Skip to content

Instantly share code, notes, and snippets.

@tristansokol
Created October 30, 2017 19:22
Show Gist options
  • Save tristansokol/335a67980cf90a9f437edc906b59b4a3 to your computer and use it in GitHub Desktop.
Save tristansokol/335a67980cf90a9f437edc906b59b4a3 to your computer and use it in GitHub Desktop.
# use Square's SDK to make your job easier
import squareconnect
from squareconnect.apis.customers_api import CustomersApi
from squareconnect.models.create_customer_card_request import CreateCustomerCardRequest
# setup authorization with your access token
squareconnect.configuration.access_token = 'sandbox-sq0atb-XXXXXXXX'
# using a hardcoded nonce, but in a production evironment you'll need to use the
# payment form:
# https://docs.connect.squareup.com/payments/sqpaymentform/sqpaymentform-overview
nonce = 'fake-card-nonce-ok'
# Your customer id will likely be dynimcally chosen, but again we will use a
# hard coded example
customer_id = 'CBASEBW5Mh0hBis1BAGMoXamePwgAQ'
# create an instance of the Location API class
api_instance = CustomersApi()
customer_card = CreateCustomerCardRequest()
customer_card.card_nonce = nonce
customer_card.cardholder_name = 'Sam Smith'
# call the API to create the employee and print the results
api_response = api_instance.create_customer_card(customer_id,customer_card)
print (api_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment