first_in_series session to collect payment and save the customer’s payment method under a mandate. Each subsequent charge uses a next_in_series session, which a merchant initiates and processes programmatically without any customer interaction.
Prerequisites
- A test API key. See Authentication.
- A registered webhook endpoint. See Webhook Setup to register your URL and obtain your signing key.
Part 1: Set up the mandate
Step 1: Create a first_in_series session
Create the session server-side. The customer must be present to complete this step. They will authorise their payment method for future charges via the hosted checkout.amount is always specified in minor units. See Monetary Amounts for details.session_url for the customer to complete checkout, and a customer_id that was created for this customer.
Step 2: Launch the checkout
Redirect your customer to thesession_url. During checkout, the customer completes their payment and authorises Moment to charge their payment method for future payments under the mandate.
Step 3: Capture the customer and payment method IDs
When the customer completes checkout, Moment sends apayment_session.completed event. The data object includes both a customer_id and a payment_method_id. Store both, as you will need them for every subsequent charge.
Part 2: Collect recurring payments
Step 4: Create a next_in_series session
Use thecustomer_id and payment_method_id from Part 1. The customer is not present and the payment is processed immediately without any checkout step.
session_url in the response. The payment processes automatically and a payment_id is returned immediately.
Step 5: Handle the completion webhook
Moment sends apayment_session.completed event once the payment is processed, with the same structure as in Part 1.
Repeat Step 4 for each subsequent charge on the schedule your application manages.
Testing
Use test card4242 4242 4242 4242 with any future expiry date and any 3-digit CVC for the first_in_series checkout. See Integration Testing for the full list of test cards and error scenarios.

