async Task PerformApplePayAction(PKPayment payment, Action<PKPaymentAuthorizationStatus> completion, PKPaymentAuthorizationViewController controller) { var jObject = ConvertToJObject(payment.Token.PaymentData); var paymentServiceModel = new PKPaymentViewModel { Amount = _applePayModel.ItemsTotalAmount(), ConsumerReference = _applePayModel.ConsumerRef, JudoID = _judo.JudoId, PaymentData = jObject, PaymentInstrumentName = payment.Token.PaymentInstrumentName ?? string.Empty, PaymentNetwork = payment.Token.PaymentNetwork ?? string.Empty }; var response = await _applePayRequest.Perform(paymentServiceModel); if (response.ConsideredSuccessful) { if (response.ReceiptModelPresent() && _successCallBack != null) { completion(PKPaymentAuthorizationStatus.Success); controller.DismissViewController(true, null); _successCallBack(response.ReceiptModel); } } else { completion(PKPaymentAuthorizationStatus.Failure); controller.DismissViewController(true, null); if (response.ReceiptModelPresent()) { _failureCallback(response.ErrorModel, response.ReceiptModel); } else { _failureCallback(response.ErrorModel); } } }
public override void PaymentAuthorizationViewControllerDidFinish (PKPaymentAuthorizationViewController controller) { controller.DismissViewController(true, null); }
public void PaymentAuthorizationViewControllerDidFinish(PKPaymentAuthorizationViewController controller) { controller.DismissViewController(true, null); }
public async Task <DropUIResult> ShowDropUI(double totalPrice, string merchantId, int resultCode = 1234) { dropUiPayTcs = new TaskCompletionSource <DropUIResult>(); if (CanPay) { BTDropInRequest request = new BTDropInRequest(); request.Amount = $"{totalPrice}"; BTDropInController bTDropInController = new BTDropInController(_clientToken, request, async(controller, result, error) => { if (error == null) { if (result.Cancelled) { dropUiPayTcs.SetCanceled(); } else if (result.PaymentOptionType == BTUIKPaymentOptionType.ApplePay) { try { isDropUI = true; var nonce = await TokenizePlatform(totalPrice, merchantId); var dropResult = new DropUIResult() { Nonce = nonce ?? string.Empty, Type = $"{BTUIKPaymentOptionType.ApplePay}" }; OnDropUISuccessful?.Invoke(this, dropResult); dropUiPayTcs.TrySetResult(dropResult); } catch (TaskCanceledException) { dropUiPayTcs.SetCanceled(); } catch (Exception exception) { OnDropUIError?.Invoke(this, exception.Message); dropUiPayTcs.TrySetException(exception); } finally { pKPaymentAuthorizationViewController?.DismissViewController(true, null); isDropUI = false; } } else { var dropResult = new DropUIResult() { Nonce = result.PaymentMethod?.Nonce ?? string.Empty, Type = $"{result.PaymentOptionType}" }; OnDropUISuccessful?.Invoke(this, dropResult); dropUiPayTcs.TrySetResult(dropResult); } } else { OnDropUIError?.Invoke(this, error.Description); dropUiPayTcs.TrySetException(new Exception(error.Description)); } controller.DismissViewController(true, null); }); var window = UIApplication.SharedApplication.KeyWindow; var _viewController = window.RootViewController; while (_viewController.PresentedViewController != null) { _viewController = _viewController.PresentedViewController; } _viewController?.PresentViewController(bTDropInController, true, null); } else { OnDropUIError?.Invoke(this, "Platform is not ready to accept payments"); dropUiPayTcs.TrySetException(new Exception("Platform is not ready to accept payments")); } return(await dropUiPayTcs.Task); }