fbpx

Integration Without Redirection

Integration Steps

Integration Without Redirection

11/03/2022 2022-03-22 23:10

Step 1 - Initiate payment

In this step we will initiate a payment.

  • Sandbox URL : https://sandbox.paymee.tn/api/v1/payments/create
  • Live URL : https://app.paymee.tn/api/v1/payments/create
  • Request method : POST

Header

Input

  • vendor: Website’s Paymee account number. (integer)
  • amount: Payment amount. (float)
  • note: Note about the payment (string)
				
					{
   "vendor": 5020,
   "amount": 120.5,
   "note" : "Order #1000132"
}
				
			

Output

The token is the identifier of the payment. We will use it in the next step.

				
					{
    "status": True,
    "code": 50,
    "message": "Success",
    "data": {
        "token": "5d41404b2a76b9719c592e6f84b68d92",
        "amount": 120.5
    }
}
				
			

Step 2 - Load gateway in an iframe

In this step we will load the Paymee gateway in an iframe. The iframe’s src contains the token as shown below :

En Sandbox, les paiements sont effectués avec un compte Paymee pour faciliter les tests.
Le paiement par carte bancaire sera activé en Production.

Once the payment process is done the iframe will create a javascript event paymee.complete.
Add the following JavaScript to detect the event. The Callback URL is the page that will execute the Step 3.

				
					window.addEventListener('message', function(event) {
    if(event.data.event_id === 'paymee.complete') {
        //Execute Step 3
        window.location.replace("Callback URL");
        }
}, false);   
				
			

Step 3 - Check payment

In this step we will check if the payment was really done.

Header

Input

  • token: The token received in Step 1

Output

If the buyer uses the wallet to pay, the buyer_id will be filled. Otherwise buyer_id is 0.

				
					{
    "status": true,
    "message": "Success",
    "code": 50,
    "data": {
        "payment_status": true,
        "token": "5d41404b2a76b9719c592e6f84b68d92",
        "amount": 3.0,
        "transaction_id": 126627,
        "buyer_id": 10253
    }
}