Create Payment Order

Now that the library is installed and configured, let's create your first payment order (different payment processor's use different terminology - order, intent, transaction and so on). Conceptually, it represents the user's intent to start a payment session.

Once you implement this basic plumbing, you will be able to switch the request to any other payment processot, by changing one-line of code.

  • If you depend on your Payment processor/ PCI vault for PCI compliance: Lets start by creating a payment intent (order) with Stripe, which you can then use to complete the payment with Stripe.js on your frontend to collect payment details - if you are not PCI compliant.

  • If you are managing PCI compliance on your own: You should be able to collect card data from the user and directly pass it to the payment processor. Ignore this section and directly jump to First Payment.

How to Create a Payment Order with Stripe?

Prerequisites

Create an order to get a sessionToken (client secret) from Stripe. The library will initiate the payment intent API of Stripe.

const { PaymentClient } = require('hyperswitch-prism');

// stripeClient is configured in installation.md
const order = await stripeClient.createOrder({
    merchantOrderId: 'order-123',
    amount: {
        minorAmount: 1000,  // $10.00
        currency: 'USD'
    },
    orderType: 'PAYMENT',
    description: 'Test order'
});

console.log('Order ID:', order.connectorOrderId);
console.log('Client Secret:', order.sessionToken?.clientSecret);

How to Create a Payment Order with Adyen?

Prerequisites

Create an order to get a sessionToken (session_id, session_data) from Adyen. The library will initiate the sessions API of Adyen.

What Just Happened?

The library helped you create a Payment Order with the specified payment processor. You will receive a connectorOrderId and optionally a sessionToken in the response (Stripe returns a client secret, Adyen returns different session data).

The order is in STARTED state, ready for the next step - Authorize.

How to use the secret to trigger the payment processor's checkout?

Now, pass the sessionToken data to your frontend and use it to initiate Stripe Elements or Adyen Card Component for PCI compliant card element. The users will be able to key in the card details on the Stripe Element/ Adyen Card Component and you will get a tokenized payment_method_id.

You can proceed to the making the first payment

Next Steps

Last updated

Was this helpful?