Payment

Version 2019-10

Note

Sales channels require elevated permissions to interact with the Payment resource. For more information, see Request payment processing.

The Payment resource allows sales channels to build a fully native checkout experience by submitting a customer's payment details directly to Shopify.

To complete a payment using the Payment resource, first create a payment session by submitting the card details to Shopify's card vault in exchange for a session ID. The session ID can then be used to create a payment for an existing Checkout.

For more information about using the Payment resource, see Completing a payment.

The Payment resource is compatible only with direct payment gateways. For a list of all supported payment gateways, see Direct and external credit card payment providers.

What you can do with Payment

The Shopify API lets you do the following with the Payment resource. More detailed versions of these general actions may be available:

Payment properties

credit_card
"credit_card": {
  "first_name": "Bob",
  "last_name": "Norman",
  "first_digits": "424242",
  "last_digits": "4242",
  "brand": "visa",
  "expiry_month": 12,
  "expiry_year": 2020
}

The details of the credit card used for payment. The following attributes are available:

  • first_name: The first name of the cardholder.
  • last_name: The last name of the cardholder.
  • first_digits: The first six digits of the credit card.
  • last_digits: The last four digits of the credit card.
  • brand: The credit card brand.
  • expiry_month: The expiry month of the credit card.
  • expiry_year: The expiry year of the credit card.

id
"id": 367556198456

A unique identifer for the payment generated by Shopify.

payment_processing_error_message
"payment_processing_error_message": "Card was declined"

A message describing the error that occured when attempting to process payment, if any.

next_action
"next_action": {
  "redirect_url": "https://shop-domain-url.myshopify.com/:shop_id/checkouts/:token/authentications/:auth_token/3ds"
}

Specifies the URL that your app or sales channel needs to send the customer to so that they can authenticate their payment. To learn more about how to use this property, refer to Authenticating payments with 3D Secure.

transaction
"transaction": {
  "amount": "323.17",
  "amount_in": null,
  "amount_out": null,
  "amount_rounding": null,
  "authorization": "ch_1CfBrOCNqnO8CNQxAtf5k9iX",
  "created_at": "2018-06-20T15:20:53-04:00",
  "currency": "USD",
  "error_code": null,
  "gateway": "shopify_payments",
  "id": 597850423352,
  "kind": "sale",
  "message": "Transaction approved",
  "status": "success",
  "test": true
}

The details of the transaction, including the following attributes:

  • amount: The amount of the transaction.
  • amount_in: The amount in before rounding is applied. Not applicable to credit card payments.
  • amount_out: The amount out after rounding is applied. Not applicable to credit card payments.
  • amount_rounding: The amount of rounding applied. Not applicable to credit card payments.
  • authorization: The authorization code returned by the payment provider.
  • created_at: The date and time when the transaction was created.
  • currency: The currency of the transaction.
  • error_code: The error code returned by the payment provider, if any.
  • gateway: The name of the payment provider which processed the transaction.
  • id: The unique identifier of the transaction.
  • kind: The kind of transaction processed, either authorization or sale.
  • message: The message returned by the payment provider, if any.
  • status: The status of the transaction, either success or failure./li>
  • test: Whether or not the transaction was a test.

unique_token
"unique_token": "client-side-idempotency-token"

A unique idempotency token generated by the app that created the payment request. For more information, refer to Idempotent requests.

Endpoints

POST https://elb.deposit.shopifycs.com/sessions
Stores a credit card in the card vault. Credit cards cannot be sent to the Checkout API directly. They must be sent to the card vault, which in response will return a session ID. This session ID can then be used when calling the POST #{token}/payments.json endpoint. A session ID is valid only for a single call to the endpoint. The card vault has a static URL and is located at https://elb.deposit.shopifycs.com/sessions. It is also provided via the payment_url property on the Checkout resource.
credit_card
required

The credit card used for payment. See the properties table above for a description of its attributes.