Managing payment methods
Learn how to manage payment methods in a cart.
Getting the available payment methods for the cart
To offer various payment options for customers, it's crucial to retrieve the available payment methods for the cart. This guide will walk you through accessing these methods using the Commerce API. By following the instructions below, you can easily integrate this functionality into your application and enhance the checkout experience for your users.
To get the available payment methods for your cart, send a GET /v1/shoppers/me/carts/active/payment-methods
request and include {Your_API_Key}
in the header. Here's an example using cURL:
curl --location -g --request GET ' https://api.digitalriver.com/v1/shoppers/me/carts/active/payment-methods' \
--header 'Authorization: Basic {Your_API_Key}' \
...
A successful response will return a JSON object with the available payment methods and related information. See the query parameters for more information.
To add an organization identifier to a cart, send a POST /shoppers/me/carts/active
request. Include {Your_API_Key}
in the header and the organizationId
field in the request payload. The organizationId
will be passed to the payment session to make specific payment methods available. Here's an example using cURL:
curl --location --request POST 'https://api.digitalriver.com/shoppers/me/carts/active' \
--header 'Content-Type: application/json' \
--header 'authorization: Basic {Your_API_Key}\
--data-raw '{
"cart": {
"organizationId": "Acme_Inc",
"lineItems": {
"lineItem":
{
"quantity": "1",
"product": {
"id": "5326162000"
}
}
}
}
}'
A successful request returns a 200 OK
response with the updated organizationId
in the cart. See the Update the current cart for more information.
To remove an organization identifier from the cart, send a POST /shoppers/me/carts/active
request. Include {Your_API_Key}
in the header. Set the organizationId
field to an empty string in the request payload. This will delete the organization identifier from the cart, resulting in a 200 OK
response if successful. Here's an example using cURL:
Last updated
Was this helpful?