Create a Payment Intent
A Payment Intent represents the intent to collect a payment. It is the central resource of the Sangho payment cycle. Here is the complete flow in 3 steps.
Step 1 (Server): Create the Payment Intent
From your backend server, create a Payment Intent with the desired amount, currency, and payment methods. The Payment Intent ID will be used to confirm the payment.
Step 2 (Client): Redirect to the payment page
The @sanghosdk/js SDK is a server-side client (Node.js) — there is no embedded payment widget on the browser side. Simply return the url field of the Payment Intent to your frontend and redirect the client to this Sangho-hosted page, which handles displaying the form.
Step 3 (Server): Confirm via Webhook
Listen for the payment_intent.succeeded event to confirm the payment server-side. Never rely on the frontend alone to confirm a payment.
The Payment Intent contains sensitive data: never expose the full details client-side. Send only the ID to the frontend.