将Google Pay(Tez)集成到我的付款网关中? (安卓) [英] Google Pay(Tez) Integration into my payment gateway ? (Android)

查看:520
本文介绍了将Google Pay(Tez)集成到我的付款网关中? (安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意::我知道它不适用于iOS,而且我也没有在寻找Xamarin.Forms(很明显).

Note : I am aware it is not yet available for iOS, Also i am not looking for Xamarin.Forms(Obviously).

当我意识到没有可用的将其集成到Xamarin的指南时,尝试将Google Pay(Tez) API集成到我的Xamarin应用程序中.

Been trying to integrate Google Pay(Tez) API into my Xamarin Application when I realised that there are no guides available for its integration to Xamarin which is fine.

因此,我访问了 Google Pay API 页,其中似乎对Android(Java)有很好的指导,所以我开始将本机Android代码转换为Xamarin.然后我碰到了一个 PaymentsClient 类似乎在Xamarin中不可用,所以我尝试检查其名称空间,以便也许我可以了解它是否可用(Xamarin.Android).但是没有提及此类的名称空间(我没有注意到).我可以在其信息中找到的只是它是从com.google.android.gms.common.api.GoogleApi继承而来的,而实际上根本没有帮助.

So, I visited the Google Pay API page, Which seems to have a sweet looking guide for Android(Java) so I started converting the native Android code into Xamarin. And then I hit a bump where the PaymentsClient class seems to be unavailable in Xamarin, So I tried checking for its namespace so maybe I could understand if it was available or not(Xamarin.Android). But there is no mention of the namespace of this class(None that I noticed). All I could find in its info is that it inherits from com.google.android.gms.common.api.GoogleApi which did not help at all actually.

查询

  • 我在这里缺少某些软件包吗?还是在Xamarin中使用了某些替代方法?
  • 是否有一些指南针对我错过的Xamarin应用程序集成Google pay(Tez)API?
  • Xamarin.Android中是否尚未添加Google pay(Tez)集成?
  • 或者我当前的配置有问题吗?即VS17 Pro版本15.6.7Xamarin版本4.9.0.753Xamarin.Android版本8.2.0.16 Android SDK最新,且所有API版本均高于v4.0
  • Am I missing some package here or is there some alternative that is used in Xamarin?
  • Is There some guide to integrating Google pay(Tez) API for Xamarin apps that I have missed?
  • Is Google pay(Tez) integration not added in Xamarin.Android yet?
  • Or is there something wrong with my current config? i.e VS17 Pro version 15.6.7 , Xamarin version 4.9.0.753 and Xamarin.Android version 8.2.0.16 Android SDK latest with all the API versions above v 4.0

推荐答案

Google Pay(非Tez):

Package: `Xamarin.GooglePlayServices.Wallet`

确保通过清单中的metadata或应用程序的MetaDataAttribute启用应用程序进行电子钱包处理:

Make sure that you enable your app for Wallet processing via the metadata in the manifest, or via your application's MetaDataAttribute:

[Application]
[MetaData(name: "com.google.android.gms.wallet.api.enabled", Value = "true")]

从那里开始是using Android.Gms.Wallet;的问题,然后设置并使用PaymentsClient,即.

From there it is a matter of using Android.Gms.Wallet; and setting up and using the PaymentsClient, ie.

PaymentsClient paymentsClient = WalletClass.GetPaymentsClient(
        this, 
        new WalletClass.WalletOptions.Builder()
                .SetEnvironment(WalletConstants.EnvironmentTest)
                .Build()
);

Google Pay for India(基于UPI Intent):

要将交易信息传递到"Tez",请定义一个URI,其中包括您所有的商家信息,交易金额等.此URI基于UNIFIED PAYMENTS INTERFACE UPI方案(此不受控制)由Google提供,因此您需要参考UPI规范以了解需要传递的数据).

Google Pay for India (UPI Intent-based):

To pass the transaction information to "Tez", you define an URI that includes all of your merchant information, transaction amount, etc... This URI is based upon the UNIFIED PAYMENTS INTERFACE UPI scheme (this is not controlled by Google and thus you have refer to UPI specs for what data you need to pass).

re: 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的替代并处理结果:

Then of course you would implement an override for OnActivityResult and process the result:

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"));
    }
}

这篇关于将Google Pay(Tez)集成到我的付款网关中? (安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆