# Transactions

Create, manage and verify your PayFlexi transactions with the guide below:

TIP

While in test mode or just fine-tuning your integrations, please only use a sandbox or test customer belonging to one of your business accounts on PayFlexi, do not use your real customer data. Learn more about testing.

# Initiate Transaction

POST 'https://api.payflexi.co/merchants/transactions'

curl -X POST 'https://api.payflexi.co/merchants/transactions' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer pf_test_sk_HhjQQI0VIUQWKqWkCW6hTC7qJa3qsPPvjiozL5wp' \
-d '{
	"amount": 500,
    "currency": "USD"
	"name": "Adebisi Kalu",
	"email": "adebisi@payflex.test",
	"domain": "global",
    "plans_enabled": true,
    "end_date": "2021-06-20",
    "gateway": "paystack",
    "meta": {
        "title": "Invoice #590",
        "description": "Payment for Invoice #590"
    }
}'
Success Response - 200 OK
{
    "errors": false,
    "message": "Transaction initiated",
    "reference": "7f12d42e125f2b0",
    "checkout_url": "https://checkout.payflexi.co/7f12d42e125f2b0"
}

Redirect customer to the URL returned as checkout_url to complete transaction.

Failure Response - 401 Unauthorized
{
    "message": "Unauthenticated."
}
Failure Response - 422 Unprocessable Entity
{
    "message": "The given data was invalid.",
    "errors": {
        "domain": [
            "The selected domain is invalid."
        ]
    }
}

# Request Params

'*' indicates required parameters.

Option Description
amount* (integer/float) The total amount (in highest denomination) you want to charge the buyer
currency* (string) The currency in which to charge the amount above
email (string) Your customer's email
name (string) Your customer's name or some identifier
reference (string) An optional reference or some identifier for this order. We would assign your transaction an automatic reference if this is not passed
meta (object) Use this to pass through any optional custom data you want associated with this order or transaction
domain* (string) Oone of 'global', 'financing' to indicate the type of transaction/checkout you are initiating. Note: only 'global' is accepted at this time
gateway* (string) The payment gateway through which you want payment processed. It can only be one of stripe and paystack at this time
end_date (string) An optional future date by which you want payments to have been completed when plans are enabled. Pass a valid date in the format YYYY-MM-DD.
plans_enabled (boolean) An optional flag to disable payment plans on the checkout. Default is true, only one-off payments are made available when set to false
callback_url (string) An optional URL you want us to redirect your customer to after payment is completed

# Initiate Transaction (Buy Now, Pay Later)

POST 'https://api.payflexi.co/merchants/financing-requests/initiate'

curl -X POST 'https://api.payflexi.co/merchants/financing-requests/initiate' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer pf_test_sk_HhjQQI0VIUQWKqWkCW6hTC7qJa3qsPPvjiozL5wp' \
-d '{
	"amount": 500,
    "currency": "NGN",
    "reference": "some-unique-id",
	"name": "Adebisi Kalu",
	"email": "adebisi@payflex.test",
	"item_url": "https://domain.com/clarks-shoes",
    "description": "The best pair of shoes on the internet today",
    "title": "Clarks Shoes",
    "callback_url": "https://domain.com/all/done/here",
    "meta": {
        "title": "Invoice #590",
        "description": "Payment for Invoice #590",
        "anything": "Fits here"
    }
}'
Success Response - 200 OK
{
    "errors": false,
    "message": "Checkout financing request initiated",
    "mode": "test",
    "checkout_url": "https://checkout.payflexi.co/bnpl/ousaaxwrkx"
}

Redirect customer to the URL returned as checkout_url to complete transaction.

Failure Response - 401 Unauthorized
{
    "message": "Unauthenticated."
}
Failure Response - 422 Unprocessable Entity
{
    "message": "The given data was invalid.",
    "errors": {
        "item_url": [
            "The selected item_url is invalid."
        ]
    }
}

# Request Params

'*' indicates required parameters.

Option Description
amount* (integer/float) The total amount (in highest denomination) you want to charge the buyer
currency* (string) The currency in which to charge the amount above
email (string) Your customer's email
name (string) Your customer's name or some identifier
reference (string) An optional reference or some identifier for this order. We would assign your transaction an automatic reference if this is not passed
meta (object) Use this to pass through any optional custom data you want associated with this order or transaction
item_url* (string) An optional URL representing where the order item can be found on your store
title* (string) A very short caption describing the order
description (string) An optional but more lengthy descriptive texts for the order — this could be used to save notes, etc on the order on your system.
callback_url (string) An optional URL you want us to redirect your customer to after payment is completed