Development Guide
Process for Merchants
Based on the Merchant’s environment, a merchant may process a payment via backend access . Payment scenarios include payments requiring password-verification and payments that are exempt from password-verification.
Access Mode - Merchants' Backend Access
This mode is applied to merchants who are equipped with a unified backend. In this mode, the Cashier communicates with the merchant’s backend first and the backend will subsequently send transaction requests to and receive results from the Trusty payment system.
Native Payment
Native Payment means that the merchant generates a collection QR code corresponding to the order according to the order information, and the user opens the Trusty Pay client and selects + in the top right corner > Scan to scan the payment code to complete the payment.
Native Payment is applicable to both online and offline scenarios. Offline scenarios usually refer to offline restaurants and convenience stores, etc. while online scenarios refer to Trusty Pay collection on PC websites.
The merchant can display the collection QR code on the offline POS or screen or on the online PC website for users to scan.
|
Application Scenario |
Scenario Description |
Problem to Fix |
|---|---|---|
|
Offline restaurants and convenience stores, etc. |
The merchant generates a QR code corresponding to a single order on the POS machine and shows the QR code to the user, and then the user completes the payment after scanning the QR code through the Trusty Pay client. |
Meeting the requirement of the offline Trusty Pay checkout scenario, and providing solutions for some POS machines without any code scanning device |
|
Online PC websites |
The merchant's online PC mall generates a collection QR code based on the specific amount of the order placed by the user and displays it on the PC webpage. The user scans the QR code thorough the Trusty Pay client to complete the payment, and the merchant displays the order payment result on the PC webpage. |
Since Trusty Pay does not provide a PC client, this product can solve the problem of accessing Trusty Pay in PC scenarios |
1. Processing flow
The Merchant's backend calls the 【Unified Order】 and the Trusty payment system returns appUrl to the Merchant's backend to create a QR Code. The Payer scans the QR Code in Trusty Pay App to initiate payment.
Notes:
-
appUrl is valid for up to 30 minutes(can be set in 【Unified Order】). The Payer can't scan the QR Code to pay again once it has expired.
Service steps:
-
The Merchant's backend creates an order based on the product selected by the Payer.
-
The Payer confirms payment and the Merchant calls the Trusty payment system 【 Unified Order 】 to create an advance payment transaction.
-
Trusty payment system creates an advance transaction bill upon receiving this request, and returns appUrl.
-
The Merchant’s backend creates a QR Code based on appUrl.
-
The Payer opens “Scan QR Code” in Trusty Pay App and scans the QR code. The scanned data is sent to the Trusty payment system from the Payer's Trusty Pay App.
-
The Trusty payment system receives the request from Trusty Pay App and verifies the URL. If the URL is verified to be valid, payment is initiated and requires the Payer's authorization.
-
The Payer enters their payment password and confirms payment in Trusty Pay App. The payment authorization is submitted to the Trusty payment system from Trusty App.
-
The Trusty payment system completes the transaction based on the Payer's authorization.
-
The Trusty payment system returns the transaction result to the Payer's Trusty Pay via SMS after the payment is done. The Payer can view the payment result in their Trusty Pay App.
-
The Trusty payment system sends an asynchronous message to inform the Merchant's backend of the payment result. Then Merchant's backend replies to inform the Trusty payment system the payment is completed.
-
The Merchant’s backend polls the 【 Query Order API 】 if no payment message is received.
-
The Merchant confirms the order and delivers products to the Payer.
2. Generate QR code rules
Corresponding link format: jl-app://customer/TrustyPay?ordId=xxxxxx. Merchants are requested to call the third-party library to generate QR code images appUrl.
For example, the jl-app://customer/TrustyPay?ordId=xxxxxx will generate a QR code as shown in the image.
In-App Payment
In-App Payment means that the Trusty Pay user selects goods and places orders in the merchant's App, and selects Trusty Pay at the payment stage. Then the Trusty Pay client will be pulled up from the merchant's App, and the system will automatically redirect back to the merchant's App after the user completes the payment in the Trusty Pay client.
|
Application Scenario |
Scenario Characteristics |
Problem to Fix |
|---|---|---|
|
Online retailers, catering takeout, etc. |
Pure online scenario, where the merchant must have developed an App and Trusty Pay is accessed in the App. |
Scenarios where an App has been developed to access Trusty Pay |
1. Processing flow
Users purchase goods in the merchant app client and place an order.The Merchant's backend calls the Unified Order and the Trusty payment system returns appUrl to the Merchant's backend , Merchant's backend return appUrl to Merchant's APP, Merchant's APP redirects the user to the appUrl(Trusty Pay App).After the user completes the payment on the Trusty App, on the payment result page, the user clicks the 'Back' button to jump to the merchant APP order payment result page .
Service steps:
-
The user initiates a payment request in the Merchant App (e.g., by placing an order).
-
The Merchant App calls the Merchant backend order creation interface.
-
Merchant's backend calls the 【Unified Order API】 .
-
Trusty Payment system returns the unified order result (containing fields like TradeNo, appUrl, etc.)
-
Merchant's backend returns the unified order result to the Merchant App.
-
Merchant App redirects the user to the appUrl (Trusty Pay App).
-
Trusty Pay App calls the Trusty Payment system to validate the payment parameters and returns the payment interface to the user.
-
The user completes the payment operation within the Trusty Pay App (e.g., by entering a password or using fingerprint verification).
-
Trusty Payment system processes the payment request, performing operations such as deducting the payment amount.
-
Trusty Payment system sends an asynchronous payment result notification (callback) to the Merchant's backend.
-
Merchant's backend system receives the notification, verifies the signature, updates the order status, and returns a successful response to Trusty Payment system.
-
Trusty Payment system notifies the Trusty App of the payment result.
-
Trusty App displays the payment result and redirects back to the Merchant App.
-
The Merchant App calls the Merchant Server to query the order status (optional, to ensure consistency).
-
The Merchant Server returns the order status to the Merchant App.
-
The Merchant App displays the final order/payment result to the user.
1. Android Platform Implementations
1.1 Kotlin Implementation
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(trustyapp_url))
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(intent)
} else {
// No trusty app found
}
1.2 Java Implementation
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(trustyapp_url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
} else {
// No trusty app found
}
2. iOS Platform Implementations
2.1 Add URL schemes to Info.plist under LSApplicationQueriesSchemes
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- for production environment -->
<string>jl-app</string>
<!-- for UAT environment -->
<string>jl-app-uat</string>
</array>
2.2 Swift Implementation
UIApplication.shared.open(trustyapp_url, options: [:]) { success in
if !success {
// Failed to launch the trusty app
}
}
2.3 Objective-C Implementation
[[UIApplication sharedApplication] openURL:trustyapp_url options:@{} completionHandler:^(BOOL success) {
if (!success) {
// Failed to launch the trusty app
}
}];