API Reference

Save COF - CP - manual capture - customer with intent - Stripe

STRIPE: Save a card-on-file when card present. Manual capture the payment method and attach the customer with the intent.

This document is for the STRIPE integration.

Step 1: Create Payment Intent

You will need to first create an intent with an external_customer_id and capture_method set to manual.

// POST /v1/payment/intent
{
    external_account_id: "my merchants account id",
    amount: 12.99,
    payment_method_types: 'card_present',
    capture_method: 'manual',
    external_transaction_id: "my transaction id",
    external_customer_id: "customer_12345"
  }

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: Capture payment

The payment must be captured before we can add the card on file.

// POST /v1/payment/capture'
{
  payment_id: 'pi_1HukElJKggKyYsMVXSTqKZ24',
  amount: '12.99',
  external_account_id: 'account_123456'
}
const params = {
  payment_id: 'pi_1HukElJKggKyYsMVXSTqKZ24',
  amount: '12.99',
  external_account_id: 'account_123456'
};
axios.post('/v1/payment/capture', params).then((response) => {
  if (response.data.error) {
    console.error(response.data.error);
  } else {
    console.log(response);
  }
}.catch((err) => {
  console.error(err);
});

Step 4: 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)