Inline Method

This pages shows how to implement Inline JS

Sample

You can embed xpresspay on your page using the xpressPayonlineSetup function. The function returns a response inside the callback, and you can pick your transactionId and send to your server to perform a verification before giving value for the transaction.

<form>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.js"></script>
    <script src="https://xpresspayonlinepluginssandbox.xpresspayments.com/js/plugin.js"></script>
      <input id="email" type="email" name="email" />
    <button type="button" onClick="xpressPayonlineSetup()">Pay Now</button>
</form>  
<script>
      const publicKey = "<ADD YOUR PUBLIC KEY HERE>";

         const transactionId = Math.random() + 877298;
             function submitData() {
                 var email = document.getElementById("email").value;
                 const body = {
                                 "publicKey": publicKey,
                                 "logoURL": "https://api.elasticemail.com/userfile/5d028e25-bd86-4559-b7c2-31e5870bbbf9/accessnew.jpg",
                                 "transactionId": transactionId,
                                 "amount": 100,
                                 "currency": "NGN",
                                 "country": "NG",
                                 "email": "[email protected]",
                                 "phoneNumber": "07063762229",
                                 "firstName": "Aminu",
                                 "lastName": "Cincin",
                                 "hash": "",
                                 "meta": [{
                               "metaName": "DSTV NUMBER",
                                "metaValue": "075632148963"
                            }],
                              "callbackUrl":"https://www.sample.xpresspayments.com/resp"
                             } 
                 xpressPayonlineSetup(body);
             }
       </script>

When the user enters their card details, xpresspay would do the following:

  • validate the card
  • Debit it
  • And redirect back to the callback url.

The paymentResponseCode has two important common response codes 000 and 08 the former means the transaction came back with a successful response, the latter means the transaction is pending validation. If after performing verification on your server and you get a paymentResponseCode that isn't 000 that means the transaction was not successful.

Parameter

ParameterRequiredDescription
publicKeytrueYour merchant public key, see how to get your API Keys
transactionIdtrueUnique transaction reference provided by you.
amounttrueAmount to debit.
currencyfalsecurrency to charge in. Defaults to NGN
countryfalseroute country. Defaults to NG
emailtrueEmail of the customer.
phoneNumbertruephone number of the customer.
firstNamefalsefirstname of the customer.
lastNamefalselastname of the customer.
callbackurltrueURL to redirect to when transaction is completed.
logoURLfalseLink to the Logo image. Default to Xpresspay logo
hashtrueThis is a sha256 hash of your xpressPayonlineSetup values, it is used for passing secured values to the payment gateway. Check Securing your Payments
meta:
[{"metaName": "DSTV NUMBER", "metaValue":"075632148963"}]
falseAny other custom data you wish to pass.

Completing a successful Xpresspay test

Xpresspay uses two environments one for test and one for live. On test environment the keys and script url are different from the keys and script url on live. To get your test keys sign up check API Keys and retrieve your Test API key. When you use keys from the live environment with script url's from the test environment you get an Invalid public key error.

🚧

Replace the src for the script tag when pointing live to https://plugins.xpresspayonline.com/js/plugin.js

Replace when pointing to live from
<script src="https://xpresspayonlinepluginssandbox.xpresspayments.com/js/plugin.js"></script>
to
<script type="text/javascript" src="https://plugins.xpresspayonline.com/js/plugin.js"></script>


What’s Next

Congrats! You now have our inline on your site to accept payment securely from your customers, to see how to check the status of your payment click on the button below.