Advertisement
Guest User

Untitled

a guest
Nov 14th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3.  
  4. import requests
  5. import base64
  6. import json
  7.  
  8. TEST_MERCHANT_ID = '496160873888'
  9. # Possibly have to base64 encode this.
  10. AUTH_HEADER = 'Basic ' + base64.b64encode(u'testing:testing123')
  11. TEST_TOKENIZED_CARD = '9418594164541111'
  12. BASE_URL = 'https://fts.cardconnect.com:6443/'
  13.  
  14.  
  15. def cc_put_request(endpoint, data):
  16.     data = json.dumps(data)
  17.     headers = {'Authorization': AUTH_HEADER, 'Accept': 'application/json'}
  18.     response = requests.put(url=BASE_URL + endpoint, json=data, headers=headers)
  19.     print 'response status'
  20.     print response
  21.     print 'my headers'
  22.     print response.request.headers
  23.     return response
  24.  
  25. def create_profile():
  26.     create_data = {
  27.         'defaultacct': 'Y',
  28.         'expiry': '0214',
  29.         'merchid': TEST_MERCHANT_ID,
  30.         'account': TEST_TOKENIZED_CARD
  31.     }
  32.     return cc_put_request(endpoint='cardconnect/rest/profile', data=create_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement