Google Pay India(UPI) 印度
印度市場獨有的UPI 實現Google Pay
一、官網地址(科學上網)
官方對接文件 http://developers.google.com/pay/india/api/android/googlepay-business 官方Dome--GitHub地址 http://github.com/googletez/inapp-payment-samples
二、主要程式碼實現(整合挺簡單)
``` String GOOGLE_PAY_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user"; int GOOGLE_PAY_REQUEST_CODE = 123;
Uri uri =
new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "[email protected]")
.appendQueryParameter("pn", "your-merchant-name")
.appendQueryParameter("mc", "your-merchant-code")
.appendQueryParameter("tr", "your-transaction-ref-id")
.appendQueryParameter("tn", "your-transaction-note")
.appendQueryParameter("am", "your-order-amount")
.appendQueryParameter("cu", "INR")
.appendQueryParameter("url", "your-transaction-url")
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);
intent.setPackage(GOOGLE_PAY_PACKAGE_NAME);
activity.startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE);
**_對應解釋_**
Uri uri =
new Uri.Builder()
.scheme("upi")
.authority("pay")
.appendQueryParameter("pa", "您的商家[email protected]") //使用者付款到的賬戶
.appendQueryParameter("pn", "您的商家名稱") // 支付顯示的名稱
.appendQueryParameter("mc", "您的商家程式碼")
.appendQueryParameter("tr", "您的交易參考編號")// 理解為訂單ID
.appendQueryParameter("tn", "您的交易記錄")
.appendQueryParameter("am", "您的訂單-amoun") // 交易金額
.appendQueryParameter("cu", "INR") //固定
.appendQueryParameter("url", "您的交易網址")
.build();
**_返回資料_**
支付錯誤原因 Google Pay會自己顯示
支付錯誤資料 txnId=&responseCode=ZD&Status=FAILURE&txnRef=123456789
支付成功資料 txnId=ICI5749db96b6ed47f1bc469c80981f9387&responseCode=0&Status=SUCCESS&txnRef=123456789
private void googlePayResult(Intent data){
if (data != null) {
String response = data.getStringExtra("response");
Map
} else {
showFinalFailDialog("");
}
} else {
showFinalFailDialog("");
}
}
```
三、遇到的坑(最難解決的卡)
1、配置Google Pay for Business
先決條件
商業渠道必須接受UPI並經NPCI /銀行驗證為商家。
確保您具有在銀行使用UPI ID接受付款所需的詳細資訊。
確保您擁有銀行提供的所有必需的API,以檢查付款狀態。
請注意,每個交易都應使用唯一的交易ID。
一定要有許可權的提前配置好自己的UPI ID 需要稽核好幾天~~~~~配置地址
2、測試(血的教訓)
1. 一定要下載印度版本的Google Pay~~~印度 Google Pay~~~
2.使用正確的Google Pay 賬戶 ``` 使用印度Google Pay賬號一定要配置好的東西: 1. 安裝Google Pay的手機 2. Google Pay賬號 3. 印度手機號 4. 與該手機號繫結的能開通UPI的銀行卡 5. 手機插卡,登入Google Pay,繫結銀行卡,啟用UPI
``` 賬號準備好以後,測試會非常順溜,祝你成功
希望可以幫助遇到同樣問題的你😁😁😁😁 如有建議和意見,請及時溝通。