- Payment
- What you can do with Payment
- Payment properties
- Endpoints
- Create a payment session with the specified billing details.
- Creating an authorization with a valid session ID but an invalid credit card number fails and returns errors
- Create an authorization using a valid
session_id
stored in the vault - Creating an authorization with a valid session can fail for various reasons
- Creating an authorization with an invalid session ID fails and returns errors
- Retrieve all the payments on a checkout
- Retrieve a payment with a succesful transaction
- Retrieve a payment with a failed transaction
- Retrieve the number of payments on a checkout
Payment
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:
- POST https://elb.deposit.shopifycs.com/sessionsStores a credit card in the card vault
- POST /admin/api/2021-01/checkouts/{token}/payments.jsonCreates a new payment
- GET /admin/api/2021-01/checkouts/{token}/payments.jsonRetrieves a list of payments on a particular checkout
- GET /admin/api/2021-01/checkouts/{token}/payments/{payment_id}.jsonRetrieves a single payment
- GET /admin/api/2021-01/checkouts/{token}/payments/count.jsonCounts the number of payments attempted on a checkout
Payment properties
credit_card | plain "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 | plain "id": 367556198456 A unique identifer for the payment generated by Shopify. |
payment_processing_error_message | plain "payment_processing_error_message": "Card was declined" A message describing the error that occured when attempting to process payment, if any. |
next_action | plain "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 | plain "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 | plain "unique_token": "client-side-idempotency-token" A unique idempotency token generated by the app that created the payment request. |
Endpoints
POSThttps://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<font style="background-color:#F4F6F8;">payment_url</font>
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. |
---|---|
Create a payment session with the specified billing details.
POST https://elb.deposit.shopifycs.com/sessions
{
“credit_card”: {
"number": "1",
"first_name": "John",
"last_name": "Smith",
"month": "5",
"year": "15",
"verification_value": "123"
}
}
POST/admin/api/2021-01/checkouts/{token}/payments.json Creates a payment on a checkout using the session ID returned by the card vaultamount REQUIRED | The amount of the payment. |
---|---|
request_details REQUIRED | The details of the request, including the following attributes: + ip_address: The IP address of the customer. + accept_language: The language preferences of the customer, in the same format as a standard Accept-Language request header. + user_agent: The user agent string for the customer’s device. |
session_id REQUIRED | A session ID provided by the card vault when creating a payment session. |
unique_token REQUIRED | A unique idempotency token generated by your app. This can be any value, but must be unique across all payment requests. |
Creating an authorization with a valid session ID but an invalid credit card number fails and returns errors
POST /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json
{
“payment”: {
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en-US,en;q=0.8,fr;q=0.6",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
},
"amount": "419.49",
"session_id": "global-f9949ad4e67f7b46",
"unique_token": "client-side-idempotency-token"
}
}
Create an authorization using a valid session_id
stored in the vault
POST /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json
{
“payment”: {
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en-US,en;q=0.8,fr;q=0.6",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
},
"amount": "398.00",
"session_id": "global-7502bb32eb6ea9d4",
"unique_token": "client-side-idempotency-token"
}
}
Creating an authorization with a valid session can fail for various reasons
POST /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json
{
“payment”: {
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en-US,en;q=0.8,fr;q=0.6",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
},
"amount": "398.00",
"session_id": "global-1b65d49c36a4f469",
"unique_token": "client-side-idempotency-token"
}
}
Creating an authorization with an invalid session ID fails and returns errors
POST /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json
{
“payment”: {
"request_details": {
"ip_address": "123.1.1.1",
"accept_language": "en-US,en;q=0.8,fr;q=0.6",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
},
"amount": "419.49",
"session_id": "global-an_invalid_session_id",
"unique_token": "client-side-idempotency-token"
}
}
GET/admin/api/2021-01/checkouts/{token}/payments.json Retrieves a list of payments on a particular checkoutRetrieve all the payments on a checkout
GET /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json
GET/admin/api/2021-01/checkouts/{token}/payments/{payment_id}.json Retrieves the payment information for an existing paymentRetrieve a payment with a succesful transaction
GET /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json
Retrieve a payment with a failed transaction
GET /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json
GET/admin/api/2021-01/checkouts/{token}/payments/count.json Counts the number of payments attempted on a checkoutRetrieve the number of payments on a checkout
GET /admin/api/2021-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/count.json