Payment Flow

How PaygreenJS handle payment

PaygreenJS works with a system of PaymentFlow. The purpose of this guide is to explain what is a payment flow and how PGJS handle them.

What is a Payment Flow?

A payment flow is a PGJS concept that tracks a single payment attempt. It contains information such as:

  • Chosen payment method
  • Status
  • Amount
  • And other details

When a payment flow is created:

  • It has no payment method defined (except the first flow if you set it using the paymentMethod option at init).
  • No payment form is displayed until a method is set.
  • You can change the method using setPaymentMethod().

Payment flows are mainly used in payment mode.


How Are They Used?

PGJS creates a new payment flow each time the buyer attempts a payment until the total amount of the payment order is reached.

  • For multiple payment methods (e.g., bank card + meal voucher), each method will have its own payment flow.

Cases Where the Flow Logic Stops

PGJS may break the flow logic in these situations:

  1. The max_operation of the payment order is reached.
  2. partial_allowed is true, and a first flow is successful.
  3. The payment order status changes to something other than pending.

Important Notes

  • The amount of a payment flow is null until the status is success. The exact authorized/captured amount is only known after the API responds.
  • You can get additional flow details by parsing the payment order operations (using the status method).
419