API Reference

Save COF - CP - auto capture - customer later - Stripe

STRIPE: Save a card-on-file when card present. Auto capture the payment method and attach the customer later.

This document is for the STRIPE integration.

Step 1: Create Payment Intent

If you'd like to capture a card for on-file from a terminal payment, you will have to do things a little different than CNP. You will need to first create an intent with allow_saving_card set to true and capture_method set to automatic. The following example will create an intent that will provide a payment token after the payment is captured.

// POST /v1/payment/intent
{
    external_account_id: "my merchants account id",
    amount: 12.99,
    payment_method_types: 'card_present',
    capture_method: 'automatic',
    external_transaction_id: "my transaction id",
    allow_saving_card: true  
  }

Step 2: Collect Payment Method

Using the Stripe Terminal SDK collect the payment method from the customer.

terminal.collectPaymentMethod(client_secret).then(function(result) {
  if (result.error) {
    // Placeholder for handling result.error
  } else {
    log('terminal.collectPaymentMethod', result.paymentIntent);
    terminal.processPayment(result.paymentIntent).then(function(result) {
    if (result.error) {
      console.log(result.error)
    } else if (result.paymentIntent) {
      paymentIntentId = result.paymentIntent.id;
      log('terminal.processPayment', result.paymentIntent);
    }
  });
}

Step 3: Save card on file

After the card is captured, you will need to call the customer card API to add the card on file using the payment_id.

This can be done client-side or server-side and will attach the payment ID to a customer.

NOTE: you do not need to save the customer ID and card ID as you can always access them using your external customer ID, but for speed of making payments, you might want to keep them to avoid additional API calls to retrieve them.

// POST /v1/customer/card
{
  payment_id: 'pi_123456',
  external_customer_id: 'customer_12345',
  external_account_id: 'account_123456'
}
const params = {
  payment_id: 'pi_123456',
  external_customer_id: 'customer_12345',
  external_account_id: 'account_123456'
};
axios.post('/v1/customer/card', params).then((response) => {
  if (response.data.error) {
    console.error(response.data.error);
  } else {
    console.log(response);
  }
}.catch((err) => {
  console.error(err);
});
import requests

url = "https://<your portal domain>/v1/customer/card"

payload = {
    "external_account_id": "account_123456",
    "external_customer_id": "customer_123456",
    "payment_id": "pi_123456"
}
response = requests.post(url, json=payload)

print(response.text)