void PopulatePKPaymentModel(PKPaymentViewModel paymentViewModel) { _judo.Validate(); _sessionPKPaymentModel.JudoId = (string.IsNullOrWhiteSpace(paymentViewModel.JudoID) ? _judo.JudoId : paymentViewModel.JudoID); _sessionPKPaymentModel.YourConsumerReference = (string.IsNullOrWhiteSpace(paymentViewModel.ConsumerReference) ? ("Consumer:" + _judo.JudoId) : paymentViewModel.ConsumerReference); _sessionPKPaymentModel.Amount = paymentViewModel.Amount; _sessionPKPaymentModel.ClientDetails = clientService.GetClientDetails(); _sessionPKPaymentModel.PkPayment = new PKPaymentInnerModel() { Token = new PKPaymentTokenModel() { PaymentData = paymentViewModel.PaymentData, PaymentInstrumentName = paymentViewModel.PaymentInstrumentName, PaymentNetwork = paymentViewModel.PaymentNetwork } }; }
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 async Task<ApplePayResponse> Perform(PKPaymentViewModel model) { var response = await _paymentService.ApplePayPayment(model); return HandleResponse(response); }
public async Task<IResult<ITransactionResult>> ApplePayPreAuth(PKPaymentViewModel payment) { PopulatePKPaymentModel(payment); Task<IResult<ITransactionResult>> task = _judoAPI.PreAuths.Create(_sessionPKPaymentModel); return await task; }