Knowledge Center

Knowledge Center > API > REST API > REST API Reference > Payment Methods > Create payment method

Create payment method

This REST API reference describes how to create a new credit card payment method for a customer account.

Request

  • Production: POST https://api.zuora.com/rest/v1/payment-methods/credit-cards
  • API Sandbox: POST https://apisandbox-api.zuora.com/rest/v1/payment-methods/credit-cards

This API call is CORS Enabled. Use client-side JavaScript to invoke the call. See Zuora CORS REST for more information. 

Request body

accountKey

required

ID of the customer account to update

creditCardType

required

Possible values are: Visa, MasterCard, AmericanExpress, Discover.

creditCardNumber

required

Credit card number, a string of up to 16 characters. This field can only be set when creating a new payment method; it cannot be queried or updated.

expirationMonth

required

One or two digit(s) expiration month (1-12)

expirationYear

required

Four-digit expiration year

securityCode

optional

The CVV or CVV2 security code for the credit card or debit card. Only required if changing expirationMonth, expirationYear, or cardHolderName. To ensure PCI compliance, this value isn't stored and can't be queried. For more information, see How do I control what information Zuora sends over to the Payment Gateway?

defaultPaymentMethod

 

optional

Specify true to make this card the default payment method; otherwise, omit this parameter to keep the current default payment method.

cardHolderInfo

optional

Container for cardholder information. If provided, Zuora will only use this information for this card.  If not provided, Zuora will use the account's existing bill-to contact information for this card.

cardHolderName

required

The card holder's full name as it appears on the card, e.g., "John J Smith", 50 characters or less

addressLine1

optional

First address line, 255 characters or less

addressLine2

optional

Second address line, 255 characters or less

city

required

City, 40 characters or less

state

required

State; must be a valid state name or 2-character abbreviation.

zipCode

required

Zip code, 20 characters or less

country

required

valid country name or abbreviation.

phone

optional

Phone number, 40 characters or less

email

optional

Card holder's email address, 80 characters or less

Response

success

Contains true if successful, otherwise false.

paymentMethodId

ID of the newly-created payment method

processId

Internal process ID to assist Zuora support. Only returned if success is false.

reasons

Information on one or more reasons for the result. Only returned if success is false.

code

Eight-digit numeric error code

message

Description of the error

Examples

HTTP/JSON request:

POST https://api.zuora.com/rest/v1/paymen...s/credit-cards

JSON request:

{"defaultPaymentMethod": false,
"cardHolderInfo":
  {"addressLine1": "77 Fallon Glen",
   "addressLine2": "",
   "zipCode": "94020",
   "state": "California",
   "phone": "4155551234",
   "country": "USA",
   "cardHolderName": "Bill Thiebault",
   "city": "Fremont",
   "email": "bill@testaddress.com"},
"expirationMonth": "10",
"accountKey": "A00001115",
"creditCardType": "Discover",
"expirationYear": "2015",
"creditCardNumber": "1111222233334444",
"securityCode": "123"}
JSON response:
{
  "paymentMethodId": "2c92c8f83dcbd8b1013dcce1d6a60",
  "success": true
}

CURL request:

##
## Create payment method
##
echo
echo "=============Create credit card============="
echo
curl -i -k -H "apiAccessKeyId:$USER_NAME" -H "apiSecretAccessKey:$PASSWORD" -H "Content-Type:application/json" -H "Accept:application/json" -d '
{
    "accountKey":"A00000001",
    "creditCardType":"Visa",
    "creditCardNumber":"4111111111111111",
    "expirationMonth":"10",
    "expirationYear":"2015",
    "securityCode":"111",
    "billingAddress":{
        "addressLine1":"some street",
        "city":"Beijing",
        "country":"China",
        "zipCode":"100080"
    },
    "defaultPaymentMethod":true,
    "creditCardHolderName":"Leo",
    "phone":"",
    "email":"leo@test.com"
}
' -X POST $BASE_URL/v1/payment-methods/credit-cards

JSON response:

{
  "paymentMethodId": "2c92c8f83dcbd8b1013dcce1d6a60",
  "success": true
}
Last modified

Tags

Classifications

(not set)