0.0.3 • Published 6 years ago
g2apay v0.0.3
Integration for G2A Pay in NodeJS
Installation
npm install g2apay
Usage See G2A Pay's documentation which describes, which parameters are required or available.
const g2aconfig = {
"hash": "G2A Shop Hash", // find these infos on G2A Merchant Dashboard
"email": "G2A Shop Email",
"secret": "G2A Shop Secret",
"test": true, // true = sandbox, false = production
"url_ok": "OK URL", // fill in an URL where it redirects on success
"url_failure": "Fail URL" // fill in an URL where it redirects on failure
}
const g2a = require("../index")(g2aconfig);
// Create an cart for G2A
g2a.createCheckout("userOrderId", amount, curreny, [
{
"sku": "1337",
"name": "Testproduct",
"amount": "15",
"qty": "1",
"price":15,
"id":"5619",
"url":"http://example.com/products/item/example-item-name-5619"
},
], (response) => {
// do something with it
console.log(response);
});
// Get Details on a payment
g2a.getPayment(transactionId, (response) => {
// do something with response
console.log(response)
});
// Refund a payment, not yet tested
g2a.refundPayment(transactionId, userOrderId, paymentAmount, refundAmount,"1", (response) => {
// do something with response
console.log(response)
});
if(g2a.checkIPN(transactionId, userOrderId, amount, hash)) {
// hash is valid
}