KNet

Knet Embedded Payment Details

Checkout Session

Before Showing the Payment Option for Knet on the platform, you have to call the intiate_order_session API endpoint to generate a Checkout Session.

This session ID will be used for the creation relevant invoice on Sadad.

API endpoint

You can start the checkout session by calling the intiate_order_session endpoint.

Request

{
    "ref_Number": "xxx",
    "amount": "xxx",
    "currency_Code": "xxx",
    "customer_Name": "xxx",
    "customer_Mobile": "xxxx",
    "customer_Email": "xxxxx",
    "PaymentGatewayCode": "Knet"   
}
{
    "ref_Number": "xxx",
    "amount": "xxx",
    "currency_Code": "xxx",
    "customer_Name": "xxx",
    "customer_Mobile": "xxxx",
    "customer_Email": "xxxxx",
    "PaymentGatewayCode": "Knet",
    "Items": [
      {
        "name":"xxx",
        "quantity":xx,
        "amount":xx
      },
      {
        "name":"xxx",
        "quantity":xx,
        "amount":xx
      } 
    ]
}
{
    "ref_Number": "xxx",
    "amount": "xxx",
    "currency_Code": "xxx",
    "customer_Name": "xxx",
    "customer_Mobile": "xxxx",
    "customer_Email": "xxxxx",
    "PaymentGatewayCode": "Knet",
    "Items": [
     {
       "name":"xxx",
       "quantity":xx,
       "amount":xx,
       "supplierId": xx
     },
      {
        "name":"xxx",
        "quantity":xx,
        "amount":xx,
        "supplierId": xx
      } 
    ]
}

Response

{  
    "isValid": true,  
    "errorKey": null,  
    "response": {  
        "session_Id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  
    }  
}
{
  "isValid": false,
  "errorKey": "ERROR",
  "response": null
}

Usage

In order to show the Knet Option, you should use the returned session_Id instead of the value "CHECKOUT SESSION ID" in the below example


<html>
    <head>
        <title>Knet</title>
    </head>
    <body>
        <p>Pay using:</p>
        <div id="sadad-knet-element"></div>

        <script src="https://sadadpay.net/embedded/knet/knet-process.min.js"></script>
        <script>
            var session_id = "CHECKOUT SESSION ID";
            var options = {
                "buttonVisible": true, //knet button visible ture/false
                "buttonWidth": "80px", //knet button width
                "successURL": "https://your_return_url_after_successful_payment?mode=success",
                "failedURL": "https://your_return_url_after_failed_payment?mode=failed",
            }
            Sadad.Configure(session_id, options, false); //true for sandbox environment
            //Sadad.ProcessSession(); //uncommenting this line will process payment instantly without showing kent button

            //next function is callback on payment error
            var SadadOnError = function (error) {
                console.log(error);
            }
        </script>
    </body>
</html>

Callback

❗️

IMPORTANT

You need to verify the payment information by calling the API to get Invoice payment to confirm that the information is correct and valid before proceeding with your action.

  1. When the Sadad invoice gets paid, Sadad will redirect you back to the return URL with the invoice ID.
  2. Use the Invoice ID to request Invoice details
  3. Sadad is not responsible for proceeding without validating and verifying the payment status of the Sadad invoice.