This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMainActivity.cs
79 lines (66 loc) · 2.39 KB
/
MainActivity.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Android.App;
using Android.OS;
using Android.Views;
using AndroidX.AppCompat.App;
using Com.Braintreepayments.Api;
using Android.Gms.Wallet;
using Java.Interop;
using Android.Widget;
namespace DropInQs
{
partial class MainActivity : IDropInListener
{
public void OnDropInFailure(Java.Lang.Exception p0)
{
lblResult.SetTextColor(Android.Graphics.Color.DarkRed);
lblResult.Text = p0.Message;
System.Diagnostics.Debug.WriteLine(p0.Message);
}
public void OnDropInSuccess(DropInResult p0)
{
lblResult.SetTextColor(Android.Graphics.Color.DarkGreen);
lblResult.Text = p0.PaymentMethodNonce.ToString();
}
}
[Activity(
Label = "@string/app_name",
Theme = "@style/AppTheme.NoActionBar",
MainLauncher = true,
Exported = true
)]
public partial class MainActivity : AppCompatActivity
{
DropInClient dropInClient;
DropInRequest dropInRequest;
TextView lblResult;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);
lblResult = FindViewById<TextView>(Resource.Id.lblResult);
dropInRequest = new DropInRequest();
dropInRequest.PayPalRequest = new PayPalVaultRequest();
var googlePayRequest = new GooglePayRequest();
googlePayRequest.TransactionInfo = TransactionInfo.NewBuilder()
.SetTotalPrice("10.0")
.SetTotalPriceStatus(WalletConstants.TotalPriceStatusFinal)
.SetCurrencyCode("USD")
.Build();
googlePayRequest.BillingAddressRequired = true;
dropInRequest.GooglePayRequest = googlePayRequest;
dropInRequest.VenmoRequest = new VenmoRequest(VenmoPaymentMethodUsage.MultiUse);
dropInRequest.ThreeDSecureRequest = new ThreeDSecureRequest
{
Amount = "10.0"
};
dropInClient = new DropInClient(this, "sandbox_tmxhyf7d_dcpspy2brwdjr3qn");
dropInClient.SetListener(this);
}
[Export("openDropIn")]
public void OpenDropIn(View view)
{
lblResult.Text = "Waiting...";
dropInClient.LaunchDropIn(dropInRequest);
}
}
}