0% found this document useful (0 votes)
65 views2 pages

Graph

The document contains a Python script that sends a POST request to the Braintree API to tokenize a credit card. It includes headers for authorization and content type, as well as a JSON payload with credit card details and metadata. The script uses the requests library to perform the API call and handle the response.

Uploaded by

saraaed838282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views2 pages

Graph

The document contains a Python script that sends a POST request to the Braintree API to tokenize a credit card. It includes headers for authorization and content type, as well as a JSON payload with credit card details and metadata. The script uses the requests library to perform the API call and handle the response.

Uploaded by

saraaed838282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import requests

headers = {
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'authorization': 'Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjIwMTgwNDI2MTYtcHJvZHVjdGlvbiIsImlzcyI
6Imh0dHBzOi8vYXBpLmJyYWludHJlZWdhdGV3YXkuY29tIn0.eyJleHAiOjE3MzgxMTI0NDAsImp0aSI6Ij
M5YmFhOWY0LTQ4MDYtNDEzYS1hNWEwLTQyZGQyNjA0OWFlZCIsInN1YiI6InB3NGd0bWRqZzViN3lzMjQiL
CJpc3MiOiJodHRwczovL2FwaS5icmFpbnRyZWVnYXRld2F5LmNvbSIsIm1lcmNoYW50Ijp7InB1YmxpY19p
ZCI6InB3NGd0bWRqZzViN3lzMjQiLCJ2ZXJpZnlfY2FyZF9ieV9kZWZhdWx0IjpmYWxzZX0sInJpZ2h0cyI
[Link]
s9unraw0MVY-lo-
qCkozARbw6brrl9kr7nZG8L83Rpr29tgT2q73l0WTMyTJVXOLeRdM2c5HU3b3CKs8kig',
'braintree-version': '2018-05-10',
'content-type': 'application/json',
'origin': '[Link]
'priority': 'u=1, i',
'referer': '[Link]
'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A
Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/[Link] Safari/537.36',
}

json_data = {
'clientSdkMetadata': {
'source': 'client',
'integration': 'custom',
'sessionId': 'ef2d5b96-03ab-40a4-99fb-4c1610fbe1e3',
},
'query': 'mutation TokenizeCreditCard($input: TokenizeCreditCardInput!)
{ tokenizeCreditCard(input: $input) { token creditCard { bin
brandCode last4 cardholderName expirationMonth
expirationYear binData { prepaid healthcare debit
durbinRegulated commercial payroll issuingBank
countryOfIssuance productId } } } }',
'variables': {
'input': {
'creditCard': {
'number': '4462951003633325',
'expirationMonth': '10',
'expirationYear': '2027',
'cvv': '700',
},
'options': {
'validate': False,
},
},
},
'operationName': 'TokenizeCreditCard',
}
response = [Link]('[Link]
headers=headers, json=json_data)

# Note: json_data will not be serialized by requests


# exactly as it was in the original request.
#data = '{"clientSdkMetadata":
{"source":"client","integration":"custom","sessionId":"ef2d5b96-03ab-40a4-99fb-
4c1610fbe1e3"},"query":"mutation TokenizeCreditCard($input:
TokenizeCreditCardInput!) { tokenizeCreditCard(input: $input) { token
creditCard { bin brandCode last4 cardholderName
expirationMonth expirationYear binData { prepaid
healthcare debit durbinRegulated commercial payroll
issuingBank countryOfIssuance
productId } } } }","variables":{"input":{"creditCard":
{"number":"4462951003633325","expirationMonth":"10","expirationYear":"2027","cvv":"
700"},"options":{"validate":false}}},"operationName":"TokenizeCreditCard"}'
#response = [Link]('[Link]
headers=headers, data=data)

You might also like