示例#1
0
 def transfer(self):
     gateway = AfricasTalkingGateway(self.APP_USERNAME, self.API_KEY)
     recipient1 = {
         'bankAccount': {
             'accountName': 'Femi Kuti',
             'accountNumber': '11100223456',
             'bankCode': 234003
         },
         'currencyCode': 'NGN',
         'amount': 100,
         'narration': 'May Salary',
         'metadata': {
             'referenceId': '1235',
             'officeBranch': '201'
         }
     }
     recipient2 = {
         'bankAccount': {
             'accountName': 'Fela Kuti',
             'accountNumber': '22200223456',
             'bankCode': 234004
         },
         'currencyCode': 'NGN',
         'amount': 50,
         'narration': 'May Salary',
         'metadata': {
             'referenceId': '1236',
             'officeBranch': '201'
         }
     }
     recipients = [recipient1, recipient2]
     try:
         responses = gateway.bankPaymentTransfer(
             productName_='Airtime Distribution', recipients_=recipients)
         for response in responses:
             print "accountNumber=%s;status=%s;" % (
                 response['accountNumber'], response['status'])
             if response['status'] == 'Queued':
                 print "transactionId=%s;transactionFee=%s;" % (
                     response['transactionId'], response['transactionFee'])
             else:
                 print "errorMessage=%s;" % response['errorMessage']
     except AfricasTalkingGatewayException, e:
         print 'Encountered an error while transfering: %s' % str(e)