Integration Guide: Customer

How to collect tokenized payment details for later using the KOMOJU Hosted Page

Suppose you want to collect your customers' payment details once, then use them to make payments at a later date. To support this, our hosted page supports creating customer objects instead of payments for long term, PCI-DSS-compliant storage.

One potential use case for this feature would be to implement a subscription system, where you collect user payment details once and then bill them monthly.

Step 1: create a session with mode=customer

The default mode for sessions is "payment". If you specify "mode": "customer" when creating your session object, the session will create a customer object instead of a payment.

The resulting session object should have a customer_id. Save this customer_id, as it will act as a token for creating future payments.

As usual, you'll want to redirect your user to the session's session_url so that they can fill in their payment information.

Step 2: listen for customer.updated webhooks

In step 1 you acquire a customer_id, but it is "empty". Until the user completes the session on KOMOJU, this customer_id cannot be used. To know when it becomes usable, you can use the customer.updated webhook to be notified and update your system accordingly.

Step 3: make payments

Once you have a usable customer_id, you can choose to omit payment_details and instead pass customer when creating payments. When done correctly, this will immediately pull money from the customer's stored account.


What’s Next