- Platform Overview
- Resources and Guides
-
POS Integration
-
Getting Started
-
Core Concepts
-
Integration SDK
-
Certification
-
- Order Ahead
-
Provider Enablement
-
Provider Enablement
-
Endpoints
-
Developer Endpoints
-
-
API Reference
-
Getting Started
-
v15
-
- Access Tokens
- Campaigns
- Credit Cards
- Users
- Credit
- Locations
- Payment Methods
- QR Codes
- Progress Adjustments
- Orders
- Rewards
- Gift Cards
-
-
v14
-
- Credit
- Access Tokens
- Campaigns
- Categories
-
Credit Cards
- Create
- Delete
- Interstitials
- Locations
- Loyalty
- Orders
- Payment Tokens
- Support Tickets
- Users
-
-
Credit Cards .: Create
API Reference / v14
Create a Credit Card
This endpoint adds a new credit card for a user.
To add a credit card, you must have a user access token.
All credit cards must be turned into braintreepaymentnonces with a tokenization key by using one of the applicable Braintree tokenization libraries.
Note: If you are using the LevelUp Sandbox for development, please see our list of test credit cards.
Request Endpoint
POST /v14/credit_cards
Authorization Required – User Token in Header
Authorization: token user="123897-99SCvr3kSe3TqqQid3DyPXfo2Kq98MyhF6CaNPqoDeMhJ18Uopq19uddcznu6R"
Request Body
{
"credit_card": {
"braintree_payment_nonce": "fake-valid-visa-nonce"
}
}
Request Parameters
Param | Type | Required | Description |
---|---|---|---|
braintree_payment_ nonce
|
String | Yes | The nonce returned from Braintree using the applicable client side tokenization library. |
cURL Example
curl -X POST https://sandbox.thelevelup.com/v14/credit_cards \
-H Accept:application/json \
-H Content-Type:application/json \
-H 'Authorization:token 123897-99SCvr3kSe3TqqQid3DyPXfo2Kq98MyhF6CaNPqoDeMhJ18Uopq19uddcznu6R' \
-d '{
"credit_card": {
"braintree_payment_nonce": "fake-valid-visa-nonce"
}
}'
Example Response
HTTP/1.1 200 OK
{
"credit_card": {
"bin": "123456",
"description": "Visa ending in 1234",
"expiration_month": 7,
"expiration_year": 2015,
"id": 305999,
"last_4": "1234",
"nickname": "Main Account",
"promoted": true,
"state": "active",
"type": "Visa"
}
}
Response Parameters
Key | Type | Description |
---|---|---|
bin |
String | The first six digits of the card number. |
description |
String | A human-readable description of the credit card. |
expiration_month |
Integer | The month in which the card expires. |
expiration_year |
Integer | The year in which the card expires. |
id |
Integer | The credit card’s ID. |
last_4 |
String | The last four characters of the card number. |
nickname |
String | The account’s nickname. |
promoted |
Boolean | Whether the card is the user’s promoted payment instrument. |
state |
String | The card’s state. Possible values: “active” — the card is available to be charged, “inactive” — the card may not be charged. |
type |
String | The type of card, e.g. Visa, Mastercard |
Errors
The credit card details were invalid
HTTP/1.1 422 Unprocessable Entity
[
{
"error": {
"object": "credit_card",
"property": "expiration_year",
"message": "Expiration year is invalid."
}
}
]
The credit card is already used by another LevelUp user
HTTP/1.1 422 Unprocessable Entity
[
{
"error": {
"object": "credit_card",
"property": "number",
"message": "This card has already been associated with another LevelUp account..."
}
}
]