---
title: "Payflex Connector"
source_url: https://docs.rapyd.net/en/payflex-connector.html
lang: en
---

# Payflex Connector

### Connector overview

- **Connector name:** Payflex
- **Payment method type:** `za_payflex_ewallet` (Payflex Buy Now, Pay Later (BNPL) for South Africa. Category ewallet, flow type ewallet. The shopper is redirected to Payflex, picks an installment plan and completes the payment there. Refundable: yes. Cancelable: no. Expirable: yes (max 3600 seconds).)
- **Gateway name:** payflex (gateway name 'Payflex', gc_type 'payflex', runs in the payments connector service)
- **Supported countries and currencies:** South Africa (ZA), ZAR
- Minimum amount is ZAR 10.00. No maximum is set in Rapyd; Payflex decides the limit per shopper based on credit history.
- Payments expire after 3600 seconds (60 minutes) of inactivity (payment_method_type_maximum_expiration_seconds = 3600).
- Payflex checkout page is hosted by Payflex (redirect). The merchant receives a redirect_url and sends the shopper there.
- The final payment status arrives asynchronously: Payflex calls a Rapyd webhook, and the connector re-reads the order from Payflex (GET order) before updating the payment. The webhook payload status itself is never trusted.
- Refunds are synchronous: the connector creates the refund at Payflex and immediately looks it up, so the refund status is final in the API response.
- Sub-merchant support: Rapyd sends aggregateMerchantId to Payflex on every create-order call. The value comes from the gateway submid configuration (sub_merchant_id, fallback rapyd_sub_merchant_id). It is not a merchant API field. Payflex never echoes it back in responses.
- Rapyd uses one set of Payflex OAuth2 client credentials per environment (central configuration). Individual merchants are identified to Payflex through aggregateMerchantId.
- In the Sandbox environment the PMT is linked to the Rapyd simulator gateway (rapyd_gw), not to Payflex UAT. Sandbox tests do not reach Payflex.

### Capabilities

| API request | Endpoint | Unique capabilities | Limitations |
| --- | --- | --- | --- |
| Create payment | `POST /v1/payments` | Redirect BNPL flow. Response has status ACT and a Payflex redirect_url. Payment becomes CLO when Payflex reports Approved (via webhook + order lookup). No payment_method.fields are needed. Customer name, email and phone are mandatory and are passed to Payflex for its credit and OTP checks. aggregateMerchantId (sub-merchant) is added automatically from submid configuration. | ZAR only, with a minimum of ZAR 10.00; payments cannot be canceled through the API. |
| Create refund | `POST /v1/refunds` | Full and partial refunds. Synchronous: the connector creates the refund at Payflex and then looks it up; the refund is Completed only when Payflex returns status 'Completed'. Payflex error codes (for example MRM007 Refund not allowed) are passed back as the refund failure code and reason. | Completed payments only; total refunds cannot exceed the order amount. |

- **Header parameters:** Standard Rapyd [headers](https://docs.rapyd.net/en/header-parameters.md "Header Parameters"). No connector-specific headers.
- **Supported workflows**

  - Redirect ewallet (BNPL) payment: create payment, redirect the shopper to redirect_url, receive the final status by Rapyd webhook.
  - Refund (full or partial) of a completed payment with `POST /v1/refunds`.
  - Retrieve payment (`GET /v1/payments/{payment}`) returns the status Rapyd has stored. The connector does not call Payflex for this (no gateway retrieve/polling).
  - Unique workflow - asynchronous status by Payflex webhook: Payflex posts to the Rapyd callback URL; the connector re-fetches the order (GET order) and maps Approved -> CLO, Declined/Abandoned -> ERR, Created/Initiated -> stays ACT. A payment already CLO is not changed again.

### Field mapping tables

### Create Payment - Body parameters

> **Note:**
>
> This table has many columns. Use the horizontal scroll bar below the table to move across and view all of the columns.

| Field name | Parent field | Data type | Required or optional | Default value | Accepted values (enum) | Constraints | Description | Example | Provided by |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `amount` | - | number | Required | - | Decimal, 2 places | Minimum 10.00 ZAR. No Rapyd maximum (Payflex decides per shopper). | Payment amount in ZAR. | 250.00 | Merchant |
| `currency` | - | string | Required | - | **ZAR** | ISO 4217 | Payment currency. | ZAR | Merchant |
| `payment_method` | - | object | Required | - | - | - | Payment method object. | {"type": "`za_payflex_ewallet`", "fields": {}} | Merchant |
| `type` | `payment_method` | string | Required | - | **`za_payflex_ewallet`** | - | Payment method type. | `za_payflex_ewallet` | Merchant |
| `fields` | `payment_method` | object | Optional | {} | Empty object | No fields are defined for this PMT (required_fields = []). | Payment-method-specific fields. None for Payflex. | {} | Merchant |
| `customer` | - | object | Required | - | - | Must contain name, email and phone_number. | Shopper details used by Payflex for identity, credit and OTP checks. | {"name": "Thabo Nkosi", "email": "thabo@example.com", "phone_number": "27821234567"} | Merchant |
| `name` | `customer` | string | Required | - | Letters and spaces | Regex ^[a-zA-ZÀ-ÿ ]{1,100}$ | Shopper full name. | Thabo Nkosi | Merchant |
| `email` | `customer` | string | Required | - | - | Regex (?=.{4,100}$)[a-zA-Z0-9À-ÿ._%+-]+@[a-zA-Z0-9À-ÿ.-]+[.][a-zA-ZÀ-ÿ]{2,}$ | Shopper email. | thabo@example.com | Merchant |
| `phone_number` | `customer` | string | Required | - | Digits only | Production and Sandbox regex ^[0-9]{1,15}$ (no plus sign). | Shopper mobile number. Payflex uses it for OTP. | 27821234567 | Merchant |
| `complete_payment_url` | - | string | Required | - | URL | HTTPS required in production. No localhost. | Where the shopper returns after approving the Payflex payment. | https://merchant.example/return | Merchant |
| `error_payment_url` | - | string | Required | - | URL | HTTPS required in production. No localhost. | Where the shopper returns if they cancel or are declined. | https://merchant.example/cancel | Merchant |
| `merchant_reference_id` | - | string | Optional | - | - | - | Merchant's own order reference. | MERCH-REF-0001 | Merchant |
| `description` | - | string | Optional | - | - | - | Payment description. | Order 1234 | Merchant |
| `expiration` | - | number | Optional | Now + 3600 seconds | Unix timestamp (seconds) | PMT maximum expiration is 3600 seconds. | When the payment expires if the shopper does not complete it. | 1780398761 | Merchant |
| `metadata` | - | object | Optional | - | - | - | Merchant-defined key/value data. | {"order": "1234"} | Merchant |

### Create Payment - Response parameters

> **Note:**
>
> This table has many columns. Use the horizontal scroll bar below the table to move across and view all of the columns.

| Field name | Parent field | Data type | Values (enum) | Description | Example | Provided by |
| --- | --- | --- | --- | --- | --- | --- |
| `id` | `data` | string | **payment_...** | Rapyd payment ID. Also sent to Payflex as merchantReference and used for reconciliation. | payment_77465d3aeaa6eb6dedf34d4552a76fdd | Rapyd |
| `status` | `data` | string | **ACT**, **CLO**, **ERR**, **EXP** | Payment status. ACT on creation; CLO when Payflex approves; ERR when Payflex declines, the shopper abandons, or order creation fails; EXP after 60 minutes. | ACT | Rapyd |
| `redirect_url` | `data` | string | URL | Payflex checkout page. Send the shopper here. | https://checkout.payflex.co.za/embedded/v2?orderId=22ba200f-8d69-496a-97ec-d0a1a0dd038c | Gateway |
| `amount` | `data` | number | - | Amount paid. 0 while ACT; equals original_amount once CLO. | 0 | Rapyd |
| `original_amount` | `data` | number | - | Requested amount. | 250 | Carried over |
| `currency_code` | `data` | string | **ZAR** | Currency. | ZAR | Carried over |
| `country_code` | `data` | string | **ZA** | Country of the payment method. | ZA | Rapyd |
| `merchant_reference_id` | `data` | string | - | Echo of the merchant reference. | MERCH-REF-0001 | Carried over |
| `payment_method_type` | `data` | string | **`za_payflex_ewallet`** | Payment method type. | `za_payflex_ewallet` | Rapyd |
| `payment_method_type_category` | `data` | string | **ewallet** | PMT category. | ewallet | Rapyd |
| `next_action` | `data` | string | **pending_confirmation**, **not_applicable** | What the merchant should do next. pending_confirmation means redirect the shopper. | pending_confirmation | Rapyd |
| `instructions` | `data` | array | - | Shopper instructions from the PMT configuration. | [{"name": "instructions", "steps": [{"step1": "You will be redirected to the Payflex login page to complete your payment.", "step2": "Once in the Payflex environment, select your preferred payment plan and complete your payment."}]}] | Rapyd |
| `complete_payment_url` | `data` | string | - | Echo. | https://merchant.example/return | Carried over |
| `error_payment_url` | `data` | string | - | Echo. | https://merchant.example/cancel | Carried over |
| `expiration` | `data` | number | - | Expiry time (Unix seconds). | 1780398761 | Rapyd |
| `paid` | `data` | boolean | **true**, **false** | true once the payment is CLO. | false | Rapyd |
| `failure_code` | `data` | string | Payflex error code, for example CRM005, VALIDATION_ERROR, UNAUTHORISED | Failure code when order creation fails at Payflex. | - | Gateway |
| `failure_message` | `data` | string | - | Failure message from Payflex. | - | Gateway |
| `textual_codes` | `data` | object | - | Not used by this connector (always empty). | {} | Rapyd |
| `customer_token` | `data` | string | **cus_...** | Rapyd customer created from the inline customer. | cus_8c94d097e831e530763f2e5b3462e568 | Rapyd |

### Create Refund - Body parameters

> **Note:**
>
> This table has many columns. Use the horizontal scroll bar below the table to move across and view all of the columns.

| Field name | Parent field | Data type | Required or optional | Default value | Accepted values (enum) | Constraints | Description | Example | Provided by |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `payment` | - | string | Required | - | **payment_...** | Payment must be CLO. | ID of the Payflex payment to refund. | payment_77465d3aeaa6eb6dedf34d4552a76fdd | Merchant |
| `amount` | - | number | Optional | Full remaining amount | **Decimal** | Cannot exceed the remaining refundable amount. | Refund amount. Partial refunds are supported. | 100.00 | Merchant |
| `currency` | - | string | Optional | Payment currency | **ZAR** | Must match the payment currency. | Refund currency. | ZAR | Merchant |
| `merchant_reference_id` | - | string | Optional | - | - | - | Merchant's own refund reference. | REFUND-0001 | Merchant |
| `reason` | - | string | Optional | - | - | - | Reason for the refund. | Customer returned item | Merchant |
| `metadata` | - | object | Optional | - | - | - | Merchant-defined data. | {} | Merchant |

### Create Refund - Response parameters

> **Note:**
>
> This table has many columns. Use the horizontal scroll bar below the table to move across and view all of the columns.

| Field name | Parent field | Data type | Values (enum) | Description | Example | Provided by |
| --- | --- | --- | --- | --- | --- | --- |
| `id` | `data` | string | **refund_...** | Rapyd refund ID. Sent to Payflex as merchantRefundReference. | refund_5a1b2c3d4e5f60718293a4b5c6d7e8f9 | Rapyd |
| `status` | `data` | string | **Completed**, **Error** | Final refund status. Completed only when the Payflex refund lookup returns 'Completed'. | Completed | Rapyd |
| `amount` | `data` | number | - | Refunded amount as returned by Payflex. | 100 | Gateway |
| `payment` | `data` | string | **payment_...** | Original payment ID. | payment_77465d3aeaa6eb6dedf34d4552a76fdd | Carried over |
| `currency` | `data` | string | **ZAR** | Refund currency. | ZAR | Carried over |
| `failure_reason` | `data` | string | - | Why the refund failed. Either the Payflex error message, or 'Refund lookup returned unexpected status: <status>'. | - | Gateway |
| `merchant_reference_id` | `data` | string | - | Echo of the merchant refund reference. | REFUND-0001 | Carried over |
| `payment_method_type` | `data` | string | **`za_payflex_ewallet`** | PMT of the refunded payment. | `za_payflex_ewallet` | Rapyd |
| `created_at` | `data` | number | - | Creation time (Unix seconds). | 1780400000 | Rapyd |

### Migrating from PayU

This section shows how PayU Africa (Magellan API) fields, values and behavior relate to the Rapyd fields in the field mapping tables.

### Migration notes

- PayU Africa equivalent: payment method code PAYFLEX (AdditionalInformation.supportedPaymentMethods = PAYFLEX). PayU Africa merchants are mapped from PAYFLEX to `za_payflex_ewallet`.
- Unique workflow - PayU Africa merchants: setTransaction with supportedPaymentMethods=PAYFLEX becomes a Rapyd hosted checkout (`POST /v1/checkout` with payment_method_types_include ['`za_payflex_ewallet`']); doTransaction PAYMENT with PAYFLEX becomes `POST /v1/payments`; doTransaction CREDIT becomes `POST /v1/refunds`. The Rapyd result is sent to the merchant's notificationUrl as a PayU-style IPN.

### Field mapping (Rapyd field to original PayU field)

### Create Payment - Body parameters

| Rapyd field name | Original PayU field |
| --- | --- |
| `amount` | `Basket.amountInCents` |
| `currency` | `Basket.currencyCode` |
| `payment_method` | `AdditionalInformation.supportedPaymentMethods` |
| `type` | `AdditionalInformation.supportedPaymentMethods` = PAYFLEX |
| `fields` | None (new in Rapyd) |
| `customer` | `Customer` |
| `name` | `Customer.firstName` + `Customer.lastName` |
| `email` | `Customer.email` |
| `phone_number` | `Customer.countryCode` + `Customer.mobile` |
| `complete_payment_url` | `AdditionalInformation.returnUrl` |
| `error_payment_url` | `AdditionalInformation.cancelUrl` |
| `merchant_reference_id` | `AdditionalInformation.merchantReference` |
| `description` | `Basket.description` |
| `expiration` | None (new in Rapyd) |
| `metadata` | None (new in Rapyd) |

### Accepted values mapping

| Field name | Original PayU value | Rapyd value |
| --- | --- | --- |
| `payment_method.type` | **PAYFLEX** | **`za_payflex_ewallet`** |
| `amount` | Basket.amountInCents = 25000 | **250.00** |

### Create Payment - Response parameters

| Rapyd field name | Original PayU field |
| --- | --- |
| `id` | `payUReference` |
| `status` | `transactionState` / `successful` / `resultCode` |
| `redirect_url` | redirect url |
| `amount` | `Basket.amountInCents` |
| `original_amount` | `Basket.amountInCents` |
| `currency_code` | `Basket.currencyCode` |
| `country_code` | - |
| `merchant_reference_id` | `merchantReference` |
| `payment_method_type` | - |
| `payment_method_type_category` | None (new in Rapyd) |
| `next_action` | None (new in Rapyd) |
| `instructions` | None (new in Rapyd) |
| `complete_payment_url` | `AdditionalInformation.returnUrl` |
| `error_payment_url` | `AdditionalInformation.cancelUrl` |
| `expiration` | None (new in Rapyd) |
| `paid` | `successful` |
| `failure_code` | `resultCode` |
| `failure_message` | `resultMessage` |
| `textual_codes` | None (new in Rapyd) |
| `customer_token` | None (new in Rapyd) |

### Accepted values mapping

| Field name | Original PayU value | Rapyd value |
| --- | --- | --- |
| `status` | successful=true, resultCode 00 (doTransaction) | **ACT** or **CLO** |
| `status` | successful=false, resultCode 05, pointOfFailure ACQUIRER | **ERR** |
| `status` | successful=false, resultCode P015, pointOfFailure PAYU | **CAN** |
| `status` | successful=false, resultCode 994, pointOfFailure PAYU | **EXP** |
| `status` | any other or missing status -> resultCode P046 | **other** |

### Create Refund - Body parameters

| Rapyd field name | Original PayU field |
| --- | --- |
| `payment` | `payUReference` |
| `amount` | Credit block amount (core field `credit.amount_in_cents`), else `Basket.amountInCents` |
| `currency` | `Basket.currencyCode` |
| `merchant_reference_id` | `AdditionalInformation.merchantReference` |
| `reason` | None (new in Rapyd) |
| `metadata` | None (new in Rapyd) |

### Accepted values mapping

| Field name | Original PayU value | Rapyd value |
| --- | --- | --- |
| `(operation)` | doTransaction TransactionType = CREDIT | **POST** /**v1**/**refunds** |

### Create Refund - Response parameters

| Rapyd field name | Original PayU field |
| --- | --- |
| `id` | `payUReference` (of the CREDIT transaction) |
| `status` | `successful` / `resultCode` |
| `amount` | Credit amount / `Basket.amountInCents` |
| `payment` | `payUReference` |
| `currency` | `Basket.currencyCode` |
| `failure_reason` | `resultMessage` |
| `merchant_reference_id` | `merchantReference` |
| `payment_method_type` | - |
| `created_at` | None (new in Rapyd) |

### Accepted values mapping

| Field name | Original PayU value | Rapyd value |
| --- | --- | --- |
| `status` | successful=true, resultCode 00 | **Completed** (or Pending) |
| `status` | successful=false, resultCode P046, pointOfFailure PAYU | Error / any other |
| `status (gateway)` | N/A - Payflex refund lookup status 'Completed' | **Completed** (CLO) |

### API samples

### Create payment (`POST /v1/payments`)

- - Request

    - ```curl
      curl -X POST 'https://sandboxapi.rapyd.net/v1/payments' \
        -H 'access_key: <your_access_key>' \
        -H 'Content-Type: application/json' \
        -H 'idempotency: <unique_idempotency_key>' \
        -H 'salt: <random_salt>' \
        -H 'signature: <calculated_signature>' \
        -H 'timestamp: <unix_timestamp>' \
        --data-raw '{
        "amount": 250.0,
        "currency": "ZAR",
        "payment_method": {
          "type": "za_payflex_ewallet",
          "fields": {}
        },
        "customer": {
          "name": "Thabo Nkosi",
          "email": "thabo@example.com",
          "phone_number": "27821234567"
        },
        "complete_payment_url": "https://merchant.example/return",
        "error_payment_url": "https://merchant.example/cancel",
        "merchant_reference_id": "MERCH-REF-0001",
        "description": "Order 1234"
      }'
      ```
- - Response

    - ```json
      {
        "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "71825e7b-b292-4415-bd08-4514d7780e06"
        },
        "data": {
          "id": "payment_77465d3aeaa6eb6dedf34d4552a76fdd",
          "amount": 0,
          "original_amount": 250,
          "is_partial": false,
          "currency_code": "ZAR",
          "country_code": "ZA",
          "status": "ACT",
          "description": "Order 1234",
          "merchant_reference_id": "MERCH-REF-0001",
          "customer_token": "cus_8c94d097e831e530763f2e5b3462e568",
          "payment_method": "other_a7a94f0a5fe13d5381a5752310fc4c98",
          "payment_method_data": {
            "id": "other_a7a94f0a5fe13d5381a5752310fc4c98",
            "type": "za_payflex_ewallet",
            "category": "ewallet",
            "metadata": {},
            "next_action": "not_applicable"
          },
          "expiration": 1780398761,
          "captured": true,
          "refunded": false,
          "refunded_amount": 0,
          "redirect_url": "https://checkout.payflex.co.za/embedded/v2?orderId=22ba200f-8d69-496a-97ec-d0a1a0dd038c",
          "complete_payment_url": "https://merchant.example/return",
          "error_payment_url": "https://merchant.example/cancel",
          "created_at": 1780395160,
          "metadata": {},
          "failure_code": "",
          "failure_message": "",
          "paid": false,
          "paid_at": 0,
          "visual_codes": {},
          "textual_codes": {},
          "instructions": [
            {
              "name": "instructions",
              "steps": [
                {
                  "step1": "You will be redirected to the Payflex login page to complete your payment.",
                  "step2": "Once in the Payflex environment, select your preferred payment plan and complete your payment."
                }
              ]
            }
          ],
          "ewallet_id": "ewallet_ba37d302e173e089078bf8cbadf68cc8",
          "payment_method_options": {},
          "payment_method_type": "za_payflex_ewallet",
          "payment_method_type_category": "ewallet",
          "initiation_type": "customer_present",
          "next_action": "pending_confirmation",
          "error_code": ""
        }
      }
      ```

### Create refund (`POST /v1/refunds`)

- - Request

    - ```curl
      curl -X POST 'https://sandboxapi.rapyd.net/v1/refunds' \
        -H 'access_key: <your_access_key>' \
        -H 'Content-Type: application/json' \
        -H 'idempotency: <unique_idempotency_key>' \
        -H 'salt: <random_salt>' \
        -H 'signature: <calculated_signature>' \
        -H 'timestamp: <unix_timestamp>' \
        --data-raw '{
        "payment": "payment_77465d3aeaa6eb6dedf34d4552a76fdd",
        "amount": 100.0,
        "currency": "ZAR",
        "merchant_reference_id": "REFUND-0001",
        "reason": "Customer returned item"
      }'
      ```
- - Response

    - ```json
      {
        "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "0c3a5d0e-5f1e-4c47-9a0b-1f2e3d4c5b6a"
        },
        "data": {
          "id": "refund_5a1b2c3d4e5f60718293a4b5c6d7e8f9",
          "amount": 100,
          "payment": "payment_77465d3aeaa6eb6dedf34d4552a76fdd",
          "currency": "ZAR",
          "failure_reason": "",
          "metadata": {},
          "reason": "Customer returned item",
          "status": "Completed",
          "receipt_number": 0,
          "created_at": 1780400000,
          "merchant_reference_id": "REFUND-0001",
          "payment_created_at": 1780395160,
          "payment_method_type": "za_payflex_ewallet",
          "ewallets": [
            {
              "ewallet": "ewallet_ba37d302e173e089078bf8cbadf68cc8",
              "amount": 100
            }
          ],
          "proportional_refund": true
        }
      }
      ```
