Web SDK
Javascript SDK for NeoX Payment Gateway
Tutorial & Code sample: NeoX SDK(javascript)
Use
<!-- example-payment.html -->
<!DOCTYPE html>
<html lang="vi-VN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>NEOPAY SDK Example</title>
</head>
<body>
<button onclick="onPayWithPopup()">Thanh toán (Popup)</button>
<br />
<br />
<button onclick="onPayWithRedirect()">Thanh toán (Redirect)</button>
</body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script
neopay-sdk
type="text/javascript"
src="https://cdn.jsdelivr.net/gh/neopayvn/neopay-pg-js-sdk/sdk/neopay-sdk.min.js"
></script>
<script>
const MERCHANT_CODE = "RZRGNY";
const HASH_KEY = "4F99C21FE8A14FD198FA00D18662A63B";
$(document).ready(function () {
const neo_PaymmentBaseUrl = "https://sandbox-api.neopay.vn/pg";
const configUI = {
neo_HiddenHeader: false,
neo_HiddenFooter: true,
neo_HiddenPaymentMethod: false,
neo_HiddenOrderInfo: false,
};
const callbacks = {
onSuccess: (data) => {
console.log("success", data);
},
onFailure: (data) => {
console.log("failure:", data);
},
onClose: (data) => {
console.log(data);
},
};
neopaySDK.init(neo_PaymmentBaseUrl, configUI, callbacks);
});
function onPayWithPopup() {
const config = {
neo_MerchantCode: MERCHANT_CODE,
neo_PaymentMethod: ["WALLET", "ATM", "CC", "QR"],
neo_Currency: "VND",
neo_Locale: "vi",
neo_Version: "1",
neo_Command: "PAY",
neo_Amount: Math.floor(Math.random() * 600000) + 100000,
neo_MerchantTxnID: `T${`${Date.now()}`.slice(-8)}`,
neo_OrderID: `DH${`${Date.now()}`.slice(-8)}`,
neo_OrderInfo: `Thanh toán ĐH Test`,
neo_Title: "Thanh toán",
neo_ReturnURL: "https://sandbox-api.neopay.vn/pg/paygate/tryitnow",
neo_ViewType: "POPUP", //POPUP | REDIRECT
};
neopaySDK.pay(config, HASH_KEY);
}
function onPayWithRedirect() {
const config = {
neo_MerchantCode: MERCHANT_CODE,
neo_PaymentMethod: ["WALLET", "ATM", "CC", "QR"],
neo_Currency: "VND",
neo_Locale: "vi",
neo_Version: "1",
neo_Command: "PAY",
neo_Amount: Math.floor(Math.random() * 600000) + 100000,
neo_MerchantTxnID: `T${`${Date.now()}`.slice(-8)}`,
neo_OrderID: `DH${`${Date.now()}`.slice(-8)}`,
neo_OrderInfo: `Thanh toán ĐH Test`,
neo_Title: "Thanh toán",
neo_ReturnURL: "https://sandbox-api.neopay.vn/pg/paygate/tryitnow",
neo_ViewType: "REDIRECT", //POPUP | REDIRECT
};
neopaySDK.pay(config, HASH_KEY);
}
</script>
</html>
<!DOCTYPE html>
<html lang="vi-VN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>NEOPAY SDK Example Checkout</title>
</head>
<body>
<span id="neopay-checkout">Checkout</span>
</body>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script
neopay-sdk
type="text/javascript"
src="https://cdn.jsdelivr.net/gh/neopayvn/neopay-pg-js-sdk/sdk/neopay-sdk.min.js"
></script>
<script>
$(document).ready(function () {
const neo_PaymmentBaseUrl = "https://sandbox-api.neopay.vn/pg";
const configUI = {
neo_HiddenHeader: false,
neo_HiddenFooter: true,
};
const callbacks = {
onSuccess: (data) => {
console.log("success", data);
},
onFailure: (data) => {
console.log("failure:", data);
},
onClose: (data) => {
console.log(data);
},
};
neopaySDK.init(neo_PaymmentBaseUrl, configUI, callbacks);
});
</script>
</html>
Methods
neopaySDK.init (neo_PaymmentBaseUrl, configUI, callbacks)
neo_PaymmentBaseUrl
Sandbox environment testing URL: https://sandbox-api.neopay.vn/pg
configUI
neopaySDK.pay (config, hashKey)
neopaySDK.pay (config, hashKey)
Request sample
{
neo_MerchantCode: "RZRGNY",
neo_PaymentMethod: ["WALLET", "ATM", "CC", "QR"],
neo_Currency: "VND",
neo_Locale: "vi",
neo_Version: "1",
neo_Command: "PAY",
neo_Amount: Math.floor(Math.random() * 600000) + 100000,
neo_MerchantTxnID: `T${`${Date.now()}`.slice(-8)}`,
neo_OrderID: `DH${`${Date.now()}`.slice(-8)}`,
neo_OrderInfo: `Payment for Test Order`,
neo_Title: "Payment",
neo_ReturnURL: "https://sandbox-api.neopay.vn/pg/paygate/tryitnow",
neo_ViewType: "POPUP",
}
callback
Callback data from onSuccess and onFailure
Response sample
{
"neo_Amount": "112214",
"neo_Command": "PAY",
"neo_Currency": "VND",
"neo_Locale": "vi",
"neo_MerchantCode": "RZRGNY",
"neo_MerchantTxnID": "T23343243",
"neo_OrderID": "DH28900084",
"neo_OrderInfo": "Thanh toán ĐH Test",
"neo_ResponseCode": "0",
"neo_ResponseData": "",
"neo_ResponseMsg": "Success",
"neo_SecureHash": "80A669689BEE56D02211F8C762D828194C5B3AD121420433D280696B952F3A19",
"neo_TransactionID": "5226",
"neo_Version": "1"
}
Last updated