Building a Buy Now, Pay Later Payment Solution
Tags: webdev, tutorial, programming
Published: 2022-03-30 11:03:13

![Article image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95qhv3t1vnmv0hyrigp9.jpg)

There was a point in my life when music was the primary focus. After high school, I decided to join a few friends to give a career in music a shot. Since I have no shame, here is a photo of me during that period of my life:

![Me in 1985](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lqt4usqh06mchyuvdz6n.jpg)

If this information about me is new to you, you are likely to conclude that the dream of being a rock star did not pan out quite as I planned back in the mid-1980s. 

That desire did lead me to the [Berklee College of Music](https://en.wikipedia.org/wiki/Berklee_College_of_Music) and then to a job at a local recording studio after I moved back to Indiana while finishing college. After graduation, my career in technology began, and my focus changed. I still played music for my family and friends but had long since sold the music gear I depended on to hone my skills.

Last fall, I decided to add a piano to our home. While I enjoy the sound of a traditional piano, I couldn’t stomach the footprint required for such an instrument. My focus became a digital piano.

What I noticed during my product search was how every merchant offered some form of a “buy now, pay later” (BNPL) option for new purchases. Basically, I would pay a portion of the purchase price now, and then equal payments would be due over the following six weeks. Here is one example I found:

![Payment Options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ococ2i1e8fz408v5wl97.png)

From a technical point of view, I wanted to know how a BNPL solution is architected, so I started digging into this topic a little deeper.

## Checking in with Marqeta

Last year, I discovered the Marqeta payment platform and published the following article:

[Leveraging Marqeta to Build a Payment Service in Spring Boot](https://dev.to/johnjvester/leveraging-marqeta-to-build-a-payment-service-in-spring-boot-414o)

As a part of that endeavor, I found an API that was well-documented and easy to use. In fact, I wrote a follow-up article on how to create a rewards card program using the Marqeta service:

[How I Built My Own Rewards Card](https://dev.to/johnjvester/how-i-built-my-own-rewards-card-hbp)

In that second article, I discovered that Marqeta provides a solid foundation for adding a rewards card to your business or program opportunity. 

Based on the depth of the Marqeta platform and its impressive API, I looked there first to determine if they had something BNPL-related in their arsenal of services.

It turns out, they do.

## Designing a BNPL Solution with Marqeta

The Marqeta approach to offering a BNPL solution follows the flow illustrated below:

![BNPL Example Flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0t313khobh9w3ag6wm4.png)

1. Customer visits Some Music Place (brick-and-mortar or online)
2. Customer finds a piano and decides to purchase
3. Customer finds “buy now, pay later” to be an attractive idea and interacts with the BNPL provider. In this case, it’s a service called Afterpay.
4. Upon approval, a pre-funded virtual card is issued on the Marqeta platform and immediately used for the purchase
5. Customer takes ownership of piano without paying the full amount at the time of purchase and pays back Afterpay in installments (technically a loan).

Regardless of whether this transaction happens in a traditional music store or online, the process does not change. The sales process allows customers to select a BNPL option, which drives a short workflow to request a short-term credit line for the exact amount of the purchase. 

If approved, the BNPL provider leverages the Marqeta payment platform to create a pre-funded virtual card that can be used for a single purchase. From the merchant’s perspective, this transaction looks no different than if the customer provided a debit or credit card (Discover, Mastercard, or Visa) in person.

In fact, this same flow that I presented in my “Leveraging Marqeta to Build a Payment Service in Spring Boot” article still holds true:

![Marqeta - User to Card](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36ra873tmr2e5ykbapwt.png)

In this case, the Funding Source and Card Product aspects are linked to the BNPL provider, which establishes a card to use for payment.

The BNPL provider will then make sure the remaining payments are collected, allowing both the merchant and Marqeta to remain focused on their business functions.

## Afterpay in Action

In the example above, the market-leading BNPL service, Afterpay, partnered with Marqeta to allow the purchase to occur instantly. Since March 2020, Marqeta has been the payment partner used by Afterpay to handle their impressive growth and new product innovation. You can read more about their partnership here:

[Afterpay Selects Marqeta as its U.S. Payments Partner](https://www.marqeta.com/blog/2020/03/05/afterpay-partners-with-marqeta)

To get an understanding of the impact BNPL options have in today’s marketplace, consider these statistics related to the Afterpay service:

* 16 million customers have used Afterpay at least one time
* Top customers use the Afterpay service 48 times a year
* 90% of those who apply for Afterpay’s services are approved

It is common for merchants who offer a BNPL option to see a 20% increase in cart conversion and the average order size increases by an additional 40%. These conclusions line up with the assumption that today’s shoppers are very interested in buying items now and paying for them later.

For each of these transactions, the Marqeta platform is being utilized to provide a seamless payment experience which further contributes to a positive customer experience.

## To build or to integrate?

In the example flow above, step three focused on the interaction with the Afterpay service, which over 85,000 merchants (big and small) have selected as their BNPL partner. The service handles all aspects of establishing a short-term credit line focused on a single transaction. Then, it handles making sure the debt is repaid via four equal payments over the following six weeks.

While Marqeta is leveraged for payment processing of the initial transaction, the remainder of the Afterpay service is quite involved, which raises the question: Should I build my own Afterpay-like service, or should I integrate with a service like Afterpay?

My recommendation here is to revisit the goals and objectives of your business. If what you bring to market justifies handling these items internally, the time and materials required to build an Afterpay-like service are something to consider. If this is not the case, then consider integrating a service like Afterpay to keep your focus on your business priorities and objectives.

### Choosing Afterpay

Merchants looking to get started using Afterpay simply fill out an online form at the following URL:

https://get.afterpay.com/app/

![Afterpay Retailer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpco4i7uss3t3cmzi75c.png)

From a cost perspective, expect to pay 30 cents (USD) per transaction and a 4-6% commission fee. While the transaction fee is similar to other services like PayPal, the commission fee is highest between Afterpay, PayPal, and major credit cards.

Merchants should keep these costs in mind and understand the return-on-investment (ROI) before moving forward with the Afterpay service.

### Moving Forward On Your Own

The alternative to using a service like Afterpay is to build your own BNPL solution. In this scenario, the use of the Marqeta service does not change. It is still the recommended approach for handling the original purchase transaction.

In fact, the flow remains the same with Marqeta. It is only the funding account owner that changes:

![Marqeta - BNPL Roll Your Own](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gb5zzpyjtiqrlygq388j.png)

Instead of the customer providing a funding source (when making a purchase), your business (the one which is creating its own BNPL service) would establish the funding source to be used to purchase products from a participating retailer.

Once the purchase is made, it is up to your business to manage and track the other aspects involved. Some high-level items to consider include:

* Initial contact creation (customer agrees to terms)
* Requesting and protecting payment information
* Tracking the payment schedule
* Handling accounts payable and collections
* Cost to develop, support, and maintain a custom-build solution 

Similar to the decision to leverage a service like Afterpay, businesses should evaluate the cost to build a competing product in order to estimate when the service will begin to provide an additional revenue stream.

## Conclusion

Since last year, I have been trying to live by the following mission statement, which I feel can apply to any IT professional:

> “Focus your time on delivering features/functionality which extends the value of your intellectual property. Leverage frameworks, products, and services for everything else.”
> - J. Vester

In this example, merchants who wish to offer customers flexible payment options can leverage the Afterpay service. They also have the option to build their own BNPL service and let Marqeta handle the payment processing functionality. Either approach leverages an existing service to keep engineering teams focused on meeting their own business needs or requirements.

But that’s not where this story ends… 

As I found with my prior publications, Marqeta provides a payment platform that offers a hands-off approach for financial transactions. In this case, the Marqeta service is instrumental in allowing services like Afterpay to complete that initial purchase so that the customer walks away with a seamless transaction. This means that the Afterpay team can remain focused on writing new features and functionality in their applications, which adheres to my mission statement 100%. 

If your application or service has payment-related needs and you are not currently utilizing the Marqeta platform, then I highly recommend adding this platform to your shortlist of providers to review.

To finish the story in my introduction, despite the flurry of online options for my digital piano purchase, I ended up buying a [Kawai](https://kawaius.com/product/kdp120/) digital piano from [Piano Solutions](https://www.pianosolutions.net/), a local merchant close to my home:

![Kawai Digital Piano](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4rf1ypn3amt74m0a1cy.jpg)

While at the store, I was given the opportunity to sit behind a [Yamaha CFX](https://usa.yamaha.com/products/musical_instruments/pianos/premium_pianos/cf_series/index.html) grand piano which was listed at a price four times higher than the list price of our brand-new 2022 [Nissan Pathfinder](https://www.nissanusa.com/vehicles/crossovers-suvs/pathfinder.html). While I cannot decide if the CFX grand piano is worth that amount of money, I can tell you that it was the best piano-playing experience I have had in my life … and it made me feel like a rock star.

Have a really great day!