Skip to content

Instantly share code, notes, and snippets.

@elialbert
Created May 24, 2012 15:15
Show Gist options
  • Save elialbert/2782159 to your computer and use it in GitHub Desktop.
Save elialbert/2782159 to your computer and use it in GitHub Desktop.
latest paypal attempt
test_email='[email protected]'
headers = {"X-PAYPAL-SECURITY-USERID":PAYPAL_API_USERNAME,"X-PAYPAL-SECURITY-PASSWORD":PAYPAL_API_PASSWORD,"X-PAYPAL-SECURITY-SIGNATURE":PAYPAL_API_SIGNATURE,"X-PAYPAL-APPLICATION-ID":"APP-80W284485P519543T","X-PAYPAL-REQUEST-DATA-FORMAT":"NV","X-PAYPAL-RESPONSE-DATA-FORMAT":"JSON"}
payload = {
'requestEnvelope.errorLanguage':'en_US',
'emailAddress':test_email,
'cardNumber':'5178059152624418',
'cardType':'MasterCard',
'confirmationType':'WEB',
'nameOnCard.firstName':'eli',
'nameOnCard.lastName':'Albert',
'billingAddress.line1':'1448 hollywood ave',
'billingAddress.city':'Chicago',
'billingAddress.state':'IL',
'billingAddress.postalCode':'60660',
'billingAddress.countryCode':'US',
'expirationDate.year':'2014',
'expirationDate.month':'6',
}
payload = urllib.urlencode(payload)
print payload
# payload = "requestEnvelope.errorLanguage=en_US&emailAddress=%s&cardNumber=2929299292222&cardType=Visa&confirmationType=WEB"%test_email
resp = requests.post('https://svcs.sandbox.paypal.com/AdaptiveAccounts/AddPaymentCard',headers=headers,data=payload)
print resp.status_code
print resp.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment