![](/img/trans.png)
[英]Getting error while Google Pay integration in android app – UPI Payment
[英]Google Pay(Tez) Integration into my payment gateway ? (Android)
注意:我知道它尚不支持iOS,而且我也沒有在尋找Xamarin.Forms(很明顯)。
當我意識到沒有可用的將其集成到Xamarin
指南時,我一直試圖將Google Pay(Tez)
API集成到我的Xamarin
應用程序中。
因此,我訪問了Google Pay API頁面,該頁面似乎有一個不錯的Android(Java)
指南,因此我開始將本機Android代碼轉換為Xamarin
。 然后我遇到了一個麻煩,即Xamarin中似乎無法使用PaymentsClient類,因此我嘗試檢查其命名空間,以便也許我可以了解它是否可用( Xamarin.Android
)。 但是沒有提到此類的名稱空間(我沒有注意到)。 我只能在它的信息中找到它繼承自com.google.android.gms.common.api.GoogleApi
,但實際上並沒有幫助。
查詢
Xamarin
使用了其他替代方法? Xamarin
應用程序的Google pay(Tez)API? VS17 Pro
版本15.6.7
, Xamarin
版本4.9.0.753
和Xamarin.Android
版本8.2.0.16
Android SDK最新,且所有API版本均高於v 4.0 Package: `Xamarin.GooglePlayServices.Wallet`
確保通過清單中的metadata
或應用程序的MetaDataAttribute
啟用應用程序進行電子錢包處理:
[Application]
[MetaData(name: "com.google.android.gms.wallet.api.enabled", Value = "true")]
從那里開始using Android.Gms.Wallet;
並設置並使用PaymentsClient
,即。
PaymentsClient paymentsClient = WalletClass.GetPaymentsClient(
this,
new WalletClass.WalletOptions.Builder()
.SetEnvironment(WalletConstants.EnvironmentTest)
.Build()
);
要將交易信息傳遞給“ Tez”,請定義一個URI,其中包括您所有的商家信息,交易金額等。此URI基於UNIFIED PAYMENTS INTERFACE UPI
方案(此不受Google的控制,因此您請參閱UPI規范以了解需要傳遞的數據)。
回復: https : //www.npci.org.in/sites/all/themes/npcl/images/PDF/UPI_Linking_Specs_ver_1.5.1.pdf
using (var uri = new Android.Net.Uri.Builder()
.Scheme("upi")
.Authority("pay")
.AppendQueryParameter("pa", "your-merchant-vpa@xxx")
.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 = new Intent(Intent.ActionView);
intent.SetData(uri);
intent.SetPackage("com.google.android.apps.nbu.paisa.user");
StartActivityForResult(intent, 9999);
}
然后,您當然可以實現OnActivityResult
的替代並處理結果:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (requestCode == 9999)
{
Log.Debug("tez result", data.GetStringExtra("Status"));
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.