PlexySDK DOCS
React Native

Advanced Flow

Drive the /payments and /payments/details calls yourself from React Native

Advanced Flow

On the advanced flow, your server calls the Payments API directly and the SDK drives the native UI and any additional actions (3D Secure, QR codes, redirects). Use it when you need full control over the payment request — custom fraud fields, order orchestration, or server-side routing.

Your server calls /v2/paymentMethods and returns the response to the app.

The shopper fills in the native UI; the SDK gives you encrypted data in onSubmit.

Your server calls /v2/payments with that data.

If the response contains an action, hand it back to the SDK; final details arrive in onAdditionalDetails.

1. Fetch payment methods

curl -X POST https://api.plexypay.com/v2/paymentMethods \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": { "value": 10000, "currency": "KZT" },
    "countryCode": "KZ",
    "shopperLocale": "ru-RU"
  }'

Pass the raw JSON response to the app.

2. Wire up PlexyCheckout

Instead of a session, provide paymentMethods plus the advanced-flow callbacks:

import { useCallback } from 'react';

import { PlexyCheckout } from '@plexy/react-native';

import { configuration } from './configuration';

function CheckoutScreen({ paymentMethods }) {
  const onSubmit = useCallback(async (data, component) => {
    // data contains the encrypted payment method and the platform-correct returnUrl
    const response = await api.makePayment({
      ...data,
      returnUrl: data.returnUrl,
    });

    if (response.action) {
      // 3D Secure, redirect, QR code, await — let the SDK handle it natively
      component.handle(response.action);
    } else {
      component.hide(response.resultCode === 'Authorised');
    }
  }, []);

  const onAdditionalDetails = useCallback(async (paymentData, component) => {
    const response = await api.makeDetailsCall(paymentData);
    component.hide(response.resultCode === 'Authorised');
  }, []);

  const onError = useCallback((error, component) => {
    component.hide(false);
  }, []);

  return (
    <PlexyCheckout
      config={configuration}
      paymentMethods={paymentMethods}
      onSubmit={onSubmit}
      onAdditionalDetails={onAdditionalDetails}
      onError={onError}
    >
      <PayButton />
    </PlexyCheckout>
  );
}

Starting the payment is the same as on the sessions flow — usePlexyCheckout().start('dropIn'), any payment method type from your /paymentMethods response, or the embedded <CardView /> component for an inline card form.

Memoize your callbacks with useCallback — inline functions re-register native event listeners on every render.

3. Make the /payments call

From onSubmit, forward data to your server and call /v2/payments. Two details matter:

  • Include returnUrl: data.returnUrl in the request. The SDK resolves the correct value per platform (on Android Drop-in the return URL is managed natively).
  • If the response contains an action object, pass it to component.handle(action). The SDK presents the native challenge (3D Secure 2, redirect, QR code) and later fires onAdditionalDetails.
const onSubmit = useCallback(async (data, component) => {
  const response = await api.makePayment(data);
  if (response.action) {
    component.handle(response.action);
  } else {
    component.hide(response.resultCode === 'Authorised');
  }
}, []);

4. Submit additional details

After the shopper completes an action, onAdditionalDetails(paymentData, component) fires. Forward paymentData to your server's /v2/payments/details call, then dismiss the UI with component.hide(success).

See Result codes for how to interpret resultCode.

Standalone action handling

For an API-only integration — you render your own payment form and only need the SDK for native 3D Secure or redirect challenges — use PlexyAction.handle directly, without the <PlexyCheckout> provider:

import { PlexyAction } from '@plexy/react-native';

const data = await PlexyAction.handle(apiResponse.action, {
  environment: 'test',
  clientKey: 'YOUR_CLIENT_KEY',
});
const result = await api.makeDetailsCall(data);

The native installation steps (return URL handler, intent filter) are still required for redirect actions to make it back into your app.

Removing stored payment methods

To let shoppers delete stored cards from Drop-in on the advanced flow, set dropin.showRemovePaymentMethodButton: true and implement onDisableStoredPaymentMethod — call your backend to disable the token, then resolve() or reject(). See the Drop-in options and Manage tokens.

On this page