-
Notifications
You must be signed in to change notification settings - Fork 17
Charge_Authorize
Jacob McConnell edited this page Jun 9, 2014
·
1 revision
This method provides a binding to the authorization call available through our Payment API.
##Method
###authorize
Use to charge a buyer and create a new 2Checkout sale using a secure token provided by 2co.js.
####Arguments
- dictionary Attributes
- Dictionary composed of authorization attributes. Attributes -> Authorization Attributes
####Returns
Returns an Authorization object.
####Example Usage:
twocheckout.Api.auth_credentials({
'private_key': '8CE03B2D-FE41-4C53-9156-52A8ED5A0FA3',
'seller_id': '1817037',
'mode': 'production'
})
params = {
'merchantOrderId': '123',
'token': 'ODAxZjUzMDEtOWU0MC00NzA3LWFmMDctYmY1NTQ3MDhmZDFh',
'currency': 'USD',
'total': '1.00',
'billingAddr': {
'name': 'Testing Tester',
'addrLine1': '123 Test St',
'city': 'Columbus',
'state': 'OH',
'zipCode': '43123',
'country': 'USA',
'email': '[email protected]',
'phoneNumber': '555-555-5555'
}
}
try:
result = twocheckout.Charge.authorize(params)
print result.responseCode
except TwocheckoutError as error:
print error.msg
####Example Response:
{
'lineItems': [
{
'tangible': 'N',
'name': '123',
'price': '1.00',
'description': '',
'recurrence': None,
'duration': None,
'startupFee': None,
'productId': '',
'type': 'product',
'options': [
],
'quantity': '1'
}
],
'responseMsg': 'Successfully authorized the provided creditcard',
'recurrentInstallmentId': None,
'shippingAddr': {
'city': None,
'phoneExtension': None,
'country': None,
'addrLine2': None,
'zipCode': None,
'addrLine1': None,
'state': None,
'phoneNumber': None,
'email': None,
'name': None
},
'orderNumber': '205180784763',
'currencyCode': 'USD',
'merchantOrderId': '123',
'errors': None,
'responseCode': 'APPROVED',
'transactionId': '205180784772',
'total': '1.00',
'type': 'AuthResponse',
'billingAddr': {
'city': 'Columbus',
'phoneExtension': None,
'country': 'USA',
'addrLine2': None,
'zipCode': '43123',
'addrLine1': '123 Test St',
'state': 'OH',
'phoneNumber': '555-555-5555',
'email': '[email protected]',
'name': 'Testing Tester'
}
}
To test using the sandbox, pass the mode
option with a value of sandbox
to the twocheckout.Charge.authorize
method along with your credentials.
Please feel free to contact 2Checkout directly for assistance with your integration.