Skip to main content

Card Integration Process (Once-off payments)

Once-off Card payments can be made easily by creating payment requests via the API. Users can then be guided to the returned redirect URLs, for them to complete their card payments within the Stitch-hosted UI.

Generate Payment Request URL

Much like Pay By Bank, Card creation is protected by a client token. You'll need to follow the steps described in the client token guide to obtain a client token with the client_paymentrequest scope. To create a payment initiation request, you'll need to ensure that the feature is enabled on your client.

To create the request, a GraphQL mutation is used to specify the requested amount, references and merchant information.

An example of a GraphQL request to create a payment initiation request with the Card payment method is shown below:

The following table outlines the possible inputs for Card:

enabledBoolean field used to specify enable or disable Card payments. Note that by default, this will be enabled.
Card Payment Method Details

Please note that:

  • The paymentMethods.card type requires client configuration. Contact the technical team to assist in enabling your client for this feature.
  • For now, Once Off card payments is the only card transaction that can be enabled.
  • Not setting the paymentMethods field results in an Pay By Bank request. To explicitly omit Pay by Bank as payment method, provide the paymentMethods.eft.enabled field with a value of false.

Expiring payment requests

It is highly recommended that an expireAt Date (ISO 8601) is supplied in the creation of any payment initiation request. At the specified date and time, the payment request status will automatically move to PaymentInitiationRequestExpired, if the payment is not yet successfully completed.

Saving cards per user

When a user is redirected to Stitch to complete their payment, they will have the option to save their card details for a quicker payment experience when returning. By default, when any user returns to Stitch within the same browser, they will see all previously-saved cards.

To ensure cards are saved on the basis of a unique user, specify the payerId field (part of Payer Information), as shown in the example request below. This can be any string value that uniquely maps to the user on your internal system, and is not expected to contain any user-sensitive information.

Surface URL and Handle Callback

The URL returned by the API requires that a whitelisted redirect_uri is appended to it as a query string argument. If you direct a user to this URL, they will be guided through the process of completing the payment. For test clients, we do have the following URLs whitelisted by default:

For example, if your whitelist URL configuration included the URL for payment requests, you'd append the following query string to the url returned from the API: ? The full URL you expose to the user should look like this
Whitelisting Redirect URLs

To add or remove a URL from the whitelist, please reach out to a Stitch Engineer via our Support Form

Please note that production clients will not be allowed to use unsecure redirect_uri params such as http. For example

Once the user completes or cancels the payment request, they'll be redirected back to the redirect_uri. The below query string parameters will be passed back to the redirect_uri.

Request FieldDescriptionType
idThe unique id of this payment requestID
statusStatus will have the value complete if successful, closed if the user clicked close in the UI, or failed if something went wrong when attempting the paymentString
payment_methodThe method used to complete the payment, card or eftString
externalReferenceThe value that was provided to the externalReference field when the payment initiation request was created. It can be used to correlate transaction IDs within your system with the payment request initiated by StitchString

The id can be used to retrieve the final payment request status and other details from the Stitch API, as well as relate to incoming webhooks.


The status field should not be used for any database operations since an external party can tweak it. To secure yourself from attackers who can send a fake payload to your redirect or webhook endpoint, we recommend:

  1. using the webhooks as the source of truth as they are secure and will always be sent from Stitch.
  2. making use of signed webhooks since you'll be able to verify the signature of each incoming webhook's request payload.

Using the webhooks also ensures you'll still be able to know the final status of a payment request if for example the request times out due to a network issue.

Using Multiple Internal Redirect URIs

For a situation where different callbacks lead to different internal URLs, you SHOULD have a single whitelisted redirect URL which can then have the logic handling the Stitch callback and redirect to the internal URLs. An overview of how to do this in NodeJS is as shown below:

const status = params.status;

switch (status) {
case "complete":
case "closed":
case "failed":

Cancelling Pending Payment Initiation Requests

If the user clicks the X on the dialog box, the payment initiation request will remain in the PaymentInitiationRequestPending status. To cancel the payment request, you should call the clientPaymentInitiationRequestCancel mutation, which also triggers the cancel webhook event.

Payment Initiation Request Statuses

The table below describes the different statuses a Card request can have, with the initial status always being PaymentInitiationRequestPending:

PaymentInitiationRequestCompletedThis is a final payment state.
PaymentInitiationRequestPendingThe user hasn't yet completed the payment initiation request, or they exited the Stitch dialog box before completing the bank selection process.
PaymentInitiationRequestCancelledThe payment initiation request was manually cancelled by the client. More information on this can be found here.
PaymentInitiationRequestExpiredThe payment initiation request has expired while awaiting user interaction. More information on this can be found here.

Subscribe to Webhooks

Since Card is similar to Pay By Bank, we subscribe to webhooks and receive payment updates in the same way.

If the subscription is successfully created, the body returned by the request will look like the sample in the Example Response tab in widget above.

For more information on receiving webhook events, listing active webhook subscriptions, unsubscribing from webhooks and validating signed webhook subscriptions, please visit the Webhooks page.

Webhook Statuses

When subscribed to the payment webhook filter type (applicable to Card and Pay By Bank requests), webhook updates will be sent whenever a payment request status is changed from the PaymentInitiationRequestPending state. This means that you will receive webhooks for each of the following payment request statuses:

  • PaymentInitiationRequestCompleted
  • PaymentInitiationRequestCancelled
  • PaymentInitiationRequestExpired

Retrieving Payment Request Status

The status of a Card request works much like Pay By Bank.

To determine if and how a payment request was completed, we will need to retrieve its status.

The two pieces of information you need from the response at this stage are the payment request id, and the url. The payment request id is used to correlate responses and to look up the status of the request in the API, and so should be retained for later usage. The url is used to enable the user to authorize the payment request, and you'll need to redirect the user to this URL. We'll cover this in the next section.

Testing Card Initiation

To test this process on your browser and run all the GraphQL examples in this guide prior to integrating with Stitch, you can use our sandbox. Learn more about the sandbox here.