Create a Credit Card

Last edit:  Sep 03, 2018

Contributors:  pavelloz

To create a credit card send a POST request to /api/user/credit_cards

HTTP request

POST /api/user/credit_cards

Parameters

Parameter Type Description Required Notes
form_configuration_name String Name of the form configuration Required underscored
form CreditCardForm CreditCardForm parameters that corresponds with FormConfiguration configuration Required

CreditCard Parameters

Parameter Type Description Required Notes
credit_card_token String Optional
payment_method_id Integer Optional

Example request

"authorization: Token token=[YOUR API TOKEN]"
"accept: application/json"
"content-type: application/json"

{
  "form_configuration_name": "reference_rest_api_credit_card_create",
  "form": {
    "credit_card_token": "abc123",
    "payment_method_id": 1
  }
}
Element Type Description Required?
form_configuration_name String Name of the defined FormConfiguration Required
form CreditCardForm Attributes for user, should match configuration defined in corresponding FormConfiguration Required

Example response

HTTP/1.1 201 Created
Content-Type: application/vnd.api+json

{
  "id": 1,
  "errors": {}
}

Element Type Description
id Integer Object identifier
errors Object Validation errors

Error and Status Codes

Code Message Meaning
201 Created Resource was created
401 Unathorized Invalid Authentication
406 Not Acceptable Wrong parameters passed
422 Unprocessable Entity Wrong values, not matched validations