Adding Digital Wallet Data to the Customer Vault
When a customer pays with Apple Pay or Google Pay, you can store the resulting token in the Customer Vault for future use — enabling one-click checkout and recurring billing.
Frontend Setup
CollectJS.configure({
googlePay: true, applePay: true,
paymentRequest: {
total: { label: 'Your Order', amount: { currency: 'USD', value: '29.99' } },
},
callback: function(token) {
submitWithVaultStorage(token.token, token.wallet);
},
});
Backend — Process and Store
$post = array(
'security_key' => YOUR_PRIVATE_KEY,
'type' => 'sale',
'amount' => '29.99',
'payment_token' => $payment_token,
'customer_vault' => 'add_customer',
'customer_vault_id' => 'CUST-' . $user_id,
'email' => $email,
);
$result = gateway_post($post);
$vault_id = $result['customer_vault_id'];
Future Charges
$post = array(
'security_key' => YOUR_PRIVATE_KEY,
'type' => 'sale',
'amount' => '29.99',
'customer_vault_id' => 'CUST-' . $user_id,
);