Learn about online payment

Tram Ho

Written by Nguyen Van Sang

As everyone knows, e-commerce is growing, because of the convenience, the maximum support for both customers and businesses and the connection between the two is also much easier. Contributing to this development cannot help but mention the introduction of online payment gateways. In this article, I will show you how it works and then how to integrate the online payment gateway (specifically Braintree) into your application.

What is an online payment gateway?

Online payment gateway is an e-commerce service aimed at connecting banks to merchants, allowing customers to make payments easier than ever. More specifically, it performs customer account verification tasks with anti-fraud strategies, a trusted party to authorize transactions made by data such as credit card numbers, numbers Card confirmation (CVV), expiration date, … encrypted, transported in the most secure way between the parties. In addition, electronic payment gateways also provide transaction statistics services, refund policy, clear dispute resolution, support multiple payment methods, multiple currencies. Some popular online payment gateways are PayPal / Braintree, Stripe, Square, …

Understand the technical way, you can consider online payment gateway as a software application provided by payment services to simplify the construction of payment functions in your application for a small fee. .

How does the online payment gateway work?

Most basically, the online payment will take the following steps:

  1. Customers make a transaction on your application.
  2. Your application sends transaction data to the online payment gateway securely. The payment gateway then forwards the data to the affiliate bank to perform the authentication.
  3. When the authentication process is completed, the payment activity will be authorized or denied by the bank (based on the accuracy of the customer information entered or the available balance in the customer account).
  4. Based on the authorized or declined transaction results, the payment gateway will issue a notification to your application.
  5. If the authorization is successful, the affiliate bank will transfer money to the online payment gateway (specifically the seller’s account).

Understand simply, the online payment gateway is responsible for mediating a quick and secure payment between the customer and the seller, authorizing and withdrawing money from the client account and then depositing it into the human account. sell (for a fee)

Benefits of using online payment gateway

  • It is one of the few ways to connect your application to payment systems because usually only large providers can connect directly to banks, financial units.
  • Service fee is negligible compared to the features it brings (banking connection, financial management, risk handling policy, support for a variety of payment methods and currencies)
  • Help sellers manage their finances better thanks to the statistics it provides

Braintree online payment gateway

Braintree is a payment platform that allows your application to accept payments via credit card, debit card, PayPal, Google Pay, Samsung Pay, … and support across multiple countries, used by companies big like Airbnb and Uber. Braintree also offers similar services to other online payment gateways like Stripe, Square. The difference may differ only in the service charge policy, but Braintree also stands out for its easy integration into the application with a clear set of documents available for each language supported. Here is the common flow when integrating Braintree into your application (including client and server).

  1. Your client will request a client token from your server to create the SDK client of Braintree.
  2. Your server will generate and send the client token to your client using Braintree’s server SDK.
  3. Once the client SDK is initialized and the customer sends it payment information, Braintree will perform a link with the bank to authenticate and return a nonce (number used only once) in case of success.
  4. Your client receives nonce and sends it to your server.
  5. Your server receives nonce, then use the server SDK to create transactions or perform other functions.

Maybe you are interested

To catch the eye of Google, Microsoft, Apple, remember the following 4 tips!

The AI ​​application automatically switches the code screen when it detects that the boss is close

For example integrating Braintree with Ruby on Rails

We use the example that Braintree provides here , you can download the test run, and in the article I will only speak through important files.

Add 2 gems on your Gemfile . Braintree gem allows you to use server SDK of Braintree, dotenv gem to load Braintree keys from .env file

This is a file that saves public key, private key, merchant id we use to connect to Braintree, you can use your account (because the sandbox environment Braintree also distinguishes the key between production and sandbox ^^) or create a new account here

The code handles submitting the transaction

The code shows the created transaction

And this is the result

With only a few short lines of code, we were able to integrate online payments into the system (in the sandbox environment, Braintree provided example instances for transaction status according to the card information and the amount entered). , refer here ).

For example, a transaction is successful

Hope the article can help you!


Share the news now

Source : Viblo