SDK Transaction Flow

The general transaction flow of the SDK are shown as diagram below.

  1. Checkout: The customer clicks the Checkout button on the host application, and the app sends a request to the merchant server.

  2. Token request: The merchant server sends a request to the Midtrans server with order information.

  3. Token response: Midtrans responds with a valid transaction token to the merchant server.

  4. Token response: The merchant server forwards the token to the mobile SDK.

  5. Get transaction options: The mobile SDK requests payment/merchant information based on the token.

  6. Transaction options response: The mobile SDK renders the payment options and payment information for the customer to make the payment.

  7. Pay: The customer selects the payment method and payment details and clicks "Pay".

  8. Charge: The mobile SDK sends the charge request to the Midtrans backend for payment processing.

  9. Charge response: The mobile SDK receives the response from the Midtrans backend and triggers a handler on the mobile app with success/failure/pending status.

  10. Charge notification: The Midtrans backend sends a notification to the merchant backend confirming the completion of the transaction.

Additionally, there are two SDK flows based on where the snaptoken (transaction token) is created:

  • SDK Flow: The snaptoken (transaction token) is created from the host app. You need to set up the transaction details (e.g., customer and product details) on the client app for every transaction and send it to the Midtrans backend through your merchant server.

  • SnapToken Flow: You have created the snaptoken somewhere else. No transaction setup is needed in the SDK. You can just pass the snaptoken (transaction token) to the API method parameter of the SDK to start the payment directly.