require __DIR__ . '/vendor/autoload.php';
# Set configuration
\Paynl\Config::setApiToken('token');
\Paynl\Config::setServiceId('SL-3490-4320');
# Get available payment methods
$paymentMethods = \Paynl\Paymentmethods::getList();
# Display paymentmethods
var_dump($paymentMethods);
require __DIR__ . '/vendor/autoload.php';
# Set configuration
\Paynl\Config::setApiToken('token');
\Paynl\Config::setServiceId('SL-3490-4320');
# Start a transaction
$result = \Paynl\Transaction::start(array(
// required vars
'amount' => 10,
'returnUrl' => \Paynl\Helper::getBaseUrl().'/return.php',
// optional vars
'exchangeUrl' => \Paynl\Helper::getBaseUrl().'/exchange.php',
'paymentMethod' => 10,
'bank' => 1,
'description' => 'Demo payment',
'testmode' => 1,
'extra1' => 'ext1',
'extra2' => 'ext2',
'extra3' => 'ext3',
'products' => array(
array(
'id' => 1,
'name' => 'Your product',
'price' => 5,
'tax' => 0.87,
'qty' => 1,
),
array(
'id' => 2,
'name' => 'Other product',
'price' => 5,
'tax' => 0.87,
'qty' => 1,
)
),
'language' => 'EN',
'enduser' => array(
'initials' => 'M',
'lastName' => 'Pay',
'gender' => 'M',
'dob' => '14-05-1999',
'phoneNumber' => '0612345678',
'emailAddress' => 'customer@pay.nl',
),
'address' => array(
'streetName' => 'Test',
'houseNumber' => '10',
'zipCode' => '1234AB',
'city' => 'Test',
'country' => 'NL',
),
'invoiceAddress' => array(
'initials' => 'IT',
'lastName' => 'ITEST',
'streetName' => 'Istreet',
'houseNumber' => '70',
'zipCode' => '5678CD',
'city' => 'ITest',
'country' => 'NL',
),
));
# Save this transactionid and link it to your order
$transactionId = $result->getTransactionId();
# Redirect the customer to this url to complete the payment
$redirect = $result->getRedirectUrl();
require __DIR__ . '/vendor/autoload.php';
# Set configuration
\Paynl\Config::setApiToken('token');
$transactionId = $_GET['transactionId']
# Refund a transaction
try{
$result = \Paynl\Transaction::refund($transactionId, 5);
} catch(\Paynl\Error\Api $e){
echo $e->getMessage();
}
# Display result
var_dump($result);
require __DIR__ . '/vendor/autoload.php';
# Set configuration
\Paynl\Config::setApiToken('token');
$transaction = \Paynl\Transaction::getForReturn();
# Verify the transaction status
if( $transaction->isPaid() || $transaction->isPending()){
// redirect to thank you page
} elseif($transaction->isCanceled()) {
// redirect back to checkout
}
require __DIR__ . '/vendor/autoload.php';
# Set configuration
\Paynl\Config::setApiToken('token');
$transaction = \Paynl\Transaction::getForExchange();
# Verify the transaction status
if($transaction->isPaid()){
// process the payment
} elseif($transaction->isCanceled()){
// payment canceled, restock items
}
// required exchange response
echo "TRUE|";
The PHP SDK including examples can be downloaded from GitHub.
Download SDK
// Set configuration
PAYNLSDK.API.RequestBase.ApiToken = "token";
PAYNLSDK.API.RequestBase.ServiceId = "SL-3490-4320";
// Get available payment methods
PAYNLSDK.API.PaymentMethod.GetAll.Response response = PAYNLSDK.PaymentMethod.GetAll();
// Set configuration
PAYNLSDK.API.RequestBase.ApiToken = "token";
PAYNLSDK.API.RequestBase.ServiceId = "SL-3490-4320";
PAYNLSDK.API.Transaction.Start.Request request = PAYNLSDK.Transaction.CreateTransactionRequest("127.0.0.1", "http://example.org/visitor-return-after-payment");
request.Amount = 621;
// Optional Stats data
request.StatsData = new PAYNLSDK.Objects.StatsDetails();
request.StatsData.Info = "your information";
request.StatsData.Tool = "C#.NET";
request.StatsData.Extra1 = "X";
request.StatsData.Extra2 = "Y";
request.StatsData.Extra3 = "Z";
// Initialize Salesdata
request.SalesData = new PAYNLSDK.Objects.SalesData();
request.SalesData.InvoiceDate = DateTime.Now;
request.SalesData.DeliveryDate = DateTime.Now;
request.SalesData.OrderData = new System.Collections.Generic.List();
// Add products
request.SalesData.OrderData.Add(new PAYNLSDK.Objects.OrderData("SKU-8489", "Testproduct 1", 2995, "H", 1));
request.SalesData.OrderData.Add(new PAYNLSDK.Objects.OrderData("SKU-8421", "Testproduct 2", 995, "H", 1));
request.SalesData.OrderData.Add(new PAYNLSDK.Objects.OrderData("SKU-2359", "Testproduct 3", 2499, "H", 1));
// enduser
request.Enduser = new PAYNLSDK.Objects.EndUser();
request.Enduser.Language = "NL";
request.Enduser.Initials = "J.";
request.Enduser.Lastname = "Buyer";
request.Enduser.Gender = PAYNLSDK.Enums.Gender.Male;
request.Enduser.BirthDate = new DateTime(1991, 1, 23, 0, 0, 0, DateTimeKind.Local);
request.Enduser.PhoneNumber = "0612345678";
request.Enduser.EmailAddress = "email@domain.com";
request.Enduser.BankAccount = "";
request.Enduser.IBAN = "NL08INGB0000000555";
request.Enduser.BIC = "";
// enduser address
request.Enduser.Address = new PAYNLSDK.Objects.Address();
request.Enduser.Address.StreetName = "Streetname";
request.Enduser.Address.StreetNumber = "8";
request.Enduser.Address.ZipCode = "1234AB";
request.Enduser.Address.City = "City";
request.Enduser.Address.CountryCode = "NL";
// invoice address
request.Enduser.InvoiceAddress = new PAYNLSDK.Objects.Address();
request.Enduser.InvoiceAddress.Initials = "J.";
request.Enduser.InvoiceAddress.LastName = "Jansen";
request.Enduser.InvoiceAddress.Gender = PAYLSDK.Enums.Gender.Male;
request.Enduser.InvoiceAddress.StreetName = "InvoiceStreetname";
request.Enduser.InvoiceAddress.StreetNumber = "10";
request.Enduser.InvoiceAddress.ZipCode = "1234BC";
request.Enduser.InvoiceAddress.City = "City";
request.Enduser.InvoiceAddress.CountryCode = "NL";
PAYNLSDK.API.Transaction.Start.Response response = PAYNLSDK.Transaction.Start(request);
Sample code for this feature will be available soon
// Set configuration
PAYNLSDK.API.RequestBase.ApiToken = "token";
PAYNLSDK.API.RequestBase.ServiceId = "SL-3490-4320";
PAYNLSDK.API.Transaction.Start.Response response;
// Perform transaction to get response object. Alternately you could work with a stored ID
PAYNLSDK.API.Transaction.Info.Response info = PAYNLSDK.Transaction.Info(response.transactionId);
PAYNLSDK.Enums.PaymentStatus result = info.State;
if (PAYNLSDK.Transaction.IsPaid(result) || PAYNLSDK.Transaction.IsPending(result))
{
// redirect user to thank you page
}
else
{
// it has not been paid yet, so redirect user back to checkout
}
// Set configuration
PAYNLSDK.API.RequestBase.ApiToken = "token";
PAYNLSDK.API.RequestBase.ServiceId = "SL-3490-4320";
PAYNLSDK.API.Transaction.Info.Response info = PAYNLSDK.Transaction.Info(response.transactionId);
PAYNLSDK.Enums.PaymentStatus result = info.State;
if (PAYNLSDK.Transaction.IsPaid(result))
{
// process the payment
}
else
{
if(PAYNLSDK.Transaction.IsCancelled(result)){
// payment canceled, restock items
}
}
response.Write("TRUE| ");
// Optionally you can send a message after TRUE|, you can view these messages in the logs.
// https://admin.pay.nl/logs/payment_state
response.Write("Paid");
The C# .NET SDK including examples can be downloaded from GitHub.
Download SDK
require 'paynl'
# Set configuration
Paynl::Config::setApiToken('token')
Paynl::Config::setServiceId('SL-3490-4320')
# Get available payment methods
api = Paynl::Paymentmethods.new
options = Hash.new
puts api.getList(options)
require 'paynl'
# Set configuration
Paynl::Config::setApiToken('token')
Paynl::Config::setServiceId('SL-3490-4320')
data = Paynl::Transaction.new
options = Hash.new
# Required values
options.store('amount', 6.21)
options.store('returnUrl', 'http://your.webshop.org/visitor-return-after-payment')
options.store('ipaddress', '127.0.0.1')
# Optional values
options.store('paymentMethod', 10)
options.store('description', 'demo payment')
options.store('testMode', true)
options.store('extra1', 'ext1')
options.store('extra2', 'ext2')
options.store('extra3', 'ext3')
# First product
products = Hash.new
product = Hash.new
product.store('id', '234567')
product.store('price', 1.21)
product.store('tax', 0.21)
product.store('name', 'Testproduct voor de demo tour')
product.store('qty', 1)
products.store(products.length + 1, product)
# Second product
product = Hash.new
product.store('id', '2')
product.store('price', 5.00)
product.store('tax', 0.87)
product.store('name', 'Testproduct 2 voor de demo tour')
product.store('qty', 1)
products.store(products.length + 1, product)
options.store('products', products)
# Enduser data
enduser = Hash.new
enduser.store('initials', 'T')
enduser.store('lastName', 'Test')
enduser.store('gender', 'M')
enduser.store('dob', '14-05-1999')
enduser.store('phoneNumber', '0612345678')
enduser.store('emailAddress', 'test@example.org')
enduser.store('language','EN')
options.store('enduser', enduser)
# Address data
address = Hash.new
address.store('streetName', 'Test')
address.store('houseNumber', '10')
address.store('zipCode', '1234AB')
address.store('city', 'Test')
address.store('country', 'NL')
options.store('address', address)
invoiceAddress = Hash.new
invoiceAddress.store('initials', 'IT')
invoiceAddress.store('lastName', 'ITTest')
invoiceAddress.store('streetName', 'ITest')
invoiceAddress.store('houseNumber', '15')
invoiceAddress.store('zipCode', '1234CC')
invoiceAddress.store('city', 'TTest')
invoiceAddress.store('country', 'NL')
options.store('invoiceAddress', invoiceAddress)
result = data.start(options)
# Store the transaction ID which is in
puts result['transaction']['transactionId']
# Redirect the user to the URL
puts result['transaction']['paymentURL']
Sample code for this feature will be available soon
require 'paynl'
# Set configuration
Paynl::Config::setApiToken('token')
Paynl::Config::setServiceId('SL-3490-4320')
data = Paynl::Transaction.new
result = data.getTransaction(transactionId)
if Paynl::Helper::transactionIsPaid(result) or Paynl::Helper::transactionIsPending(result)
# redirect user to thank you page
else
# it has not been paid yet, so redirect user back to checkout
end
require 'paynl'
# Set configuration
Paynl::Config::setApiToken('token')
Paynl::Config::setServiceId('SL-3490-4320')
data = Paynl::Transaction.new
result = data.getTransaction(transactionId)
if Paynl::Helper::transactionIsPaid(result)
# Process the payment
elsif Paynl::Helper::transactionIsCanceled(result)
# Payment canceled, restock items
end
puts 'TRUE| '
# Optionally you can send a message after TRUE|, you can view these messages in the logs.
# https://admin.pay.nl/logs/payment_state
puts 'Paid: ' + Paynl::Helper::transactionIsPaid(result).to_s
The Ruby SDK including examples can be downloaded from GitHub.
Download SDK
Sample code for this feature will be available soon
TransactionService transaction = new TransactionService();
# Set configuration
transaction.setToken("token");
transaction.setServiceId("SL-3490-4320");
# Required values
transaction.setAmount(199);
transaction.setIpAddress("127.0.0.1");
transaction.setfinishUrl("https://pay.nl");
# Optional values
transaction.setTestMode(false);
transaction.transactionData.setDescription("Test Payment");
transaction.transactionData.setOrderExchangeUrl("https://pay.nl");
transaction.endUser.setLanguage("NL");
transaction.endUser.setInitials("T");
transaction.endUser.setLastName("Testpersoon");
transaction.endUser.address.setStreetName("Example street");
transaction.endUser.address.setStreetNumber("1");
transaction.endUser.address.setZipCode("1234AA");
transaction.endUser.address.setCity("Spijkenisse");
# Start transaction
transaction.startRequest();
# Return the result object
TransactionResult result = transaction.getResult();
if (result.request.result.equalsIgnoreCase("1")) {
System.out.println(result.transaction.transactionId);
System.out.println(result.transaction.paymentURL);
} else {
System.out.println("Error: "+ result.request.errorMessage);
}
Sample code for this feature will be available soon
TransactionInfoService transactionInfoService = new TransactionInfoService();
# Set configuration
transaction.setToken("token");
transaction.setServiceId("SL-3490-4320");
# Set orderId
transactionInfoService.setTransactionId("696298750X366d6a");
# Get transaction info
transactionInfoService.startRequest();
# Return the result object
TransactionInfoResult result = transactionInfoService.getResult();
if (result.request.result.equalsIgnoreCase("1")) {
if (result.isPaid() || result.isPending()) {
// redirect to thank you page"
} else if (result.isCanceled()) {
// redirect back to checkout
}
}
else {
System.out.println("Error: "+ result.request.errorMessage);
}
TransactionInfoService transactionInfoService = new TransactionInfoService();
# Set configuration
transaction.setToken("token");
transaction.setServiceId("SL-3490-4320");
# Set orderId
transactionInfoService.setTransactionId("696298750X366d6a");
# Get transaction info
transactionInfoService.startRequest();
# Return the result object
TransactionInfoResult result = transactionInfoService.getResult();
if (result.request.result.equalsIgnoreCase("1")) {
if (result.isPaid()) {
// process the payment
} else if (result.isCanceled())) {
// payment canceled, restock items
}
}
else {
System.out.println("TRUE|"+ result.request.errorMessage);
}
System.out.println("TRUE|");
The JAVA SDK including examples can be downloaded from GitHub.
Download SDK
var Paynl = require('paynl-sdk');
# Set configuration
Paynl.Config.setApiToken('token');
Paynl.Config.setServiceId('SL-3490-4320');
# Get available payment methods
Paynl.Paymentmethods.getList().forEach(
function(paymentmethod) {
console.log(paymentmethod.id + ' ' + paymentmethod.visibleName);
}
)
.catch(error => {
console.error(error);
});
var Paynl = require('paynl-sdk');
# Set configuration
Paynl.Config.setApiToken('token');
Paynl.Config.setServiceId('SL-3490-4320');
# Start a transaction
Paynl.Transaction.start({
amount: 19.95,
returnUrl: 'https://my-return-url.com/return',
ipAddress: '10.20.30.40'
})
.subscribe(
function (result) {
//redirect the user to this url to complete the payment
console.log(result.paymentURL);
// the transactionId, use this to fetch the transaction later
console.log(result.transactionId);
},
function (error) {
console.error(error);
}
);
var Paynl = require('paynl-sdk');
# Set configuration
Paynl.Config.setApiToken('token');
Paynl.Config.setServiceId('SL-3490-4320');
# Refund a transaction
Paynl.Transaction.refund({
transactionId: '715844054X85729e',
description: 'Refund order 123'
})
.subscribe(
result => {
console.log(result);
},
error => {
console.log(error);
},
() => {
console.log('complete');
}
);
var Paynl = require('paynl-sdk');
# Set configuration
Paynl.Config.setApiToken('token');
Paynl.Config.setServiceId('SL-3490-4320');
# Verify the transaction status
Paynl.Transaction.get('715844054X85729e').subscribe(
function(result){
// some examples of what you can do with the result
if (result.isPaid()) {
console.log('The transaction is paid');
}
if (result.isCanceled()) {
console.log('Tranasaction is canceled, restock the items');
}
},
function(error){
console.error(error);
}
)
var Paynl = require('paynl-sdk');
# Set configuration
Paynl.Config.setApiToken('token');
Paynl.Config.setServiceId('SL-3490-4320');
# Verify the transaction status
Paynl.Transaction.get('715844054X85729e').subscribe(
function(result){
if (result.isPaid()) {
// process the payment
}
if (result.isCanceled()) {
// payment canceled, restock items
}
},
function(error){
console.error(error);
}
)
The node.js SDK including examples can be downloaded from GitHub.
Download SDK