Package: django-unionbank
django_unionbankDjango Unionbank is the library for easily integrating and consuming the Unionbank of the Philippines API with your Django Application. As of now this has been used in production for Partner Accounts(Corporate) Fund Transfers (UBP, Instapay, PESOnet) to any bank accounts and will eventually add Customer Account services as well. Codebase is functioning but still currently for standard refactoring/development and testing :)Quick StartTo install, use pip:pip install django_unionbankAdd django_unionbank to you INSTALLED_APPS settings like this:INSTALLED_APPS = [
 ...,

 'django_unionbank',

 ...
 ]Configure django_unionbank by adding these to your settings.py::USE_UNIONBANK_ONLINE=True
 UNIONBANK_CLIENT_ID=<REPLACE WITH CLIENT ID>
 UNIONBANK_CLIENT_SECRET=<REPLACE WITH CLIENT SECRET>
 UNIONBANK_PARTNER_ID=<REPLACE WITH PARTNER ID>
 UNIONBANK_API_MODE=<CHOOSE FROM SANDBOX, UAT, PROD>
 UNIONBANK_USERNAME=<REPLACE USERNAME>
 UNIONBANK_PASSWORD=<REPLACE PASSWORD>Library allows you to have certain models used to save FundTransfer Data,  SandBox Accounts, Data of Instapay and PESONet banks available. For now, saving data in the database is required to function. To do this:python manage.py migrate django_unionbankUsagePartner AuthenticationUnionBank Partner Authenticationget_partner_tokenfrom django_unionbank.api.partner_authentication import get_partner_token
 
 token = get_partner_token(scope)Parameters:scope: [str] Space separated OAuth2 scopes. Seehttps://developer.unionbankph.com/reference#tag/OAuth2-Scopesfor complete list of scopesReturns:
token = [str] Online partner access tokenPartner TransfersUnionbank Partner Account to Unionbank Account Fund Transferpartner_funds_transferfrom django_unionbank.api.identity.partner_funds_transfer
 
 transfer, message = partner_funds_transfer(token, account_number, amount, remarks="Partner Payout")Parameters:token: [str] Partner access token you can retrieve usingget_partner_tokenmethodaccount_number: [str] Valid Unionbank Account Numberremarks: [str] Remarks for the specific transactionamount:[str/decimal] Amount to transfercurrency: [str]default='PHP'Object containing additional info you want to include in transactionreference_id: [str] If not provided, package has default id generator (UBPXXXX, IPYXXXX, PSOXXXX)info: [list] Object containing additional info you want to include in transactionReturns:transfer = FundTransfer object. Check models.pymessage = Response messagesample_info = [
      {
          "index": "1",
          "name": "Recipient",
          "value": "Juan dela Cruz"
      },
      {
          "index": "2",
          "name": "Message",
          "value": "Sample Message"
      },
      {
          "index": "3",
          "name": "Custom Info",
          "value": "Custom Value"
      }
  ]Unionbank Partner Account InstaPay Transferpartner_instapay_fund_transferfrom django_unionbank.api.instapay.partner_instapay_fund_transfer
 
 transfer, message = partner_instapay_fund_transfer(token, data)Parameters:token: [str] Partner access token you can retrieve usingget_partner_tokenmethoddata: [list] Information regarding transfer to be made in the following prescribed formatreference_id: [str] If not provided, package has default id generator (UBPXXXX, IPYXXXX, PSOXXXX)Returns:transfer = FundTransfer object. **Check models.pymessage = Response messagedata = {
      'sender_name': <[str] SENDER NAME>,
      'sender_address': {
              "line1": <[str]>,
              "line2": <[str]>,
              "city": <[str]>,
              "province": <[str]>,
              "zipCode": <[str]>,
              "country": <[str]>
          },
      'beneficiary_account': <[str] RECIPIENT ACCOUNT NUMBER>,
      'beneficiary_name': <[str] RECIPIENT ACCOUNT NAME>,
      'beneficiary_address': {
              "line1": <[str]>,
              "line2": <[str]>,
              "city": <[str]>,
              "province": <[str]>,
              "zipCode": <[str]>,
              "country": <[str]>
          },
      'remittance_amount': <[str/decimal] TRANSFER AMOUNT>,
      'remittance_bank': <[int] InstaPay bank code - see "update_instapay_banks" method for data of valid bank with codes>
      'remittance_purpose': <1001 or 1002 or 1003>,
      'remittance_instructions': <[str] Optional Instructions/Remarks here>
  }Unionbank Partner Account PESONet Transferpartner_pesonet_fund_transferfrom django_unionbank.api.pesonet.partner_pesonet_fund_transfer
 
 transfer, message = partner_pesonet_fund_transfer(token, data)Parameters:token: [str] Partner access token you can retrieve usingget_partner_tokenmethoddata: [list] Information regarding transfer to be made in the following prescribed formatreference_id: [str] If not provided, package has default id generator (UBPXXXX, IPYXXXX, PSOXXXX)Returns:transfer = FundTransfer object. **Check models.pymessage = Response messagedata = {
      'senderRefId': <[str] Reference ID here]>,
      "tranRequestDate": <[str] Datetime ISO Format (i.e. datetime.now().isoformat()[:-3]>,
      "sender": {
          "name": <[str] Sender Name]>,
          "address": {
                      "line1": <[str]>,
                      "line2": <[str]>,
                      "city": '<[str]>',
                      "province": <[str]>,
                      "zipCode": <[str]>,
                      "country": <[str]>
          }
      },
      "beneficiary": {
          "accountNumber": <str> RECIPIENT ACCOUNT NUMBER>,
          "name": <str> RECIPIENT NAME>,
          "address": {
                      "line1": <[str]>,
                      "line2": <[str]>,
                      "city": <[str]>,
                      "province": <[str]>,
                      "zipCode": <[str]>,
                      "country": <[str]>
          }
      },
      "remittance": {
          "amount": <[str] representation of amount with 2 decimal places>>,
          "currency": <[str] 'PHP'>,
          "receivingBank": <[int] InstaPay bank code - see "update_pesonet_banks" method for data of valid banks with codes>,
          "purpose": <1001, 1002, 1003>,
          "instructions": <[str] Optional Instructions/Remarks here>
      }
  }InstaPay and PESONet partner banksupdate_instapay_banksandupdate_pesonet_banksReturns: list of partner banks for the respective serviceCalling these methods allows you to save all partner banks available to the database mapped via the InstapayBank and PESONetBank models respectivelyfrom django_unionbank.api.instapay import update_instapay_banks
from django_unionbank.api.instapay import update_pesonet_banks

instapay_bank_list = update_instapay_banks()
pesonet_bank_list = update_pesonet_banks()

# model classes available in: django_unionbank.models.pyPartner Account Balanceget_last_running_balanceReturns:
balance = Remaining Balance on the account
records = last 10 activity/transaction records
record_count = total record/activity count in accountfrom django_unionbank.api.identity import get_last_running_balance

  balance, records, record_count = get_last_running_balance()