gopay-node-new
v0.0.6
Published
library for gopay
Downloads
2
Readme
Please visit https://doc.gopay.com/en/ for more informations. Installation You can install via npm
npm install gopay-node-new
Basic usage const gopay = require('gopay-node-new'); Initialization is done through class GoPay. This class accepts three parameters. First your Client ID as string, second Client secret as string and third is optional boolean value for sandbox (true) or live (false) mode (default is true).
const gp = new gopay.GoPay("ClientID", "ClientSecret", true); After initialization you can use all methods listed below. Every method accepts and returns data according to official GoPay documentation.
Example const gopay = require('gopay-node-new');
const gp = new gopay.GoPay("ClientID", "ClientSecret", true); const data = { "target": { "type":"ACCOUNT", "goid":"8123456789" }, "amount":"10000", "currency":"CZK", "order_number":"001", "items": [{ "type":"ITEM", "name":"obuv", "product_url":"https://www.eshop.cz/boty/lodicky", "ean":1234567890123, "amount":10000, "count":1, "vat_rate":21 }], "callback":{ "return_url":"http://www.eshop.cz/return", "notification_url":"http://www.eshop.cz/notify" }, }
gp.createPayment(data).then(payment => { console.log(payment) }) Get token Function getToken() accepts one optional string parameter called scope. Default value is "payment-all". You can find all accepting values in docs: scope. Function returns token as string.
gp.getToken().then(token => { console.log(token) } Create payment Function createPayment(JSON_DATA) accepts one required json parameter. You can find all informations about required json in docs: payment. Function returns json described in docs: payment
gp.createPayment(JSON_DATA).then(payment => { console.log(payment) } Payment status Function getStatus(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: payment status
gp.getStatus(PAYMENT_ID).then(status => { console.log(status) } Void authorization Function voidAuthorization(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: void auth
gp.voidAuthorization(PAYMENT_ID).then(info => { console.log(info) } Capture authorization Function captureAuthorization(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: capture auth
gp.captureAuthorization(PAYMENT_ID).then(info => { console.log(info) } Partial authorization Function partialAuthorization(PAYMENT_ID, JSON_DATA) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is json described in docs: json. Function returns json described in docs: partian auth
gp.partialAuthorization(PAYMENT_ID, JSON_DATA).then(info => { console.log(info) } Create recurrence Function createRecurrence(PAYMENT_ID, JSON_DATA) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is json described in docs: json. Function returns json described in docs: recurring on demand
gp.createRecurrence(PAYMENT_ID, JSON_DATA).then(info => { console.log(info) } Void recurrence Function voidRecurrence(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs:void recurrence
gp.voidRecurrence(PAYMENT_ID).then(info => { console.log(info) } Refund payment Function refundPayment(PAYMENT_ID, AMOUNT) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is number, number represents amount in cents (long > 0) more in docs: refund. Function returns json described in docs:refund
gp.refundPayment(PAYMENT_ID, AMOUNT).then(info => { console.log(info) }