Payment Gateway Integration Tutorial For Developers - Emerchantpay
Payment Gateway Integration Tutorial For Developers - Emerchantpay
The ultimate guide for integrating a payment gateway with your online businesses. JavaScript & Server Side Tutorials | Shopping
Cart Tutorials
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
Quick
information, check integration
https://www.emerchantpay.com/insights/payment-gateway-integration/ 1/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
JavaScript only
Testing
The process of integrating a payment gateway may seem daunting, but if you want your website to accept online payments it is
necessary. Payment gateways connect the merchant’s website and their payment processing bank, allowing for the secure
transference of financial details. This is usually done by encrypting the details of credit cards, or other payment methods. In this
article, we will provide a step by step instructions for multiple types of integration methods. Throughout, we will be using our
payment gateway, Genesis, as an example. Before we get to the nitty gritty of the integration process, we first need to take a look at
the steps that need to be in place beforehand.
Quick integration
Before we start with different integration methods for the different programming languages, there is an option for a super quick
and simple integration. If this fits your requirements, keep reading. If not, you can skip to the next section.
We provide you with the option to generate and redirect the users to a hosted payment form
You can embed it
Please note: integrating the gateway by following the below steps is a more advanced. However, you can achieve similar results
with the above described, if it fits your business model.
PHP- https://github.com/GenesisGateway/genesis_php
Java- https://github.com/GenesisGateway/genesis_java
Node.js- https://github.com/GenesisGateway/genesis.js
2. You will need to sign a contract in order to receive your username, password and token
3. Client-side integration: you will need a HTML form to collect credit and debit card information.
First, the merchant needs to create a payment form integrated with the Client-Side Encryption (CSE) library. This can be retrieved
from the CSE panel in the merchant console on the merchant configuration page.
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
It is important
information, check out ourtoCookie
makepolicy.
sure that the payment form contains all the required fields for the transaction types that are going to be
used. If you are unsure, consult with our Transactions documentation. Don't forget to replace the form action with the payment
I AGREE CHANGE SETTINGS
handler URL of the merchant's server.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 2/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Flag all card input fields for encryption by annotating them with the data-encrypted-name attribute. The name attribute should not
be used for card input fields. The fields allowed for encryption are card_holder, card_number, expiration_month, expiration_year, and
cvv.
Use the "data-encrypted-name" attribute for card input fields. This technique protects the merchant's server from receiving
unencrypted card data and avoids any impact on the transaction security and PCI regulations compliance.
The form may have a custom ID attribute. The formId option can be used to set any string as an ID for the payment form. Make
sure to update the HTML form with the configured option and be careful to check that they both match.
Encrypto.createEncryptedForm(publicKey, {
onSubmit: function(form) {
// console.log(form.fields);
})
JavaScript only
In the instance that the merchant does not have an HTML form, our library provides HTML-independent encryption. In this scenario,
it's important to remember it's the merchant’s responsibility to make sure that the card data is encrypted before being sent to the
server.
<head>
...
<script src="https://{CDN}/encrypto-{VERSION}.js"
integrity="sha512-lJxHl93A/b8peqxz/mdLj7jD58N2zvHiiYhw8...=="
crossorigin="anonymous"></script>
</head>
<body>
<script>
let data = {
cvv: '123',
card_number: '42000...'
};
</script>
</body>
From the merchant's server, an HTTP POST request needs to be made to the gateway API endpoints. The workflow is the same as
I AGREE CHANGE SETTINGS
in the classic Client Integrations. The only difference is that when the Client-Side Encryption (CSE) library is used, our gateway will
i th dd t t d
https://www.emerchantpay.com/insights/payment-gateway-integration/ 3/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
receive the card data encrypted.
After this, the steps differ for each language and we will explain the requirements needed for them all.
<?php
require 'vendor/autoload.php';
\Genesis\Config::loadSettings('/path/to/config.ini');
\Genesis\Config::setEndpoint(\Genesis\API\Constants\Endpoints::EMERCHANTPAY);
\Genesis\Config::setEnvironment(\Genesis\API\Constants\Environments::STAGING);
\Genesis\Config::setUsername('<enter_your_username>');
\Genesis\Config::setPassword('<enter_your_password>');
\Genesis\Config::setToken('<enter_your_token>');
$genesis
->request()
->setTransactionId('43671')
->setRemoteIp('245.253.2.12')
->setAmount('50')
->setCurrency('USD')
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
// Customer
information, check out ourDetails
Cookie policy.
->setCustomerEmail('[email protected]')
(
https://www.emerchantpay.com/insights/payment-gateway-integration/ ) 4/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
->setCustomerPhone('1987987987987')
->setCardHolder('Emil Example')
->setCardNumber('4200000000000000')
->setExpirationMonth('01')
->setExpirationYear('2020')
->setCvv('123')
// Billing/Invoice Details
->setBillingFirstName('Travis')
->setBillingLastName('Pastrana')
->setBillingZipCode('10178')
->setBillingCity('Los Angeles')
->setBillingState('CA')
->setBillingCountry('US');
try {
$genesis->execute();
echo $genesis->response()->getResponseObject()->unique_id;
echo $genesis->response()->getResponseObject()->technical_message;
error_log($parameter->getMessage());
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
// Log/handle network (transport) errors
https://www.emerchantpay.com/insights/payment-gateway-integration/ 5/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
error_log($network->getMessage());
?>
Notifications
When using an asynchronous workflow, you need to parse the incoming extension in order to ensure its authenticity and verify it
against the Genesis server.
Example:
Endpoints
The current versions support two separate endpoints: E-ComProcessing and emerchantpay
You can set the Endpoint to E-ComProcessing, thus all the requests will go to E-ComProcessing’s Genesis instance:
\Genesis\Config::setEndpoint(\Genesis\API\Constants\Endpoints::ECOMPROCESSING);
You can set the Endpoint to emerchantpay, thus all the requests will go to emerchantpay’s Genesis instance:
\Genesis\Config::setEndpoint(\Genesis\API\Constants\Endpoints::EMERCHANTPAY);
Request types
You can use the following request types to initialise the Genesis client:
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 6/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Financial\Capture
Financial\Refund
Financial\Cancel
Financial\Alternatives\Earthport
Financial\Alternatives\P24
Financial\Alternatives\POLi
Financial\Alternatives\PPRO
Financial\Alternatives\Sofort
Financial\Alternatives\Trustly\Sale
Financial\Alternatives\Trustly\Withdrawal
Financial\Alternatives\PaypalExpress
// PayByVouchers transactions
Financial\PayByVouchers\oBeP
Financial\PayByVouchers\Sale
Financial\Cards\Argencard
Financial\Cards\Aura
Financial\Cards\Authorize
Financial\Cards\Authorize3D
Financial\Cards\Bancontact
Financial\Cards\Cabal
Financial\Cards\Cencosud
Financial\Cards\Credit
Financial\Cards\Elo
Financial\Cards\Hipercard
Financial\Cards\Naranja
Financial\Cards\Nativa
Financial\Cards\Payout
Financial\Cards\Sale
Financial\Cards\Sale3D
Financial\Cards\TarjetaShopping
Financial\Cards\Recurring\InitRecurringSale
Financial\Cards\Recurring\InitRecurringSale3D
Financial\Cards\Recurring\RecurringSale
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
// Cash
information, check Payments
out our Cookietransactions
policy.
Financial\CashPayments\Baloto
Financial\CashPayments\Banamex
https://www.emerchantpay.com/insights/payment-gateway-integration/ 7/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Financial\CashPayments\Boleto
Financial\CashPayments\Carulla
Financial\CashPayments\Efecty
Financial\CashPayments\EmpreseDeEnergia
Financial\CashPayments\Oxxo
Financial\CashPayments\PagoFacil
Financial\CashPayments\Redpagos
Financial\CashPayments\SantanderCash
Financial\CashPayments\Surtimax
// Crypto transactions
Financial\Crypto\BitPay\Sale
Financial\Crypto\BitPay\Refund
Financial\Crypto\BitPay\Payout
Financial\GiftCards\Intersolve
Financial\GiftCards\Fashioncheque
Financial\GiftCards\TCS
Financial\SCT\Payout
Financial\SDD\Sale
Financial\SDD\Refund
Financial\SDD\Recurring\InitRecurringSale
Financial\SDD\Recurring\RecurringSale
Financial\OnlineBankingPayments\Alipay
Financial\OnlineBankingPayments\BancoDoBrasil
Financial\OnlineBankingPayments\Bancomer
Financial\OnlineBankingPayments\Bradesco
Financial\OnlineBankingPayments\Entercash
Financial\OnlineBankingPayments\Eps
Financial\OnlineBankingPayments\GiroPay
Financial\OnlineBankingPayments\Ideal
Financial\OnlineBankingPayments\iDebit\Payin
Financial\OnlineBankingPayments\iDebit\Payout
Financial\OnlineBankingPayments\InstaDebit\Payin
Financial\OnlineBankingPayments\InstaDebit\Payout
Financial\OnlineBankingPayments\InstantTransfer
Financial\OnlineBankingPayments\Itau
Financial\OnlineBankingPayments\Multibanco
Financial\OnlineBankingPayments\MyBank
Financial\OnlineBankingPayments\PaySec\Payin
Financial\OnlineBankingPayments\PaySec\Payout
Financial\OnlineBankingPayments\PayU
Financial\OnlineBankingPayments\Pse
Financial\OnlineBankingPayments\RapiPago
Financial\OnlineBankingPayments\SafetyPay
Financial\OnlineBankingPayments\Santander
Financial\OnlineBankingPayments\TrustPay
Financial\OnlineBankingPayments\WeChat
Financial\Preauthorization\IncrementalAuthorize
Financial\Preauthorization\PartialReversal
// Vouchers
Financial\Vouchers\AstropayCard
Financial\Vouchers\CashU
Financial\Vouchers\Neosurf
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
Financial\Vouchers\Paysafecard
// Electronic
I AGREE Wallets
CHANGE transactions
SETTINGS
Financial\Wallets\eZeeWallet
Fi i l\W ll t \N t ll
https://www.emerchantpay.com/insights/payment-gateway-integration/ 8/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Financial\Wallets\Neteller
Financial\Wallets\Qiwi
Financial\Wallets\WebMoney
Financial\Wallets\Zimpler
NonFinancial\AccountVerification
NonFinancial\Blacklist
NonFinancial\Consumers\Create
NonFinancial\Consumers\Retrieve
NonFinancial\Consumers\Update
NonFinancial\Consumers\Disable
NonFinancial\Consumers\Enable
NonFinancial\Fraud\Chargeback\DateRange
NonFinancial\Fraud\Chargeback\Transaction
// SAFE/TC40 Report
NonFinancial\Fraud\Reports\DateRange
NonFinancial\Fraud\Reports\Transaction
// Retrieval request
NonFinancial\Fraud\Retrieval\DateRange
NonFinancial\Fraud\Retrieval\Transaction
// Fx requests
NonFinancial\Fx\GetTiers
NonFinancial\Fx\GetTier
NonFinancial\Fx\GetRates
NonFinancial\Fx\GetRate
NonFinancial\Fx\SearchRate
// KYC requests
NonFinancial\KYC\Call\Create
NonFinancial\KYC\Call\Update
NonFinancial\KYC\ConsumerRegistration\Create
NonFinancial\KYC\ConsumerRegistration\Update
NonFinancial\KYC\IdentityDocument\Download
NonFinancial\KYC\IdentityDocument\Upload
NonFinancial\KYC\Transaction\Create
NonFinancial\KYC\Transaction\Update
// Reconcile requests
NonFinancial\Reconcile\DateRange
NonFinancial\Reconcile\Transaction
NonFinancial\Retrieve\AbniDealBanks
WPF\Create
WPF\Reconcile
When all this has been completed, you can then start testing >>
<dependency>
<groupId>com.emerchantpay.gateway</groupId>
<artifactId>genesis-java</artifactId>
<version>1.7.0</version>
</dependency>
Example
import com.emerchantpay.gateway.GenesisClient;
import com.emerchantpay.gateway.api.TransactionResult;
import com.emerchantpay.gateway.api.constants.Endpoints;
import com.emerchantpay.gateway.api.constants.Environments;
import com.emerchantpay.gateway.api.requests.financial.card.AuthorizeRequest;
import com.emerchantpay.gateway.model.Transaction;
import com.emerchantpay.gateway.util.Configuration;
// Create configuration
configuration.setUsername("SET_YOUR_USERNAME");
configuration.setPassword("SET_YOUR_PASSWORD");
configuration.setToken("SET_YOUR_TOKEN");
authorize.setTransactionId(uniqueId)
.setRemoteIp("245.253.2.12");
authorize.setGaming(true);
authorize.setCurrency("USD").setAmount(new BigDecimal("50.00"));
authorize.setCardHolder("Emil Example")
.setCardNumber("4200000000000000")
.setExpirationMonth("01")
.setExpirationYear("2020")
.setCvv("123");
authorize.setBillingFirstname("Travis")
.setBillingLastname("Pastrana")
.setBillingZipCode("10178")
.setBillingCity("Los Angeles")
.setBillingState("CA").setBillingCountry("US");
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
GenesisClient client = new GenesisClient(configuration, authorize);
client.debugMode(true);
https://www.emerchantpay.com/insights/payment-gateway-integration/ 10/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Notifications
import com.emerchantpay.gateway.NotificationGateway;
import com.emerchantpay.gateway.api.constants.Endpoints;
import com.emerchantpay.gateway.api.constants.Environments;
import com.emerchantpay.gateway.util.Configuration;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// Create configuration
configuration.setUsername("SET_YOUR_USERNAME");
configuration.setPassword("SET_YOUR_PASSWORD");
configuration.setToken("SET_YOUR_TOKEN");
map.put("transaction_id", "82803B4C-70CC-43BD-8B21-FD0395285B40");
map.put("unique_id", "fc6c3c8c0219730c7a099eaa540f70dc");
map.put("signature", "3070d7030806a3763fcae73923d9c2da0898dd19");
map.put("transaction_type", "sale3d");
map.put("terminal_token", configuration.getToken());
map.put("status", "approved");
map.put("amount", "500");
map.put("eci", "05");
map.put("avs_response_code", "5I");
map.put("avs_response_text", "Response+provided+by+issuer+processor%3B+
Address+information+not+verified");
notification.initReconciliation();
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check // String
out our status = notification.getReconcilation().getStatus();
Cookie policy.
I AGREE //CHANGE
Generate the Gateway response
SETTINGS
notification.generateResponse();
https://www.emerchantpay.com/insights/payment-gateway-integration/ 11/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
System.out.println(response);
System.out.println(uniqueId);
Endpoints
Request types
You can use the following request types to initialise the Genesis client:
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 12/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
api.requests.financial.CaptureRequest
api.requests.financial.RefundRequest
api.requests.financial.VoidRequest
api.requests.financial.apm.CashURequest
api.requests.financial.apm.P24Request
api.requests.financial.apm.PaySafeCardRequest
api.requests.financial.apm.POLiRequest
api.requests.financial.apm.PProRequest
api.requests.financial.apm.SofortRequest
api.requests.financial.apm.TrustlySaleRequest
api.requests.financial.apm.TrustlyWithdrawalRequest
api.requests.financial.apm.PayPalExpressRequest
api.requests.financial.apm.EarthportRequest
// PayByVouchers transactions
api.requests.financial.pbv.PBVSaleRequest
api.requests.financial.pbv.PBVYeePayRequest
api.requests.financial.card.AuthorizeRequest
api.requests.financial.card.Authorize3DRequest
api.requests.financial.card.CreditRequest
api.requests.financial.card.PayoutRequest
api.requests.financial.card.SaleRequest
api.requests.financial.card.Sale3DRequest
api.requests.financial.card.recurring.InitRecurringSaleRequest
api.requests.financial.card.recurring.InitRecurringSale3DRequest
api.requests.financial.card.recurring.RecurringSaleRequest
api.requests.financial.sdd.SDDSaleRequest
api.requests.financial.sct.SCTPayoutRequest
api.requests.financial.sdd.SDDRefundRequest
api.requests.financial.sdd.SDDInitRecurringSaleRequest
api.requests.financial.sdd.SDDRecurringSaleRequest
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
api.requests.financial.apm.CitadelPayInRequest
api.requests.financial.oBeP.InstadebitPayInRequest
https://www.emerchantpay.com/insights/payment-gateway-integration/ 13/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
api.requests.financial.oBeP.IDebitPayInRequest
api.requests.financial.oBeP.IDebitPayOutRequest
api.requests.financial.oBeP.AlipayRequest
api.requests.financial.oBeP.WechatRequest
api.requests.financial.oBeP.PaySecRequest
api.requests.financial.oBeP.PaySecPayoutRequest
api.requests.financial.oBeP.RPNRequest
api.requests.financial.oBeP.RPNPayoutRequest
api.requests.financial.wallets.eZeeWalletRequest
api.requests.financial.wallets.NetellerRequest
api.requests.financial.wallets.WebMoneyRequest
api.requests.nonfinancial.AccountVerificationRequest
api.requests.nonfinancial.BlacklistRequest
api.requests.nonfinancial.fraud.ChargebackByDateRequest
api.requests.nonfinancial.fraud.ChargebackRequest
// SAFE/TC40 Report
api.requests.nonfinancial.fraud.ReportsByDateRequest
api.requests.nonfinancial.fraud.ReportsRequest
// Retrieval request
api.requests.nonfinancial.fraud.RetrievalByDateRequest
api.requests.nonfinancial.fraud.RetrievalRequest
// Reconcile requests
api.requests.nonfinancial.reconcile.ReconcileByDate
api.requests.nonfinancial.reconcile.ReconcileRequest
api.requests.nonfinancial.retrieve.AbnIDealBanksRetrieveRequest
api.requests.wpf.WPFCreateRequest
api.requests.wpf.WPFReconcileRequest
api.requests.financial.giftcards.FashionchequeRequest
api.requests.financial.giftcards.IntersolveRequest
api.requests.financial.giftcards.TCSRequest
More information about each one of the request types can be found in the Genesis API Documentation and the Wiki.
When all this has been completed, you can then start testing >>
Gradle
We areThen,
using cookies
add theto give you the bestinexperience
dependency on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
your build.gradle:
information, check out our Cookie policy.
dependencies
I AGREE CHANGE SETTINGS
https://www.emerchantpay.com/insights/payment-gateway-integration/ 14/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
dependencies {
implementation 'com.emerchantpay.gateway:genesis-android:1.2.1'
Basic usage
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="YOUR_PACKAGE">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
</intent-filter>
</activity>
<activity android:name="com.emerchantpay.gateway.genesisandroid.api.ui.GenesisWebViewActivity"/>
</application>
</manifest>
MainActivity.java:
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 15/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
import android.R
import android.app.Activity
import android.os.Bundle
import android.view.View
import com.emerchantpay.gateway.androidgenesissample.R
import com.emerchantpay.gateway.genesisandroid.api.ui.AlertDialogHandler
import com.emerchantpay.gateway.genesisandroid.api.constants.Endpoints
import com.emerchantpay.gateway.genesisandroid.api.constants.Environments
import com.emerchantpay.gateway.genesisandroid.api.constants.ErrorMessages
import com.emerchantpay.gateway.genesisandroid.api.constants.Locales
import com.emerchantpay.gateway.genesisandroid.api.internal.Genesis
import com.emerchantpay.gateway.genesisandroid.api.internal.request.PaymentRequest
import com.emerchantpay.gateway.genesisandroid.api.internal.request.TransactionTypesRequest
import com.emerchantpay.gateway.genesisandroid.api.internal.response.Response
import com.emerchantpay.gateway.genesisandroid.api.models.Country
import com.emerchantpay.gateway.genesisandroid.api.models.Currency
import com.emerchantpay.gateway.genesisandroid.api.models.GenesisError
import com.emerchantpay.gateway.genesisandroid.api.models.PaymentAddress
import com.emerchantpay.gateway.genesisandroid.api.models.WPFTransactionTypes
import com.emerchantpay.gateway.genesisandroid.api.util.Configuration
import java.math.BigDecimal
import java.util.UUID
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@Throws(IllegalAccessException::class)
// Generate unique Id
// Create configuration
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
"SET_YOUR_PASSWORD",
( )
https://www.emerchantpay.com/insights/payment-gateway-integration/ 16/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
configuration.setDebugMode(true)
// Alert dialog
"Washington", Country.UnitedStates)
transactionTypes.addTransaction(WPFTransactionTypes.sale)
BigDecimal("2.00"), Currency.USD,
"https://example.com", transactionTypes)
when {
genesis.isConnected(this)!! -> {
ErrorMessages.CONNECTION_ERROR)
dialogHandler.show()
when {
genesis.push()
// Get response
when {
response!!.isSuccess!! -> {
error = response!!.error
+ error!!.message)
dialogHandler.show()
when {
genesis.isValidData!! -> {
error = genesis.error
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
val message = error!!.message
!! t h i lM ! ll && !
https://www.emerchantpay.com/insights/payment-gateway-integration/
!! t h i lM !! i E t () t h i lM 17/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
error!!.technicalMessage != null && !error!!.technicalMessage!!.isEmpty() -> technicalMessage =
error!!.technicalMessage
"$technicalMessage $message")
dialogHandler.show()
Additional usage
You will have to set usage, description and lifetime:
paymentRequest.setUsage("TICKETS")
paymentRequest.setDescription("Description")
paymentRequest.setLifetime(60)
"Washington", Country.UnitedStates)
paymentRequest.setShippingAddress(shippingAddress)
// Risk params
"+49301234567")
paymentRequest.setRiskParams(riskParams)
Once all of these stages have been completed, you can then test the gateway.
Getting started
In order to process transactions via Genesis, you'll have to acquire the necessary credentials in order to connect to the gateway.
Configuration
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
You can override the path to the directory holding your configuration files (by default it’s config in the root directory of the module)
I AGREE CHANGEvariable NODE_CONFIG_DIR.
via environmental SETTINGS The first file to parse configuration from, is <your-config-dir>/default.json and based
on the environment variable (NODE ENV), you can specify your custom file; for example <your-config-
https://www.emerchantpay.com/insights/payment-gateway-integration/ 18/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
o t e e o e t a ab e ( O _ ), you ca spec y you custo e; o e a p e you co g
dir>/<NODE_ENV_NAME>.json. It’s good practice to prevent web or direct access to your config directory to protect the files inside.
Sale transaction
JavaScript
genesis = require('./lib/genesis.js');
crypto = require('crypto');
failure = function(reason) {
return console.log(reason);
};
success = function(data) {
return console.log(data);
};
transaction.sale({
transaction_id: crypto.randomBytes(16).toString('hex'),
amount: '100',
currency: 'USD',
card_number: '4200000000000000',
cvv: '000',
expiration_month: 12,
expiration_year: 2020,
customer_email: '[email protected]',
customer_phone: '0123456789',
billing_address: {
first_name: 'John',
last_name: 'Doe',
zip_code: '10000',
country: 'US'
})
.send()
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
.then(success)
CoffeeScript
https://www.emerchantpay.com/insights/payment-gateway-integration/ 19/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
crypto = require 'crypto'
console.log reason
console.log data
transaction.sale({
transaction_id : crypto.randomBytes(16).toString('hex')
remote_ip : '127.0.0.1'
amount : '100'
currency : 'USD'
card_number : '4200000000000000'
cvv : '000'
expiration_month : 12
expiration_year : 2020
customer_email : '[email protected]'
customer_phone : '0123456789'
billing_address :
first_name: 'John'
last_name : 'Doe'
zip_code : '10000'
country : 'US'
})
.send()
.then(success)
.catch(failure)
The example above is going to create a Sale (Authorise w/ immediate Capture) transaction for the amount of $100.
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 20/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
genesis = require('./lib/genesis.js');
crypto = require('crypto');
failure = function(reason) {
return console.log(reason);
};
success = function(data) {
return console.log(data);
};
transaction.wpf_create({
locale: 'de',
transaction_id: crypto.randomBytes(16).toString('hex'),
remote_ip: '127.0.0.1',
amount: '100',
currency: 'USD',
customer_email: '[email protected]',
customer_phone: '0123456789',
notification_url: 'http://my.host.name.tld:1234/notifier',
return_success_url: 'http://my.host.name.tld/success',
return_failure_url: 'http://my.host.name.tld/failure',
return_cancel_url: 'http://my.host.name.tld/cancel',
billing_address: {
first_name: 'John',
last_name: 'Doe',
zip_code: '10000',
country: 'US'
},
})
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
.send()
.catch(failure);
CoffeeScript
https://www.emerchantpay.com/insights/payment-gateway-integration/ 21/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
CoffeeScript
console.log body
transaction.wpf_create({
locale : 'de'
transaction_id : crypto.randomBytes(16).toString('hex')
remote_ip : '127.0.0.1'
amount : '100'
currency : 'USD'
customer_email : '[email protected]'
customer_phone : '0123456789'
notification_url : 'http://my.host.name.tld:1234/notifier'
return_success_url: 'http://my.host.name.tld/success'
return_failure_url: 'http://my.host.name.tld/failure'
return_cancel_url : 'http://my.host.name.tld/cancel'
billing_address :
first_name: 'John'
last_name : 'Doe'
zip_code : '10000'
country : 'US'
transaction_types: [
'authorize3d'
'sale'
})
.send()
.then(success)
.catch(failure)
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
The example above is going to create a new WPF instance with German (de) locale and allowed transaction types
- authorize3d (Authorize
I AGREE w/ 3D-Secure asynchronously) and sale for the amount of $100.
CHANGE SETTINGS
N tifi ti li t
https://www.emerchantpay.com/insights/payment-gateway-integration/ 22/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Notification listener
JavaScript
genesis = require('./lib/genesis.js');
success = function(result) {
return console.log(result);
};
failure = function(error) {
return console.log(error);
};
notification.listen(success, failure);
notification_url = notification.getUrl();
CoffeeScript
console.log result
console.log error
notification_url = notification.getUrl()
The example above would create a notification listener on my.host.name.tld:1234/notifier which you can use as notification handler
for async transactions. If a notification is received and it’s successfully verified against our backend, the callback will be called with
details of the transaction you're being notified for.
Request and response objects should be enhanced versions of Node’s own request and response objects and support all built-in
fields and methods.
JavaScript
genesis = require('./lib/genesis.js');
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
router.post('/listen', urlencodedParser, function (request, response) {
.then(console.log)
});
https://www.emerchantpay.com/insights/payment-gateway-integration/ 23/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
});
CoffeeScript
notification.handle(request, response)
.then console.log
.catch console.log
Transaction types
account_verification
avs
authorize
authorize3d
blacklist
capture
chargeback
chargeback_by_date
credit
fraud_report
fraud_report_by_date
init_recurring
init_recurring_sale3d
reconcile
reconcile_by_date
recurring_sale
refund
retrieval
retrieval_by_date
payout
sale
sale3d
void
wpf_create
wpf_reconcile
p24
Transaction parameters
In order to get a full list of required and optional parameters, please consult our API documentation.
After all these steps have been completed you may now proceed to testing.
The emerchantpay payment gateway also supports .NET and Swift (iOS client library) integrations. You can find the full
documentation here:
.NET documentation
Swift documentation
We have
I AGREE developed easy to install and configure modules for all of the most popular content managements systems, including
CHANGE SETTINGS
Magento version 1 and 2, Opencart, osCommerce, PrestaShop, Shopify, WooCommerce, X-Cart and Zen Cart.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 24/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
We will explain the integration process for Wordpress, Opencart and Prestashop. If you are using any of the other CMS mentioned
above, you can find the full instructions and documentation in GitHub.
Installation
Log in to your WordPress admin panel with your administrator account privileges
Navigate to Plugins -> add new
Install through the Marketplace by typing emerchantpay in the search
Select the downloaded .zip file
Activate the newly installed WooCommerce emerchantpay Payment Gateway Client plugin
Navigate to WooCommerce -> settings -> checkout
Select your preferred payment method emerchantpay Checkout or emerchantpay Direct
Check enable, set the correct credentials and save changes.
Ensure you have installed and configured a SSL Certificate on your PCI-DSS certified server
Log in to your WordPress admin panel with administrator privileges
Navigate to WooCommerce - > settings -> checkout
Under Checkout Process check force secure checkout.
If you are using tokenisation for your Web Payment Form, please make sure Guest Checkout is disabled.
Subscriptions
In order to process subscriptions, the WooCommerce Subscription Extension needs to be installed, which will add subscription
support to the WooCommerce plugin.
Manage subscriptions
https://www.emerchantpay.com/insights/payment-gateway-integration/ 25/31
a age subsc pt o s
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Refund a subscription
You are only allowed to refund the sign-up fee for a subscription
If your site is hosted on your server, connect to the machine using SSH and type the following command into the terminal to edit
your cron jobs. Do not forget to replace www-data with your WebServer User.
and add the following line to execute the WordPress Cron once per 10 Minutes
OpenCart 2.0.X - 3.0.2.X (due to architectural changes, this module is incompatible with OpenCart 1.X)
GenesisPHP v1.4 - (integrated in module)
PCI-certified server in order to use emerchantpay Direct
Installation (manual)
1. Upload the contents of the folder (excluding README.md) to the <root> folder of your OpenCart installation
Ensure you have installed a valid SSL Certificate on your PCI-DSS certified web server and you have configured your virtual
host properly
Log in to your OpenCart admin panel
Navigate to Settings -> Your Store -> Server
If you have trouble with your credentials or terminal configuration, get in touch with our support team.
Installation (manual)
Upload the contents of folder (excluding README.md) to the <root> folder of your PrestaShop installation
Login into your PrestaShop admin panel
Navigate to Modules -> Payment
Locate emerchantpay payment gateway in the list and click install
Tweak the settings according to your preference and click save when ready
You can find the new payment methods in the checkout section of your store front
Clear the cache via Advanced Parameters -> Performance -> clear cache
https://www.emerchantpay.com/insights/payment-gateway-integration/ 27/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
If you have payment restrictions in place, you'll have to add the newly installed payment method to
the currencies / countries / groups you wish to appear on.
Ensure you have installed a valid SSL Certificate on your PCI-DSS certified web server and you have configured your virtual
host properly
Log in to your PrestaShop admin panel
Navigate to Shop Parameters -> General
Click the link titled ‘please click here to check if your shop supports HTTPS’ near to the enable SSL option
Set enable SSL to yes
Click save
Set enable SSL on all pages to yes
Click save
It is recommended to add a rewrite rule from http to https or to add a permanent redirect to https in your virtual host.
Testing
To test your newly integrated payment gateway, log in to the gateway admin and create a terminal.
The API base URL for testing single transaction reconciling is: https://staging.gate.emerchantpay.net/reconcile/TERMINAL_TOKEN
The API base URL for test date range reconciling is: https://staging.gate.emerchantpay.net/reconcile/by_date/TERMINAL_TOKEN
The following credit card numbers can be used to test the gateway:
For 3DSecure testing the following credit card numbers can be used:
3DSecure unavailable -
4012001036853337 Visa
Card Not Participating
3DSecure unavailable -
5111010030175156 Mastercard
Card Not Participating
In test mode, successful transaction XML responses will include the following error message: ”TESTMODE: No real money will be
transferred!”
Conclusion
At emerchantpay, we strive to make the onboarding process as seamless as possible for our merchants, with 14 working days as
our optimal timeframe. Whilst we handle everything on our side, we only require patience and that the necessary information be
provided by merchants. Integrating with the emerchantpay payment gateway is straightforward if you follow our simple
instructions. Our support team are always on hand to offer assistance if you encounter any difficulties.
If you want to hear more about what emerchantpay has to offer get in touch today to chat to one of our specialists.
Related articles
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
Everything you need to know about
information, check out our Cookie policy. Error code 2000: What does "Do Not
payment
I AGREE
tokenisation
CHANGE SETTINGS
Honour" really mean?
Great for consumers a game-changer for merchants We ‘Do Not Honour’ – also known as error code 2000 and 05 –
https://www.emerchantpay.com/insights/payment-gateway-integration/ 29/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Great for consumers, a game changer for merchants. We Do Not Honour also known as error code 2000 and 05
all encounter tokenisation whenever we make a purchase is by far the most common of all the error codes that come
without having to re-enter all [...] up when a [...]
By Shannon Lynn
12 February 2021
I have read and understood the Privacy Policy and agree to the use of my personal data accordingly. By clicking SUBSCRIBE I consent to emerchantpay storing and processing my personal
data required to contact me. I understand I may unsubscribe from these communications at any time.
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
SUBSCRIBE
I AGREE CHANGE SETTINGS
https://www.emerchantpay.com/insights/payment-gateway-integration/ 30/31
11/3/21, 10:22 PM Payment Gateway Integration Tutorial for Developers | emerchantpay
Privacy Policy | Cookies | Terms of Use | Security of Client Funds | Modern Slavery and Human Trafficking Statement
For the US only, emerchantpay corporation is a Registered MSP/ISO of Elavon, Inc. Georgia [a wholly owned subsidiary of U.S. Bancorp, Minneapolis, MN]
TM
Copyright ©2021, emerchantpay Ltd.
We are using cookies to give you the best experience on our site. By continuing to use our website without changing the settings, you are agreeing to our use of cookies. For more
information, check out our Cookie policy.
https://www.emerchantpay.com/insights/payment-gateway-integration/ 31/31