Working with saved customer credit cards

Below you will find information on how to save, retrieve, and delete customer credit cards. Currently this is only available for the online_credit payment method, using either the Stripe, or Authorize.Net payment gateways.

Please make sure you read the Conventions before continuing with this guide.

Prerequisites

You will need an X-API-KEY.

Steps to save a credit card

1) Authenticate customer

First, you must authenticate.

Store the shortToken from the authentication response, so that you can use it in subsequent API calls. You will also need the paymentMethodId, and customerId

2) Get the 'online_credit' payment method

You can get all available payment methods from this endpoint: /btrz-pay/payment-methods

Find the record with a method of "online_credit", the _id returned will be used in all calls related to customer cards.

3) Get a list of the current saved customer credit cards

Check to see if the current customer has any credit cards already saved.

Use the endpoint documented here: /btrz-pay/payment-methods

This will provide a list of all saved credit cards, and their default card if available.

4) Create a customer saved credit card record

If you need to save a new credit card for a customer you will use the information provided by the customer to try and create a saved credit card for future purchases.

Use the endpoint documented here: /btrz-pay/payment-methods

5) Delete a customer saved credit card record

If a customer wants to remove a card from their profile, you can call this endpoint with the appropriate id, to remove the saved credit card from the system.

Use the endpoint documented here: /btrz-pay/payment-methods

6) Paying with a saved credit card

This works the same as a regular payment using the online_credit payment type, with a slight adjustment to the payload.

You can see an example here: Payment payload details, for Authorize.Net and Stripe.

Postman resources

If you would like to use Postman to test the API, we have included a collection you can use as a starting point below.

This collection is designed to allow you to create/retrieve/delete saved customer credit card information.

After importing the collection, and the environment, make sure your collection is using the new environment, and that you have set the initial values. While each step will attempt to add variable data needed for subsequent steps, you may decide you want to delete these automated steps, and manually enter the data.

If you are going to be using our API in sandbox, please change the {{basePath}} environment variable to https://sandbox-api.betterez.com.

Postman Collection

Postman Environment