Managing payment methods
Learn how to manage payment methods in a cart.
Managing payment methods is critical to eCommerce operations, ensuring smooth and secure transactions for sellers and customers. By effectively managing payment methods, you can offer a variety of options that cater to your users' preferences and needs, ultimately enhancing their shopping experience and increasing conversion rates. This section will guide you on managing and configuring payment methods using the Commerce API, including adding, updating, and removing payment options from your 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:
A successful response will return a JSON object with the available payment methods and related information.
For more details, refer to the Payment methods query parameters.
Adding an organization identifier to a cart
In certain scenarios, specific payment methods require an organization identifier (organizationId
). This identifier is necessary to ensure the correct payment method is available for the shopper during the checkout process. For instance, TreviPay uses a client reference_id
as the organizationId
. The following instructions explain how to add or remove an organization identifier when updating a cart. This identifier will be passed to the payment session to enable the corresponding payment methods.
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:
A successful request returns a 200 OK
response with the updated organizationId
in the cart.
For more details, refer to the API documentation.
Removing an organization identifier from the cart
To manage the organization identifier associated with a cart, you may need to remove it. Ensuring that the cart is no longer linked to a particular organization can be useful in various scenarios, such as updating or clearing organization-specific details.
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:
A successful request returns a 200 OK
response that contains no organizationId
in the cart.
Last updated