Pay.nl NodeJS SDK
SDK for pay.nl allowing you to manage your pay.nl transactions in nodeJS
Installation
npm install paynl-sdk --save
Usage
- Require 'paynl-sdk' in your file.
var Paynl = ;
- Register for a pay.nl account at: pay.nl/registreren
- In the pay.nl admin, navigate to Manage -> Services and click the SL-code on the left.
- From the popup use the apitoken and serviceId, and configure them in the SDK.
PaynlConfig;PaynlConfig;
Examples
Some of the basic examples are listed here, for the full list of examples, please take a look at the samples directory here
All examples start with requiring paynl-sdk and setting the apitoken and serviceId.
var Paynl = ; PaynlConfig;PaynlConfig;
Basic transactions
Getting the available payment methods
This example shows how to fetch a list of the available payment methods.
The method Paynl.Paymentmethods.getList()
returns an observable array.
For more information about observables see reactivex.io
PaynlPaymentmethods;
Starting a transaction
This example shows the minimum required attributes to start a transaction. The full version with all supported options is located here
PaynlTransactionstart //the amount in euro amount: 1995 //we redirect the user back to this url after the payment returnUrl: "https://my-return-url.com/return" //the ip address of the user ipAddress: '10.20.30.40' ;
Fetching a transaction
The following example shows how to fetch a transaction.
PaynlTransaction;
Instore payments (pin)
Fetching available terminals
Before you can send a transaction, you need to know which terminal to send the transaction to.
PaynlInstore ;
Starting an instore transaction
An instore transaction is started in the same way as a normal transaction with the addition of a terminalId. After the transaction has been started, you can use the terminalStatusUrl to get the status of the transaction.
// Start transaction and send to the terminalPaynlTransactionstart amount: 001 paymentMethodId: 1927 //returnUrl and ipAddres make no sense for instore payments, but are mandatory returnUrl: "not_applicable" ipAddress: "10.20.30.40" terminalId: "TH-0123-4567"; { PaynlInstore;}
Direct Debit (Incasso)
Creating a new Direct Debit
This SDK can also add direct debit transactions. Only amount, bankaccountHolder and bankaccountNumber are mandatory, the rest of the arguments are optional.
PaynlDirectDebit;
Fetching a Direct Debit transaction
Fetch a DirectDebit transaction to fetch the status.
PaynlDirectDebit;