hyperpay-sdk v1.0.8
New v1.0.8 · Apple Pay networks up to iOS 26

Accept HyperPay payments in React Native

A native bridge to the official HyperPay mobile SDK. Charge VISA, Mastercard, MADA, AMEX and 40+ card brands, take Apple Pay, handle 3-D Secure, and turn every result code into a clear status — fully typed.

$npm install react-native-hyperpay-sdk

Everything a HyperPay checkout needs

The official OPPWA SDKs for iOS and Android ship inside the package. You write TypeScript; the bridge handles the native side.

Card payments

VISA, Mastercard, MADA, MEEZA, AMEX and 41 typed brands through one call.

Apple Pay

Native payment sheet with 35 networks, including mada and Meeza.

3-D Secure 2

Challenges run natively, with redirect back to your app via a deep link.

610 result codes

Map any HyperPay code to a status and description, offline.

TypeScript first

Typed params, responses, brands, networks and country codes.

Loading hook

useTransactionLoading() tracks native progress for your UI.

How a payment flows

Your access token stays on your server. The app only handles a short-lived checkoutID.

  1. Your server

    Create a checkout

    Send the amount, currency and entity ID to HyperPay and return the checkout id to the app.

    POST /v1/checkouts
  2. This SDK

    Pay in the app

    Collect the card or open Apple Pay. The native SDK sends the details straight to HyperPay.

    CARD · APPLE PAYcreatePaymentTransaction()
  3. Issuer bank

    3-D Secure

    The bank may ask the shopper to confirm. They return to your app through the deep link.

    REDIRECTshopperResultURL
  4. Your server

    Verify the result

    Fetch the payment status, then map the code to a clear outcome.

    GET /v1/checkouts/{id}/payment
Getting started

Requirements#

DependencyMinimumNotes
React Native0.63+Bare app or Expo dev client (not Expo Go).
iOS13.0+Set by the podspec. Apple Pay networks have their own minimums.
Xcode16+Needed for the bundled OPPWAMobile.xcframework.
AndroidminSdk 24Builds with compileSdk 35 / targetSdk 35 by default — overridable.
HyperPay account—Access token and entity ID(s), test and live.

The native SDKs are bundled — OPPWA Mobile 7.11.0 on Android and the IPWorks 3DS SDK on both platforms — so there is nothing to download from HyperPay.

Getting started

Installation#

npm install react-native-hyperpay-sdk

iOS

cd ios && pod install

Android

Nothing to add — auto-linking registers the native module. Rebuild the app after installing.

Expo: this is a native module, so it doesn’t run in Expo Go. Use a bare app, or Expo with a custom dev client (npx expo prebuild).

Getting started

Initialize#

Call HyperPay.init() once before any payment — in your entry file, or when the checkout screen mounts.

import HyperPay from 'react-native-hyperpay-sdk';

HyperPay.init({
  shopperResultURL: 'com.yourapp.payments://result', // deep link back into your app
  mode: 'TestMode',                    // 'TestMode' | 'LiveMode'
  // Apple Pay (iOS only)
  countryCode: 'SA',                   // ISO 3166-1 alpha-2
  merchantIdentifier: 'merchant.com.yourapp',
  companyName: 'Your Store',           // shown as "Pay Your Store"
  supportedNetworks: ['Visa', 'MasterCard', 'mada'],
  currencyCode: 'SAR',                 // ISO 4217
});

Config options

OptionTypeDescription
shopperResultURLrequiredstringWhere the shopper returns after an async or 3-D Secure flow. Must match a scheme your app registers — see Return URL.
mode'TestMode' | 'LiveMode'Payment environment. Defaults to 'TestMode'.
countryCodeApple PayCountryCodesMerchant country, e.g. 'SA', 'AE', 'EG'.
merchantIdentifierApple PaystringMerchant ID from your Apple Developer account.
companyNameiOSstringName in the Apple Pay sheet, after “Pay”.
supportedNetworksiOSSupportedNetworks[]Networks Apple Pay accepts — see networks.
currencyCodeiOSstringISO 4217 currency for the Apple Pay sheet.
Getting started

Quick start#

A complete checkout screen: get a checkout from your server, pay by card, then confirm and map the result.

import React from 'react';
import { ActivityIndicator, Alert, Button, View } from 'react-native';
import HyperPay, { useTransactionLoading } from 'react-native-hyperpay-sdk';

HyperPay.init({ shopperResultURL: 'com.yourapp.payments://result', mode: 'TestMode' });

const API = 'https://api.yourapp.com';

export function CheckoutScreen() {
  const isLoading = useTransactionLoading();

  const pay = async () => {
    try {
      // 1. Your server creates the checkout
      const { checkoutID } = await fetch(`${API}/checkouts`, { method: 'POST' }).then(r => r.json());

      // 2. Charge the card through the native SDK
      await HyperPay.createPaymentTransaction({
        paymentBrand: 'VISA',
        holderName: 'Sara Ahmed',
        cardNumber: '4200000000000000', // test card
        expiryMonth: '12',
        expiryYear: '2030',
        cvv: '123',
        checkoutID,
      });

      // 3. Your server asks HyperPay for the final result
      const result = await fetch(`${API}/checkouts/${checkoutID}/status`).then(r => r.json());
      const { status, description } = HyperPay.getPaymentStatus(result.code);

      Alert.alert(status === 'successfully' ? 'Paid' : 'Payment failed', description);
    } catch (e: any) {
      Alert.alert('Payment error', e?.message ?? String(e));
    }
  };

  return (
    <View>
      {isLoading && <ActivityIndicator size="large" />}
      <Button title="Pay 100 SAR" onPress={pay} disabled={isLoading} />
    </View>
  );
}
Payments

Card payment#

Pass the card details and the checkoutID from your server. The SDK submits them straight to HyperPay and runs 3-D Secure if the issuer asks.

const response = await HyperPay.createPaymentTransaction({
  paymentBrand: 'MADA',             // any CardAccountBrands value
  holderName: 'Sara Ahmed',
  cardNumber: '4464040000000007',
  expiryMonth: '12',                // 2 digits
  expiryYear: '2030',               // 4 digits
  cvv: '123',
  checkoutID,                       // from your server
  shopperResultURL: 'com.yourapp.payments://result', // optional override
});

// {
//   status: 'successfully' | 'pending' | 'rejected' | 'risk' | 'chargeback' | 'declines',
//   checkoutId: string,
//   redirectURL: string   // non-empty when the shopper was sent to a web page
// }

Always verify on your server. The response says how the in-app step ended, not whether money moved. Check the payment status from your backend before fulfilling — see Server integration.

The promise rejects when a payment can’t start — invalid parameters, a network error, or (Android) no foreground activity — so wrap calls in try / catch.

Payments · iOS only

Apple Pay#

  1. Create a Merchant ID in your Apple Developer account and set up Apple Pay with HyperPay for it.
  2. In Xcode: Signing & Capabilities → + Capability → Apple Pay, then tick the Merchant ID.
  3. Pass merchantIdentifier, countryCode, supportedNetworks and currencyCode to init().
import { Platform } from 'react-native';

if (Platform.OS === 'ios') {
  const result = await HyperPay.applePay({
    checkoutID,
    amount: '100.00',          // shown in the Apple Pay sheet
    companyName: 'Your Store', // optional, overrides init
    currencyCode: 'SAR',       // optional, overrides init
  });

  // { resourcePath?: string }  synchronous — verify now from your server
  // { redirectURL?: string }   async — verify when the shopper returns
}

Show the same amount as the checkout your server created.

Payments

Loading state#

useTransactionLoading() returns true while a transaction is processing. It listens to the native onProgress event, so there’s no state to manage.

const isLoading = useTransactionLoading();

return <Button title="Pay" onPress={pay} disabled={isLoading} />;

Outside a component

Pass onProgress as the second argument. The listener removes itself when loading ends.

await HyperPay.createPaymentTransaction(params, (isLoading) => {
  store.setPaying(isLoading);
});

await HyperPay.applePay(params, (isLoading) => console.log('Apple Pay busy:', isLoading));
Payments

Payment status#

getPaymentStatus() maps a HyperPay result code to a description and one of five statuses. It runs locally — no network call.

HyperPay.getPaymentStatus('000.000.000');
// { code: '000.000.000', description: 'Transaction succeeded', status: 'successfully' }

HyperPay.getPaymentStatus('999.999.999');
// { code: '999.999.999', description: 'This status code is invalid', status: 'error' }
StatusMeaningWhat to do
successfullySucceeded, including “review manually” successes.Fulfil. Flag 000.400.* codes for review.
pendingWaiting on the shopper, bank or a risk check.Don’t fulfil yet; check again later.
rejectedDeclined by bank, 3-D Secure, risk or validation.Show the reason; let the shopper retry.
ChargebackChargeback-related code.Handle in your back office.
errorUnknown code.Log it; treat as failed.
Payments · Interactive

Result code lookup#

Search the same table the SDK ships — by code, part of a code, or a word in the description.

Payments

Server integration#

Two endpoints on your backend complete the flow. Shown with Node and Express — any stack works, it’s plain HTTPS.

// Keep the token on the server — never ship it in the app
const HOST = 'https://eu-test.oppwa.com';   // live: https://eu-prod.oppwa.com
const TOKEN = process.env.HYPERPAY_TOKEN;
const ENTITY = process.env.HYPERPAY_ENTITY_ID; // MADA usually has its own entity ID

// 1. Create a checkout
app.post('/checkouts', async (req, res) => {
  const body = new URLSearchParams({
    entityId: ENTITY,
    amount: '100.00',
    currency: 'SAR',
    paymentType: 'DB',            // DB = debit (capture now)
    merchantTransactionId: req.body.orderId,
  });
  const r = await fetch(`${HOST}/v1/checkouts`, {
    method: 'POST',
    headers: { Authorization: `Bearer ${TOKEN}` },
    body,
  });
  const data = await r.json();
  res.json({ checkoutID: data.id });
});

// 2. Get the payment result
app.get('/checkouts/:id/status', async (req, res) => {
  const url = `${HOST}/v1/checkouts/${req.params.id}/payment?entityId=${ENTITY}`;
  const r = await fetch(url, { headers: { Authorization: `Bearer ${TOKEN}` } });
  const data = await r.json();
  res.json(data.result); // { code: '000.100.110', description: '...' }
});

Pass result.code to HyperPay.getPaymentStatus() in the app. Full parameter list: HyperPay developer docs.

Reference

API reference#

import HyperPay, { useTransactionLoading } from 'react-native-hyperpay-sdk';
HyperPay.init(config: Config): Config

Stores the merchant configuration in the native SDK. Call once before any payment. Returns the applied config. See config options.

HyperPay.createPaymentTransaction(params, onProgress?): Promise<CreateTransactionResponseType>

Submits a card payment for a server-created checkout and runs 3-D Secure if needed.

ParamTypeDescription
paymentBrandrequiredCardAccountBrandsCard brand, e.g. 'VISA', 'MADA'.
holderNamerequiredstringName on the card.
cardNumberrequiredstringCard number, digits only.
expiryMonthrequiredstringTwo digits, e.g. '07'.
expiryYearrequiredstringFour digits, e.g. '2030'.
cvvrequiredstringSecurity code.
checkoutIDrequiredstringFrom your server’s /v1/checkouts call.
shopperResultURLstringOverrides the value from init().
onProgress(isLoading: boolean) => voidSecond argument; called as processing starts and ends.
HyperPay.applePay(params, onProgress?): Promise<ApplePayCallback>

iOS only. Presents the Apple Pay sheet and submits the token to HyperPay.

ParamTypeDescription
checkoutIDrequiredstringFrom your server.
amountstringAmount shown in the sheet, e.g. '100.00'.
companyNamestringOverrides init().
currencyCodestringOverrides init().
HyperPay.getPaymentStatus(code: string): PaymentStatus

Maps a result code to { code, description, status }. Unknown codes return status: 'error'.

useTransactionLoading(): boolean

React hook: true while a transaction is in progress, false when it completes or fails.

Reference

TypeScript types#

import type {
  Config,
  CreateTransactionParams,
  CreateTransactionResponseType,
  ApplyPayParams,
  ApplePayCallback,
  PaymentStatus,
} from 'react-native-hyperpay-sdk';

type CreateTransactionResponseType = {
  status: 'pending' | 'rejected' | 'risk' | 'chargeback' | 'declines' | 'successfully';
  checkoutId: string;
  redirectURL: string;
};

type ApplePayCallback = { redirectURL?: string; resourcePath?: string };

type PaymentStatus = {
  code: string;
  description: string;
  status: 'successfully' | 'rejected' | 'Chargeback' | 'pending' | 'error';
};
Reference

Card brands#

Values for paymentBrand. Highlighted brands are the most used in the Gulf and Egypt; your HyperPay entity must have each brand enabled.

MADA cards go with paymentBrand: 'MADA' and a checkout created with your MADA entity ID. MEEZA (Egypt) and BCMC are processed asynchronously.

Reference · iOS

Apple Pay networks#

Values for supportedNetworks, matched case-insensitively. Devices ignore networks their iOS version doesn’t support.

NetworkMin iOSRegion
Reference · Android

Android configuration#

Optional: override the SDK versions the library builds with.

ext {
    HyperPay_compileSdkVersion = 35
    HyperPay_minSdkVersion     = 24
    HyperPay_targetSdkVersion  = 35
}
Shipping

Go-live checklist#

  • Set mode: 'LiveMode' and point your server at eu-prod.oppwa.com with live credentials.
  • For iOS release builds, swap ipworks3ds_sdk.xcframework for ipworks3ds_sdk_deploy.xcframework in the podspec, as the package notes.
  • Use the right entity ID per brand on the server (e.g. a separate MADA entity).
  • Confirm every payment from your server before fulfilling an order.
  • Register the shopperResultURL scheme on both platforms and test a 3-D Secure challenge end to end.
  • Enable Apple Pay with the production Merchant ID and certificate configured in HyperPay.
  • Never log or store card numbers or CVV in your app or analytics.
Shipping

Troubleshooting#

“The package doesn't seem to be linked”

Run cd ios && pod install, rebuild the app (a Metro reload isn’t enough), and make sure you aren’t in Expo Go.

Status comes back pending

The shopper may still be on a 3-D Secure or bank page. Check redirectURL, wait for the return through shopperResultURL, then query the status from your server.

The app doesn’t reopen after 3-D Secure

The scheme isn’t registered or doesn’t match shopperResultURL exactly. Re-check Return URL on both platforms.

The Apple Pay sheet doesn’t appear

Check the Apple Pay capability and Merchant ID in Xcode, that merchantIdentifier and countryCode were passed to init(), and that the device has a card on one of your networks.

Android build errors about SDK versions

Raise your app’s compileSdkVersion to 35, or set the overrides in Android configuration.

Project

Roadmap (TODO)#

Today the SDK covers card brands and Apple Pay. HyperPay offers more payment methods than that, and several of them already exist in the bundled OPPWA SDK or in the package’s type files (VirtualAccountBrands). These are next.

Payment methods shipped
2 / 13

Wallets

MethodBrand valuePlatformRegionStatus
Card paymentsVISA, MADA, …iOS · AndroidGlobalShipped
Apple PayAPPLEPAYiOSGlobalShipped
STC PaySTC_PAYiOS · AndroidSaudi ArabiaTODO
Google PayGOOGLEPAYAndroidGlobalTODO
Samsung PaySAMSUNGPAYAndroidGlobalTODO
PayPalPAYPALiOS · AndroidGlobalTODO

Buy now, pay later

MethodBrand valuePlatformRegionStatus
TabbyTABBYiOS · AndroidGulfTODO
valUVALUiOS · AndroidEgyptTODO
KlarnaKLARNA_PAYMENTS_*iOS · AndroidEuropeTODO

Bank transfers & local methods

MethodBrand valuePlatformRegionStatus
SADADSADAD_VAiOS · AndroidSaudi ArabiaTODO
CliQCLIQiOS · AndroidJordanTODO
AlipayALIPAYiOS · AndroidChinaTODO
WeChat PayWECHAT_PAYiOS · AndroidChinaTODO

SDK features

Saved cards (tokenization)TODO

Store a card on the first payment and charge it later with a token, no card form.

Ready UI checkoutTODO

Open HyperPay’s prebuilt checkout screen listing every brand enabled on the entity.

Card brand detectionTODO

Detect VISA / MADA / MASTER from the card number as the shopper types.

Typed native errorsTODO

Reject promises with stable error codes instead of raw native messages.

Each method must also be enabled on your HyperPay entity. Need one sooner? Open an issue or send a pull request.

Shipping

Example app#

A runnable app with card and Apple Pay flows lives in example/.

git clone https://github.com/RMabroukS/react-native-hyperpay-sdk
cd react-native-hyperpay-sdk
yarn bootstrap        # dependencies + pods
yarn example android
yarn example ios
Project

Contributing & license#

Issues and pull requests are welcome on GitHub — please use conventional commits (see CONTRIBUTING.md).

Released under the MIT License. HyperPay and OPPWA are trademarks of their owners; this is a community-maintained bridge.

↑ ↓ to move↵ to open