Payment Gateway

Receiving Payments using Stripe

Stripe Payment Gateway

Every successful online business requires one thing – a payment gateway. 

As per Investopedia: “A payment gateway is a technology used by merchants to accept debit or credit card purchases from customers. The term includes not only the physical card-reading devices found in brick-and-mortar retail stores but also the payment processing portals found in online stores.”

Why are Payment Gateways Important? 

  • Every business needs to receive money. 
  • They are more secure and faster than traditional money transfers.
  • Reduces money fraud!
  • Customer data is encrypted and secure.
  • As more and more businesses come online, the scope of online banking transactions will only increase.
  • Even NGOs need to receive donations.

Business Use Case

We were making an Enterprise Resource Planning software for a client.

Their platform allowed Service Providers to offer their services to customers via our client’s portal. 

We were to provide a solution to receive payments from the customers and redirect those funds to the service providers. So money was to be collected from customers and passed onto the service provider, after deduction of companies’ share.


  • There were several payment methods to choose from. Pay by credit card, bank account or pay by manual means (cheque/draft).
  • There were different billing cycles like monthly subscription, or prepaid. 
  • The bill amount was expected to be large enough that most customers would have opted for the pay by bank account (as credit card charges more). 
  • Now there were customers from different countries around the world with different payment systems, different currencies, different taxation laws. 
  • They also need payouts capabilities to send money to Service Providers.
  • They also needed capability to offer refunds. 

Our Solution

Comparing available options, we went ahead with Stripe as it was developer-friendly, had a lot of examples and demo codes and it fulfilled all our requirements.

The customer and service provider would both be directed to create a Stripe account. This Stripe account would be linked to their bank account. After creation, the Stripe account would get connected to the user’s account on our platform. Stripe would handle all currency conversions by itself.  So the flow of money would be:


Why Stripe Express?

Stripe provides various facilities like connect : standard and express. We chose express.

As per Stripe:

“Express accounts are a hybrid option that allows platform owners to customize some aspects while Stripe takes care of on-boarding, verification and account management. Quicker to implement. Platform fees apply.”


  1. When logged on to the Platform, the user would be shown a button (link with Stripe) which redirected them to Stripe’s Account Creation page.
  2. After the user clicks the link, they are taken to Stripe’s website where they are asked to provide contact and payout information.
  3. After the user completes the process, they are redirected back to the Platform, using the URL defined as platform’s redirect_uri. An authentication token is also returned.
  4. In the backend, the newly created account is verified and connected to the Platform’s Stripe account using Stripe’s APIs and the returned authentication token.
  5. Once, the account is connected with the Platform, charges and payouts can be made to the account as per TRANSFER CAPABILITIES set in Stripe settings of the account.

The whole process is secure and uses https and OAUTH.

How We Used Stripe API?

We used Stripe’s API to charge the customers and cron jobs.

  • In case of a prepaid or direct charge, API call was made instantly to charge the client.
  • If payment was monthly, then node-cron was used for a cronjob to process all pending payments at start of new month.
  • Payment status was maintained using webhooks.
  • After an API call, charge created on Stripe website, a webhook was called to update status of payment as successful or failed in our DB.
  • In case of success, error or failed transfer both the Platform and the concerned party would be sent emails by Stripe and confirmation by Platform.
  • For failed transactions, cron would again run after a few days.

Similar cronjobs were made for payouts to Service Providers.

Implementation of credit cards was relatively easy. We still kept it just in case, someone wants to try out the platform for a few days, billing amount is low, or doesn’t want to create a Stripe account.

We also ran a cron for checking credit cards which were expiring next month to inform users to update accounts with other card details.

What is Stripe? 

  • Stripe is the most powerful and flexible tool for internet commerce. 
  • A set of unified APIs and tools that instantly enable businesses to accept and manage online payments.
  • Millions of the world’s most innovative technology companies are scaling faster and more efficiently by building their businesses on Stripe.
  • Built for developers!
  • Whether you’re creating a subscription service, an on-demand marketplace, an e-commerce store, or a crowdfunding platform, Stripe’s meticulously designed APIs and unmatched functionality help you create the best possible product for your users. 

Why use Stripe? 

Developer friendly 

  • “We believe that payments are a problem rooted in code, not finance. We obsessively seek out elegant, composable abstractions that enable robust, scalable, flexible integrations. Because we eliminate needless complexity and extraneous details, you can get up and running with Stripe in just a couple of minutes.” – Stripe 
  • It powers millions of businesses in 100+ countries and across nearly every industry. 
  • Headquartered in San Francisco, Stripe has 14 global offices and hundreds of people working to help transform how modern businesses are built and run.
  • It accepts all major currencies including USD and INR
  • It is PCI compliant. 
  • It allows easy migration and data portability 

How Much Does Stripe Cost? 

stripe 3



If your are planning to implement Stripe, here is a short example to help you get started.

Stripe API documentation :

Flow for Receiving Payments


NPM package used: “react-stripe-checkout”

stripe 4

Important Terms

We will be using Stripe Connect for this. For this you will need to create an account on Stripe and obtain API keys.

  • Public and Private key: – Keys obtained from Stripe
  • Stripe Checkout – Checkout creates a secure, Stripe-hosted payment page that lets you collect payments quickly. It works across devices and is designed to increase your conversion.
  • Stripe Token –

Tokenization is the process Stripe uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. 

  • Direct Charge – With Connect, you can make charges directly on the connected account and take fees in the process. The connected account is responsible for Stripe fees, refunds, and chargebacks.
  • Customer Create

Implementation of Receiving Money from Clients via Stripe

Clone the github repo.

Front-end code is in the Client directory whereas Backend code is in the root directory. Create a stripe account to get API keys. Replace the keys in respective .env files.


  1. Download/Clone the repository.
  2. Do “npm install” in root and in client directory
  3. Replace values of secret key (backend) and public key (frontend) in envs provided.
  4. To run backend, “npm run start” in root directory
  5. To run frontend, “npm start” in client directory
  6. Go to localhost:3000

Other Features in Stripe

  • Stripe Connect  (Enterprise/ Standard )
  • Payouts
  • Recurring Payments / Subscriptions
  • Refunds
  • Webhooks


Stripe Dashboard

stripe dashboardSample Usage in Code

stripe usage in code

Alternatives to Stripe

There are other alternatives to Stripe. Top payment gateways in the world :

  1. Stripe 
  2. Amazon Pay
  3. Pay Simple
  4. PayPal
  5. BrainTree

Payment Gateways in India

  1. Razorpay
  2. Instamojo
  3. Amazon Pay
  4. Payu
  5. Mobikwik 



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s