protected void FetchAuthorization() { if (mAuthorization != null) { OnAuthorizationFetched(); } else if (Settings.UseTokenizationKey(this)) { mAuthorization = Settings.GetEnvironmentTokenizationKey(this); OnAuthorizationFetched(); } else { DemoApplication.getApiClient(this).GetClientToken( Settings.GetCustomerId(this), Settings.GetMerchantAccountId(this)) .ContinueWith(t => { if (t.IsFaulted || TextUtils.IsEmpty(t.Result)) { ShowDialog("Client token was empty"); } else { mAuthorization = t.Result; OnAuthorizationFetched(); } }); } }
async void SendNonceToServer(PaymentMethodNonce nonce) { Task <Transaction> task; if (Settings.isThreeDSecureEnabled(this) && Settings.isThreeDSecureRequired(this)) { task = DemoApplication.getApiClient(this).CreateTransaction(nonce.Nonce, Settings.GetThreeDSecureMerchantAccountId(this), true); } else if (Settings.isThreeDSecureEnabled(this)) { task = DemoApplication.getApiClient(this).CreateTransaction(nonce.Nonce, Settings.GetThreeDSecureMerchantAccountId(this)); } else if (nonce is CardNonce && ((CardNonce)nonce).CardType.Equals("UnionPay")) { task = DemoApplication.getApiClient(this).CreateTransaction(nonce.Nonce, Settings.GetUnionPayMerchantAccountId(this)); } else { task = DemoApplication.getApiClient(this).CreateTransaction(nonce.Nonce, Settings.GetMerchantAccountId(this)); } var transaction = await task; if (transaction == null) { SetStatus(Resource.String.transaction_failed); SetMessage(new Java.Lang.String("Unable to create a transaction")); return; } if (transaction.Message != null && transaction.Message.StartsWith("created")) { SetStatus(Resource.String.transaction_complete); SetMessage(new Java.Lang.String(transaction.Message)); } else { SetStatus(Resource.String.transaction_failed); if (TextUtils.IsEmpty(transaction.Message)) { SetMessage(new Java.Lang.String("Server response was empty or malformed")); } else { SetMessage(new Java.Lang.String(transaction.Message)); } } }