Explore a full, working sample of integration with Fanspay Checkout. The client- and server-side code redirects to a prebuilt payment page hosted on Fanspay.

1. Set up the server

1.1 Get your secret key

First of all, you need to log in to Fanspay Dashboard and get your API secret key.

1.2 Create a Checkout Session

Add an endpoint on your server that creates a Checkout Session. A Checkout Session controls what your customer sees on the payment page such as line items, the order amount and currency, and acceptable payment methods.

1.3 Define a product to sell

Always keep sensitive information about your product inventory, such as price and availability, on your server to prevent customer manipulation from the client. Define product information when you create the Checkout Session using objects of item, price, and product.

1.4 Supply success and cancel URLs

Specify URLs for success and cancel pages — make sure they’re publicly accessible so Fanspay can redirect customers to them. You can also handle both the successful and canceled states with the same URL.

1.5 Redirect to Checkout

After creating the session, redirect your customer to the URL for the Checkout page returned in the response.

2. Build your checkout

2.1 Add a success page

Create a success page for the URL you provided as the Checkout Session success_urlto display order confirmation messaging or order details to your customer. Fanspay redirects to this page after the customer successfully completes the checkout.

2.2 Add a canceled page

Add another page for cancel_url. Fanspay redirects to this page when the customer clicks the back button in Checkout.

2.3 Add an order preview page

Finally, add a page to show a preview of the customer’s order. Allow them to review or modify their order — as soon as they’re sent to the Checkout page, the order is final and they can’t modify it without creating a new Checkout Session.

2.4 Add a checkout button

Add a button to your order preview page. When your customer clicks this button, they’re redirected to the Fanspay-hosted payment page.


You have a basic Checkout integration working. Now you need to set up a webhook to fulfill orders after a payment succeeds. Webhooks are the most reliable way to handle business-critical events.

What’s Next