I tried Stripe's one-click payment Link in Magento2

# Table of Contents

1. Introduction
2. Environment
3. What is one-click payment Link by Stripe?
4. Link by Stripe in Magento2
5. Payment testing Link by Stripe
6. Payment failure....?
7. Reason of a failure
8. Conclusion

# Introduction
https://github.com/stripe/stripe-magento2-releases/pull/52/files

The stripe has released it's latest version 3.5.11 today. As soon as I got to know this, I decided to try to test in my local Magento2 server. When I read the Changelog in the official site of stripe, I was really excited by the following lines:
```
Fixed an issue with Link where if the 'Save payment method' is enabled, orders placed with Link would fail.
```
As I was having trouble with the stripe's one-click payment Link which I already been reported to the stripe's development team. From on I haven't got any reply from them. But for now I'm very excited to test this latest version, hope it will fulfill my expectations. The purpose of this testing is to check whether the previous issue(Stripe's one-click payment Link) I have raised to stripe's development team has been resolved or not.

# Environment
| Environment | Version |
|:-:|:-:|
| Magento  |  2.4.6-p4 |
|  Php |  8.2 |
| [StripeIntegration module](https://github.com/stripe/stripe-magento2-releases/tree/master)  | 3.5.11  |

# What is one-click payment Link by Stripe?
Stripe has provided a new payment solution known as one-click payment [Link by Stripe](https://stripe.com/en-hu/payments/link). Link by Stripe is a powerful payment feature of the payment gateway Stripe that helps to create a frictionless checkout experience for your buyers.

![Screenshot 2024-02-16 at 13.16.04.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/9f333e0d-20cb-094c-f0d9-3d762e891191.png)


Link saves, encrypts, and autofills saved payment and shipping information for your customers, creating a speedy and friction-free checkout experience.
Once their data is saved, the customers can now make one-click payments on any sites that have Link enabled, without needing to create an account officially on a site.

1 out of 5 customers abandon their carts, because of the long and complicated checkout process. And 30-35% of transactions are not completed because the website requires their user to create an account before checking out. With its 5-6 second checkout process, here is what exactly Link by Stripe lends you a helping hand!

# Link by Stripe in Magento2
First download the latest version of StripeIntegration from the official site.

https://github.com/stripe/stripe-magento2-releases/tree/master

After downloading the latest version of stripe, place this module inside the app/code. The general setting about api key are done as per your needs. The Stripe Payments v3.5.8 and greater depends on the Stripe PHP library v12.7 or newer. So you need to update the Stripe PHP library v12.7 or newer. I have already set to latest v13.0.0.
Before proceeding the operation verification, lets do some initial setups regarding to the Link in the stripe.

In Magento2 admin panel section, you need to set [Wallet Button] -> [Enabled]. And other settings like where to display the Link button.

![Screenshot 2024-02-16 at 13.22.27.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/170d8aa1-a54a-d7a6-f7a3-720e7131ca4c.png)

But in case of Stripe Dashboard first login to your Stripe account. You can then enable the Link payment method in the "Payments / Payment methods" section of the "Settings" page in your Stripe Dashboard:

![Screenshot 2024-02-16 at 12.36.57.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/0f81f7e8-1858-e13e-5665-d1f7e6e114e8.png)

By clicking the Payment methods you can view the "Wallets" category. Simply just turn on the Link.

![Screenshot 2024-02-16 at 12.39.48.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/35ed8367-4258-6206-cfea-1c360d09c4e4.png)

Once the Link by Stripe is in Active state, you can then view the description about Link Payment Method as follows:

![Screenshot 2024-02-16 at 12.46.22.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/308827ab-050b-e34d-fa26-10c9bd564c8c.png)

Next is, to configure the Link payment method in the "Payments / Link settings" section of the "Settings" page in the Stripe Dashboard:

![Screenshot 2024-02-16 at 13.43.30.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/6e5da7f1-ae69-e72f-c32a-23618074d436.png)

Depending on your need you can configure how the Link is displayed as a request button on your site:

![Screenshot 2024-02-16 at 13.37.17.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/d3faa859-87a3-cdd0-69eb-68f743a6872d.png)

After completing above setting this is how it is displayed in Magento2 checkout payment page:

![Screenshot 2024-02-16 at 13.51.43.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/16572905-88bf-c4df-9bca-f85066b614d1.png)

After clicking Link button it will pop up like this:

![Screenshot 2024-02-16 at 13.52.47.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/1cbe29db-b40d-5779-dbca-d896245524ef.png)

Lets move on the payment testing of Link by Stripe in Magento2.

# Payment testing Link by Stripe
Lets add test product to the cart. After adding to the cart we will proceed to the checkout page.

![Screenshot 2024-02-15 at 15.24.40.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/2bef8b63-bca9-0f95-0fcf-d2068232ff7d.png)

![Screenshot 2024-02-15 at 15.24.52.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/010356b8-560b-9aac-58cb-6d88ecfd2325.png)

On the checkout page enter all the required shipping information, select desired Shipping Methods and click on [Next] button.

![Screenshot 2024-02-16 at 14.02.21.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/c838b4e5-6e81-dded-b739-8bda95495f34.png)

![Screenshot 2024-02-16 at 14.02.31.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/4b0799a9-31e8-7b41-2ea5-2d0475582ab2.png)

The checkout payment displays all the payment methods along with the Link by Stripe.

![Screenshot 2024-02-16 at 14.20.29.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/d1580753-9aa5-2a91-cf41-ea0797dda183.png)

Here we are going to test is Link by Stripe, so simply click [Pay with link] button. The pop-up occurs for the login process.

![Screenshot 2024-02-16 at 13.52.47.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/f89c3c05-6621-eeef-533d-7e2f971e1c6f.png)

Enter your login details here. As I have already created account so I will enter my login information.

When the buyer uses Link by Stripe on a new site or new device, they’ll receive a one-time code via SMS to verify their identity and keep their payment information secure:

![Screenshot 2024-02-16 at 14.54.31.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/0d2c2167-a61c-50af-376b-3210ad1ea185.png)

After entering the SMS code, the authentication succeeds and a confirmation dialog is displayed to approve the purchase:

![Screenshot 2024-02-16 at 14.59.28.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/e7524f33-7b76-9b8b-f0d9-0fcfc0848850.png)

Lets place order to check if it will succeed or not. By clicking on [Pay] button the following will display:

![Screenshot 2024-02-16 at 15.19.42.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/5521a8c1-5057-9ead-d67e-b97ac36b2aac.png)

![Screenshot 2024-02-16 at 15.17.24.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/90898ca2-75af-8c71-f3dd-75c77fca1dbd.png)

We can now confirm that the payment process has been successfully completed with an ease of time.

# Payment failure....?
I thought the Link by Stripe was successful in all cases. But there is a time when payment failure occurs as well. I thought it was corrected by the stripe's development team.
The successful payment made was when it was placed from the Checkout page. But by placing order from Product Pages, Minicart, Shopping cart page it was a failure with some error.
Lets try to place order from any of these Product Pages, Minicart, or Shopping cart page.
I am going to test from Product Pages.
Click on any of the product. I have selected the following product with **Size** and **Color**.

![Screenshot 2024-02-16 at 17.41.25.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/99bb8c35-32d2-bc83-1cd5-c139fdf0f5fb.png)

Simply clicking on **Link** button will pop-up the Link payment page:

![Screenshot 2024-02-16 at 17.18.42.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/18b8b502-441e-acb8-da1d-89cbbbb810ae.png)

Entering your log in email id and sms code will display like this:

![Screenshot 2024-02-16 at 17.50.11.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/dd303937-473e-21c2-89a1-147f4243661d.png)

By clicking Pay button will display both **Payment complete** message and **Error** message simultaneously. Unfortunately the payment was a failure.

![Screenshot 2024-02-16 at 18.01.21.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/51b6e927-c8ed-c2e5-61c1-b03bf08c2b26.png)

# Reason of a Failure
I further tested in various conditions and finally I came to know that this error will occur if I enter full name in japanese(hiragana or katakana) in the Shipping Address.

![Screenshot 2024-02-16 at 18.25.43.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/c8ee43d4-f0cf-d968-3131-bbb3d5bc8b26.png)

But if you enter full name in English format the payment has been successful. Currently I don't know the reason but I need to further investigate on this issue.

![Screenshot 2024-02-16 at 18.31.48.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/327994/6887d939-554a-a4b0-5c38-5cdaa58ea738.png)


# Conclusion
The Link by Stripe is the most convenient payment method provided by the Stripe. It is also one of the secure and the fast payment method to check out in just 5-6 seconds. You can proceed this payment from various places depending on the settings such as: Product Pages, Minicart, Shopping cart page, Checkout page as well. It has a feature to allows the customers to save their checkout information so that the next time they check out, their info will autofill and purchasing will be a click away using only a one-time authentication code sent to their mobile device.
It is helpful because of making checkout as quick as possible decreases cart abandonment and increases conversions.
By performing payment test using this method, I really felt it is indeed one of the fast payment method.
Further I wish if the stripe development team would notice this strange issue and will this issue be resolved soon. Lets have a faith in stripe for now! 🤞