Skip to content

POST Payment initialization

https://api.magmaonepay.com/v1/payment/init



Initiate Payment

This guide will help you initiate a payment to any operator that Magma OnePay API V1 supports.

Corridors

Here are the countries and their supported payment methods:

Country CodeCountry NameSupports Mobile Wallet?Supports Credit Card?Currency
BJBeninYesNoXOF
CICôte d'IvoireYesNoXOF
TGTogoYesNoXOF
SNSenegalYesNoXOF
MLMaliYesNoXOF
BFBurkina FasoYesNoXOF
CMCamerounYesNoXAF
SLSierra LeoneYesNoSLE

Available Payment Methods

Here are the available payment methods per country and their minimum and maximum transaction limits:

Country CodeCountry NamePayment methodsMin amountMax amount
BJBeninMOOV_BJ, MTN_BJ2001500000
CICôte d'IvoireMOOV_CI, MTN_CI, ORANGE_CI, WAVE_CI2001500000
TGTogoMOOV_TG, TMONEY_TG2001500000
SNSenegalEXPRESSO_SN, WAVE_SN, ORANGE_SN, FREE_SN2001500000
MLMaliORANGE_ML, MOOV_ML2001500000
BFBurkina FasoMOOV_BF, ORANGE_BF2001500000
CMCamerounMTN_CM, ORANGE_CM2001500000
SLSierra LeoneORANGE_SL2001500000

Payment Statuses

Payments may have one of the following statuses:

StatusDescription
newThe payment is newly created
successThe payment is successful
pendingThe payment is pending
failedThe payment has failed
refundedThe payment has been refunded
cancelledThe payment has been cancelled

Valid Currencies

Below are the valid currencies:

CurrencyDescription
XOFWest African Economic and Monetary Union
EUREuro

Valid Payee Phone Number

A payee's phone number should be in E.164 format. This starts with a plus sign (+), followed by the country code and then the phone number. For example, a number for Côte d'Ivoire (CIV) would look like: +2250102030405.

Valid Channel Strings

Below are the valid channel strings:

ChannelDescription
mobile_moneyPayment made through mobile money service
credit_cardPayment made using a credit card
wavePayment made through a mobile wallet application called Wave

Request Information

Here are the parameters you need to include in your request:

ParameterTypeIs MandatoryDescription
merchant_transaction_idstringYesThe merchant's unique identifier for the transaction
amountintegerYesThe amount of the payment
currencyvalid_currency_stringYesThe currency in which the payment is made
descriptionstringNoA brief description of the payment transaction
payeevalid_payee_phone_numberNoPhone number of the payee
payee_first_namestringNoFirst name of the payee
payee_last_namestringNoLast name of the payee
channelvalid_channel_stringYesThe channel used to make the payment
webhook_urlstringNoThe URL to which the payment confirmation will be sent
custom_fieldstringNoAn optional custom field for additional information

Please note that you can force the using of a payment method by adding "payment_method" with a valid one

Response Information

Here are the parameters you will receive in your response:

Response ParameterTypeDescription
codeintegerThe HTTP status code returned by the API
messagestringA message indicating the result of the API operation
dataobjectAn object containing the payment processing details
data.payment_statusstringThe current status of the payment
data.payment_tokenstringA unique identifier for the payment transaction
data.payment_methodstringThe payment method used for the transaction
data.payment_typestringThe type of payment made
data.countrystringThe country where the payment was made
data.country_prefixstringThe country code prefix for the mobile number
data.channelstringThe channel used to initiate the payment
data.metaobjectAdditional metadata related to the payment transaction
data.meta.otpbooleanIndicates whether the payment requires an OTP code
data.meta.otp_lengthintegerThe length of the OTP code required
data.meta.redirect_customer_to_url_processingbooleanndicates whether the customer should be redirected to a URL for processing
data.meta.before_payment_instructionsstringInstructions before
data.meta.after_payment_instructionsstringInstructions after

Simulating Payment Statuses : Test Phase Only

The API allows you to simulate different payment statuses during the testing phase. These pattern below trigger different payment states and responses, allowing you to verify that your system correctly handles various scenarios.

Channel "mobile_money" Testing

Here is a list of test phone numbers and their associated payment statuses:

PayeeType TransactionFinal Status
+2250707000200One Stepsuccess
+2250707000201Two Stepsuccess
+2250707000205One Stepfailed with generic error
+2250707000202Two Stepfailed with specific error
+2250707000203Two Stepfailed with specific error
+2250707000204Two Stepfailed with generic error
+2250707000206One Stepfailed with specific error
+2250707000206One Stepfailed with specific error
Any other numberTwo Stepfailed with generic error

AUTHORIZATION

Bearer Token
TokenTOKEN

HEADERS

AuthorizationBearer TOKEN

NB: TOKEN is your private secret key dependant on your mode (live or test) for server-side

Body

raw (json)
json

{
  "merchant_transaction_id": "845bf095-da3c-4516-98ed-b29c0e59df79",
  "amount": 500,
  "currency": "XOF",
  "description": "Payment description",
  "payee": "+2250707000200", //If you want to collect directly via the api, this field is required
  "payee_first_name": "Amidou",
  "payee_last_name": "Amada",
  "channel": "mobile_money",
  "webhook_url": "https://webhook.site/3533c510-719c-4f52-9c2d-be163501db09",
  "success_url": "http://my-url1.com",
  "error_url": "http://my-url1.com",
  "custom_field": "any_string"
}

Example Request

curl
curl --location 'https://api.magmaonepay.com/v1/payment/init' \
--header 'Authorization: Bearer TOKEN' \
--data '{
	"merchant_transaction_id": "string",
    "amount": "integer",
	"currency": "valid_currency_string",
    "description": "Payment description",
    "payee": "valid_payee_phone_number",
    "payee_fist_name": "payee_fist_name",
    "payee_last_name": "payee_last_name",
	"channel": "valid_channel_string",
	"webhook_url": "http://my-url.com",
    "custom_field": "any_string"
}'

Example Response ([Success] [payee is set up])

Body
json
{
    "code": 201,
    "message": "CREATED",
    "data": {
        "payment_token": "73351d2a-c2bd-4d7c-8f1a-35ddbe9bd606",
        "payment_status": "new",
        "amount": 10000,
        "currency": "XOF",
        "payment_method": "ORANGE_CI",
        "payment_url": "https://gateway-test.magmaonepay.com/pay/73351d2a-c2bd-4d7c-8f1a-35ddbe9bd606",
        "direct_pay": true,
        "channel": "mobile_money",
        "payment_type": "direct",
        "country": "CI",
        "country_prefix": "+225",
        "meta": {
            "otp": false,
            "otp_length": 0,
            "redirect_customer_to_url_processing": false,
            "before_payment_instructions": "Make sure you have enough balance.",
            "after_payment_instructions": "Check your account for the transaction details."
        }
    }
}
Headers (1)

Content-Type        application/json

Example Response ([Success] [payee is not set up])

Body
json
{
  "code": 201,
  "message": "CREATED",
  "data": {
    "payment_token": "fa0204d0-06df-460c-b54f-c496b3b0e95c",
    "payment_status": "new",
    "amount": 10000,
    "currency": "XOF",
    "payment_url": "https://gateway-test.magmaonepay.com/pay/fa0204d0-06df-460c-b54f-c496b3b0e95c",
    "direct_pay": false
  }
}
Headers (1)

Content-Type        application/json