Document Status | IN REVIEW |
---|---|
Document Owner(s) | |
Reviewers |
✅ Proposed Solution
Frontend - MB WAY
After selecting the MBWay payment method, we will implement two new screens for the user to enhance their payment experience.
Create a mb way payment method
This screen will provide the user with clear instructions on how to complete their payment using MBWay.
It will include:
A brief overview of the MBWay payment process.
A field for the user to enter their phone number. This phone number is crucial, as it will be used by Paycomet to create the payment request in the user's MBWay account.
A "Confirm" button for the user to proceed after entering their phone number.
A regex to validate phone number input (only for ES and PT)
The user can fill with only phone number ( PT Example )
User Input: 98333 0099 (no spaces)
Input Mask: 98333-0099
Final Result: 351983330099
The user can fill with ISO Country Code and phone number ( PT Example )
User Input: 351 98333 0099 (no spaces)
Input Mask: +351 98333-0099
Example: 351983330099
Create a component to be used in payment page and recent orders
This screen will notify the user that their payment request has been successfully created.
It will include:
A message indicating that the payment request is pending and that the user should complete their payment via the MBWay app.
Information on the payment details such as the amount to be paid.
A countdown timer displaying the remaining time for the user to complete the payment.
Instructions on what to do if they need to cancel the order.
Additionally, an order polling process will be implemented on this screen to continuously check the payment status.
The polling will detect when the payment status changes to
(PAYMENT_SUCESSFUL, INSERT_SUCESSFUL and UPDATE_SUCESSFUL)
.Upon successful payment, the user will be automatically redirected to the
/order-confirmation
screen, where they will receive confirmation of their order and further instructions.
Frontend - Payment Tracking
After the user makes a payment request and closes the app, we need to ensure the user knows what happened to their order. This is a page to which the user will be redirected when there are pending payments available.
Remember that waiting for payment is a feature for all payment methods, but for it to be displayed, two conditions must be met:
The order must not be paid yet. (PRICE_SUCESSFUL and PAYMENT_REQUIRED)
The request must contain the
paymentRequestCreatedAt
property in thepayment
property.
Create Reusable Waiting Payment Page for order pending
This page reuses the same component as the mb payment details ensuring that users are familiar with the layout and can easily find the information they need. The primary objective of this page is to offer users comprehensive details about their pending MBWay payments, in scenarios where they might have closed the whitelabel app during the payment process. It helps clarify the payment status and guides users on completing their transactions successfully.
Importantly, only the most recent pending order will be displayed to the user, focusing their attention on the latest transaction.
Backend
Create Payment Request
To create a payment request for MBWay, it is necessary to add a new endpoint called InitiatePayment
that handles the initialization of a new payment. Unlike the GenerateCheckoutLink
, which is used for other payment methods, in the case of MBWay, we will not generate a link. Instead, we will request Paycomet to create a payment request in the customer's MBWay account.
The InitiatePayment
endpoint was created specifically for this purpose: to request or initiate a payment that will be processed outside the whitelabel.
For this communication, it is necessary to transmit two important pieces of information to the Paycomet service: the amount
and the cellphone
. The cellphone
will be used by Paycomet to create a request in the user's MBWay account. Once the data reaches the Paycomet service, we will create a payload as mentioned below for the /payments
endpoint of Paycomet.
With this, Paycomet will return whether the request was created or not, allowing us to handle this data at the beginning of the request in the frontend, ensuring direct communication of the responses. If the endpoint returns success, it means that the user received a payment request. Otherwise, the user did not receive any request, and we should inform the user to try again, either because they entered an unregistered number or due to an issue on Paycomet's side.
Retrieve Payment Status
The retrieval of payment status data is performed through an order polling process that waits for the order to reach the status: PAYMENT_SUCCESSFUL
. To facilitate this process, we utilize a webhook in the Paycomet service, which is triggered whenever the payment status is updated in the Paycomet payment service provider.
When the Paycomet service receives this information about the status change, it will trigger the payment services to notify that there has been a change. This will, in turn, trigger all other services so that the order is updated in the database and this information is reflected on the frontend.
Development
This section includes some code examples that will be developed. The examples serve as a guide for development, and good practices as well as testing should be adopted.
New payment method support
This first stage involves adding the main foundation for the new payment method. Since this task is repeated for all new payment methods, I will only provide the reference for each stage. This should be the first part of the frontend development; without it, it will not be possible to continue with the development of the subsequent screens.
Add new payment method icon
This task involves adding the icon to be used later by the whitelabel
ref: https://github.com/rbilabs/ctg-components-library/pull/399
Create a new feature flag
This task aims to create the feature flag in both launchdarkly and whitelabel
ref: - IBFEC-1758Getting issue details... STATUS
time: 1h
Add the new payment method in the payment state and structure
This task aims to create the mbway in payment state and structure
ref: - IBFEC-1761Getting issue details... STATUS
time: 8h
Add the new method in payment-method structure and payment list
This task aims to add mbway to the payment dropdown
ref: - IBFEC-1760Getting issue details... STATUS
time: 2d
Adjust the receipt email to show the correct message for the new payment method
This task aims to adjust the email to include mbway as a payment method
ref: - IBFEC-1765Getting issue details... STATUS
time: 2h
Setup MBWay Payment
This is the second stage of the development tasks in the frontend. This phase involves the development of MBWay, where the screens and payment handling will be developed.
Create a mb way payment method
This is the first payment screen via MBWay. After selecting this payment method from the dropdown, the screen with the phone number input field should appear. This involves both the development of the screen and the validation and masking of the input.
It is important to note that the development of this form will be reused in the new MBWay Pending Payments page.
Handle Fulfillment Initiate
This task focuses more on handling the information after the user enters the phone number and clicks "Continue." This stage involves communication with the "Initiate Payment" endpoint and returning the result. Additionally, this screen includes the invocation of the error modal.
Handle Commit Order
This task covers the order commit, where we will add a new field called paymentRequestCreatedAt
, which will be responsible for recording when the payment request was generated. This field will be used in the future on the "Waiting for Payment" screen. It is important to remember that saveCommitOnly
must be enabled for the order commit in the backend to be activated.
Even though we are just requesting a payment, we must place the order so that we can receive the transaction data in the psp-service notification endpoint. Without this, the order will never be completed.
Payment Pending Tracking
Tracking Page
This task involves handling the information for the "Waiting for Payment" screen when the payment request is made. Therefore, a generic screen should be developed that can be used by other future payment methods. Additionally, this screen should be displayed when the user closes the app and returns to the homepage, as long as there is still an active payment to be completed.
Backend
Packages
This task aims to add mbway to the payment method enums
Commit Order Graphql/Fulfillment
This task aims to add mbway to the payment method enums and modify the commit order to accept this new payment method, in addition to including the new field: "paymentRequestCreatedAt"
Create a new request to Graphql/Fulfillment to handle MB Way on Initiate Endpoint
This task aims to add the paycometCaptureContext field to the initiatePayment endpoint
Implementation example: https://github.com/rbilabs/intl-whitelabel-graphql/pull/1150
Create a new endpoint in Paycomet PSP Service
This task aims to create the initiatePayment endpoint on paycomet psp and also its functionality.
Admin App
Adding mbway within the translation enum so that the Admin App knows this new payment method and selects the correct translation.
DOP
Adding mbway within the translation enum so that the DOP knows this new payment method and selects the correct translation
Expeditor Tablet
Adding the mbway inside the enum so that the expeditor tablet knows this new payment method.
Potential Challenges
The most complex part was understanding the payment flow via endpoint and how we would achieve the result of creating the initiate payment. Since this solution does not involve an iframe, it will slightly change the way this payment method is developed and how it handles edge cases.
Another problem was dealing with the fact that we cannot cancel an MB Way payment, only the user has the power to do that. This caused some user experience difficulties in the whitelabel solution, where the user, even outside the payment page, can still complete the payment if they are within the allowed time.
🎛️ Configuration
LaunchDarkly
Feature Flag |
---|
enable-mbway-payment |
🧑🚒 QA Plan
Test Scenario | Steps | Screenshots |
---|---|---|
SCENARIO 1: The user makes a payment |
| |
SCENARIO 2: The user makes a payment and closes the whitelabel app ( Delivery ) |
| |
SCENARIO 3: The user makes a payment and closes the whitelabel app ( Pickup ) |
| |
SCENARIO 4: The user makes a payment, closes the whitelabel app, doesn't pay in the MB Way app, opens the whitelabel app, the payment is still valid and user is redirect to waiting payment page. |
| |
SCENARIO 6: The user enters an incorrect phone number |
| |
SCENARIO 7: The user makes a payment and the time limit expires |
| |
SCENARIO 8: The user makes a payment and cancels in the MB Way app |
| |
SCENARIO 9: Guest receives the email after placing the order |
| |
SCENARIO 10: The support tool user can see the order receipt |
| |
SCENARIO 11: The DOP user can see the order receipt |
| |
SCENARIO 12: The DMP user can see the order receipt |
| |
SCENARIO 13: Make a refund in the support tool |
| |
SCENARIO 14: Make a partial refund in the support tool |
| |
SCENARIO 15: Make a refund in DMP |
| |
SCENARIO 16: Autorefund |
| |
SCENARIO 17: Phone input error |
| |
SCENARIO 18: Payment Refused |
| |
SCENARIO 19: Payment Refused by time expired |
| |
SCENARIO 20: Insert a phone number without iso code country |
| |
SCENARIO 21: Insert a phone number with iso code country |
|
How to test
Unfortunately, Paycomet does not provide a way to perform tests in a development environment. Therefore, it will not be possible to conduct an end-to-end test of this new feature. What will be described below is a way to simulate a response from Paycomet when the payment is completed in MB Way App.
Make a Payment
The first step is to follow the happy path flow of the payment method, that is, choose an order, go to the checkout screen, fill in the necessary information, select the MB Way payment method, enter the phone number: "351 931301715
" and click on pay. After that, you will be redirected to the MB Way waiting screen, and now you need to proceed to the next step.
Make a request to notification in paycomet-service
Below you will find an example of how to create the notification request to the endpoint. After creating this request, make a call to the Paycomet service at the notification endpoint. If the request is correctly created, the order status will be updated to success, and the Whitelabel app will redirect the user to the order confirmation screen.
{ "AccountCode": "", // AccountCode (can be found in paycomet logs) IMPORTANT "Amount": 2146, // Amount (can be found in paycomet logs) IMPORTANT "AmountEur": 21.46, "AuthCode": 341348, // Amount (can be found in paycomet logs) IMPORTANT "BankDateTime": 20240814195535, // !BankDateTime (can be found in paycomet logs) IMPORTANT "BicCode": "BSABESBBXXX", "CardBrand": "VISA", "cardCategory": "CONSUMER", "CardCountry": "ES", "cardType": "CREDIT", "ClearanceDateTime": 20240814195535, "Currency": "EUR", // Currency (can be found in paycomet logs) IMPORTANT "DCC_Amount": "", "DCC_Currency": "", "DCC_CurrencyName": "", "DCC_EcbPercentage": "", "DCC_ExchangeRate": "", "DCC_Markup": "", "ErrorDescription": "", // ErrorDescription (can be found in paycomet logs) IMPORTANT "ErrorID": 0, // ErrorID (can be found in paycomet logs) IMPORTANT "ExtendedSignature": "", // ExtendedSignature (can be found in paycomet logs) "IdUser": 00000000, // IdUser (can be found in paycomet logs) "Language": "es", "MethodId": 1, "MethodName": "", // MethodName (can be found in paycomet logs) "NotificationHash": "", // Paycomet Service has the validatePaymentHash // function to help you create the hash IMPORTANT "Order": "", //rbiOrderId (can be found in paycomet logs) IMPORTANT "paycometId": 00000000, // PaycometId (can be found in paycomet logs) "Response": "OK", "SecurePayment": 1, "sepaCard": 1, "Signature": "", // Signature (can be found in paycomet logs) "TokenUser": "", // TokenUser (can be found in paycomet logs) "TpvID": 0000, // TpvID (can be found in paycomet logs) IMPORTANT "TransactionName": "Autorización", "TransactionType": 1 // TransactionType (can be found in paycomet logs) IMPORTANT }
0 Comments