Full Transaction Lifecycle Example
Step 1: Gather The Digital Wallet Data with Collect.js
This example code snippet prepares a request that indicates the customer will be charged $10 per month starting on October 31, 2025:
<script
src="https://secure.nmi.com/token/Collect.js"
data-tokenization-key="000000-000000-000000-000000"
data-variant="inline"
data-field-apple-pay-selector=".apple-pay-button"
data-field-apple-pay-line-items='[{"label":"Monthly Subscription","amount":"10.00"}]'
data-field-apple-pay-total-label="Our Fine Products"
data-field-apple-pay-type="buy"
data-country="US"
data-currency="USD"
data-price="0.00"
data-field-apple-pay-is-recurring-transaction="true"
data-field-apple-pay-recurring-payment-description="Recurring payment description"
data-field-apple-pay-recurring-billing-agreement="Recurring billing agreement"
data-field-apple-pay-recurring-management-url="https://mymanagementurl.com"
data-field-apple-pay-recurring-token-notification-url="https://mynotificationurl.com"
data-field-apple-pay-recurring-label="Recurring"
data-field-apple-pay-recurring-amount='10.00'
data-field-apple-pay-recurring-payment-timing="recurring"
data-field-apple-pay-recurring-payment-start-date='2025-10-31T00:00:00Z'
data-field-apple-pay-recurring-payment-interval-unit='month'
data-field-apple-pay-recurring-payment-interval-count='1'
data-field-apple-pay-recurring-payment-end-date=''
></script>
<form action="/myProcessingScript" method="POST">
<div id="apple-pay-button"></div>
</form>
In the customer's browser, it will show a "Pay with Apple Pay" button like this:

A screenshot of Safari showing a page with a single black "Pay with Apple Pay" button
and when they press the button, they'll see:

A screenshot of Safari showing an Apple Pay recurring payment sheet, indicating $0.00 up front and $10 per month starting October 30th.
Note: This example is minimal to focus on the Apple Pay requirements. Merchants may need wish to add other fields to support direct card number entry if they also want to accept non-Apple Pay transactions through this form, or additional customer and order details.
Step 2: Register the Subscription
When the customer finishes interacting with the Apple Pay payment sheet, the form is automatically submitted to a script on a server you control. In this example, it's called /myProcessingScript
.
In addition to any other fields the form contains, /myProcessingScript
will receive a field named payment_token
. This is used in place of conventional card data when creating the subscription. For example, you could perform a request like this:
curl --request POST \
--url https://secure.nmi.com/api/transact.php \
--header 'accept: application/x-www-form-urlencoded' \
--header 'content-type: application/x-www-form-urlencoded'
--data recurring=add_subscription \
--data plan_amount=10.00 \
--data month_frequency=1 \
--data day_of_month=31 \
--data start_date=20250731 \
--data payment_token=00000000-000000-000000-000000000000\
--data first_name=John \
--data last_name=Doe \
--data 'address1=123 Main Street' \
--data 'address2=Apt E' \
--data city=Wichita \
--data state=KS \
--data zip=12345 \
--data country=US \
--data phone=8005551212 \
--data [email protected] \
--data security_key=XXXXXXXXXXXXXXXXXXXXXXXX
When this step is performed, we execute a $0 authorization to ensure that the digital wallet data is correctly cued up.. You'll get a response including these fields:
response=1&transactionid=281474976710719&customer_vault_id=MyVaultId1...
The response=1
lets you know the request was successful.
Step 3: Normal Subscription Processing
Every month, the gateway will automatically charge the customer's payment method $10 as set up in the subscription in Step 2. No further differences in customer handling are required compared with a regular credit card subscription. You can modify or delete the subscription through the control panel.
Updated about 5 hours ago