|
| 1 | +from authorizenet import apicontractsv1 |
| 2 | +from authorizenet.apicontrollers import * |
| 3 | +from decimal import * |
| 4 | +from authorizenet.apicontractsv1 import bankAccountType, accountTypeEnum |
| 5 | + |
| 6 | +merchantAuth = apicontractsv1.merchantAuthenticationType() |
| 7 | +merchantAuth.name = '5KP3u95bQpv' |
| 8 | +merchantAuth.transactionKey = '4Ktq966gC55GAX7S' |
| 9 | + |
| 10 | + |
| 11 | +payment = apicontractsv1.paymentType() |
| 12 | + |
| 13 | +bankAccountType = apicontractsv1.bankAccountType() |
| 14 | +accountType = apicontractsv1.bankAccountTypeEnum |
| 15 | +bankAccountType.accountType = accountType.checking |
| 16 | +bankAccountType.routingNumber = "125000024" |
| 17 | +bankAccountType.accountNumber = "12345678" |
| 18 | +bankAccountType.nameOnAccount = "John Doe" |
| 19 | + |
| 20 | +transactionrequest = apicontractsv1.transactionRequestType() |
| 21 | +transactionrequest.transactionType = "refundTransaction" |
| 22 | +transactionrequest.amount = Decimal ('2.55') |
| 23 | +transactionrequest.payment = payment |
| 24 | +transactionrequest.payment.bankAccount = bankAccountType |
| 25 | + |
| 26 | + |
| 27 | +createtransactionrequest = apicontractsv1.createTransactionRequest() |
| 28 | +createtransactionrequest.merchantAuthentication = merchantAuth |
| 29 | +createtransactionrequest.refId = "MerchantID-0001" |
| 30 | + |
| 31 | +createtransactionrequest.transactionRequest = transactionrequest |
| 32 | +createtransactioncontroller = createTransactionController(createtransactionrequest) |
| 33 | +createtransactioncontroller.execute() |
| 34 | + |
| 35 | +response = createtransactioncontroller.getresponse() |
| 36 | + |
| 37 | +if (response.messages.resultCode=="Ok"): |
| 38 | + print "Transaction ID : %s" % response.transactionResponse.transId |
| 39 | + print response.transactionResponse.messages.message[0].description |
| 40 | +else: |
| 41 | + print "response code: %s" % response.messages.resultCode |
| 42 | + print response.messages.message[0].text |
0 commit comments