public async Task <string> Complete(CompletePaymentRequest request, bool isSandbox) { try { string clientId; string clientSecret; var settings = await _siteSettingsService.Get(); if (isSandbox) { clientId = settings.PaypalSandBoxClientId; clientSecret = settings.PaypalSandBoxSecret; } else { clientId = settings.PaypalClientId; clientSecret = settings.PaypalClientSecret; } request.Token = _paypalService.GetAccessToken(clientId, clientSecret, isSandbox ? "sandbox" : "mode"); var completedPayment = _paypalService.CompletePayment(request); return(completedPayment.id); } catch (PaymentsException ex) { throw new Exception(ex.Response); } }
public async Task <IActionResult> OnPostPay() { CompletePaymentRequest request = new CompletePaymentRequest { OrderId = OrderId }; await mediator.Send(request); return(RedirectToPage("Dispenser", new { OrderId = OrderId })); }
public Payment CompletePayment(CompletePaymentRequest paymentRequest) { var apiContext = new APIContext(paymentRequest.Token); var paymentExecution = new PaymentExecution { payer_id = paymentRequest.PayerId }; var payment = new Payment { id = paymentRequest.PaymentId, }; var executedPayment = payment.Execute(apiContext, paymentExecution); return(executedPayment); }
public async Task <ActionResult> Complete(CompletePaymentRequest completePaymentRequest) { try { //todo: send cart data with order ViewBag.PaymentConfirmation = await _checkoutService.Complete(completePaymentRequest, _isSandbox); var cart = await _cartService.GetCartViewModel(_session.SessionId()); var orderId = await _orderService.Create(await GetOrderModel(), cart); await _cartService.EmptyCart(_session.SessionId()); return(RedirectToAction("OrderConfirmation", "Checkout", new { id = orderId })); } catch (PaymentsException ex) { return(Content(ex.Response)); } }
public async void Example() { #pragma warning disable 0168 using (Client client = GetClient()) { CardWithoutCvv card = new CardWithoutCvv(); card.CardNumber = "67030000000000003"; card.CardholderName = "Wile E. Coyote"; card.ExpiryDate = "1220"; CompletePaymentCardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CompletePaymentCardPaymentMethodSpecificInput(); cardPaymentMethodSpecificInput.Card = card; CompletePaymentRequest body = new CompletePaymentRequest(); body.CardPaymentMethodSpecificInput = cardPaymentMethodSpecificInput; CompletePaymentResponse response = await client.Merchant("merchantId").Payments().Complete("paymentId", body); } #pragma warning restore 0168 }
public Payment CompletePayment(CompletePaymentRequest paymentRequest) { try { var apiContext = new APIContext(paymentRequest.Token); var paymentExecution = new PaymentExecution { payer_id = paymentRequest.PayerId }; var payment = new Payment { id = paymentRequest.PaymentId, }; var executedPayment = payment.Execute(apiContext, paymentExecution); return(executedPayment); } catch (PaymentsException ex) { throw new Exception(ex.Response); } }
/// <summary> /// Resource /{merchantId}/payments/{paymentId}/complete /// - <a href="https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/dotnet/payments/complete.html">Complete payment</a> /// </summary> /// <param name="paymentId">string</param> /// <param name="body">CompletePaymentRequest</param> /// <param name="context">CallContext</param> /// <returns>CompletePaymentResponse</returns> /// <exception cref="ValidationException">if the request was not correct and couldn't be processed (HTTP status code BadRequest)</exception> /// <exception cref="AuthorizationException">if the request was not allowed (HTTP status code Forbidden)</exception> /// <exception cref="IdempotenceException">if an idempotent request caused a conflict (HTTP status code Conflict)</exception> /// <exception cref="ReferenceException">if an object was attempted to be referenced that doesn't exist or has been removed, /// or there was a conflict (HTTP status code NotFound, Conflict or Gone)</exception> /// <exception cref="GlobalCollectException">if something went wrong at the Ingenico ePayments platform, /// the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, /// or the service that you're trying to reach is temporary unavailable (HTTP status code InternalServerError, BadGateway or ServiceUnavailable)</exception> /// <exception cref="ApiException">if the Ingenico ePayments platform returned any other error</exception> public async Task <CompletePaymentResponse> Complete(string paymentId, CompletePaymentRequest body, CallContext context = null) { IDictionary <string, string> pathContext = new Dictionary <string, string>(); pathContext.Add("paymentId", paymentId); string uri = InstantiateUri("/v1/{merchantId}/payments/{paymentId}/complete", pathContext); try { return(await _communicator.Post <CompletePaymentResponse>( uri, ClientHeaders, null, body, context)); } catch (ResponseException e) { object errorObject = _communicator.Marshaller.Unmarshal <ErrorResponse>(e.Body); throw CreateException(e.StatusCode, e.Body, errorObject, context); } }