Vault a redirect payment method
Store an alternative payment instrument like PayPal or GoCardless for future use.
At the moment, our API allows you to vault payment methods for the services below.
- GoCardless
- PayPal
A redirect payment method can be stored by calling the
POST /payment-methods
API. The call requires a method
, a
redirect_url
, a country
(optional) and a currency
(optional).
Additionally, the API call accepts a buyer_id
or buyer_external_identifier
which can be used to associate a card to a previously created buyer.
2-step process
Storing a redirect payment method is a 2-step process that requires a buyer-redirect to get explicit authorization.
Step 1. Initialize a new redirect payment method
The first step is to initialize a new redirect payment method. A redirect_url
needs to be provided to redirect the user back to your application after they
have approved access to their account. However, country
and currency
are
optional and depend on the service to be used to vault the payment method.
In this example, we will use GoCardless to create a payment method.
The API returns a new payment-method
resource for which the status
is set to
buyer_approval_required
.
Step 2. Redirect the user
For the next step, you will need to redirect the buyer to the URL specified in
the approval_url
field of the response.
The buyer then logs in to their account and authorizes it to be used by Gr4vy.
After this, the buyer is redirected back to the redirect_url
you specified
earlier. For example:
The payment_method_id
query parameter represents the ID of the payment method
that this account has been stored as. The status
represents the status of the
payment method, which in most cases should be stored
.
(Optional) Step 3. Confirm the authorization
Finally, you could make an optional API call to confirm the payment method has been fully stored.
The API will return the same payment-method
resource with its updated status.
Was this page helpful?