Inline Method
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": "07063703099",
"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 responseCode that isn't 000
that means the transaction was not successful.
Parameter
Parameter | Required | Description |
---|---|---|
publicKey | true | Your merchant public key, see how to get your API Keys |
transactionId | true | Unique transaction reference provided by you. |
amount | true | Amount to debit. |
currency | false | currency to charge in. Defaults to NGN |
country | false | route country. Defaults to NG |
true | Email of the customer. | |
phoneNumber | true | phone number of the customer. |
firstName | false | firstname of the customer. |
lastName | false | lastname of the customer. |
callbackurl | true | URL to redirect to when transaction is completed. |
logoURL | false | Link to the Logo image. Default to Xpresspay logo |
hash | true | This 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"}] | false | Any 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>
Updated almost 5 years ago