Yaniv Amrami
Yaniv Amrami

Reputation: 387

Payments through PayPal with ASP.NET CORE 3

I am trying to run payments through PayPal in sandbox mode with my .NET CORE 3 project. The idea is to give the customer ability to choose whether to pay using his/her PayPal account or Credit Card. I am using the PayPal-NET-SDK v2.0.0-rc2

I am trying to understand whether this is the right order to run things:

  1. Create Payment using PaymentCreateRequest
  2. At this point, I get the approval_url. I redirect the customer and approve the payment/order using Credit Card
  3. Execute payment using PaymentExecuteRequest, using the PAYID and PAYERID I get from the redirect URL. Here I get an order object
  4. Authorize order using OrderAuthorizeRequest with the order id (setting body to a PayPal.v1.Orders.Capture object)
  5. Capture order using OrderCaptureRequest with the order id (setting body to a PayPal.v1.Payments.Capture object)

Is that a correct execution order?

Upvotes: 3

Views: 3987

Answers (1)

Preston PHX
Preston PHX

Reputation: 30467

  1. Rather than the old v1/payments, you should use v2/orders; the v2 SDK can be downloaded here

  2. Rather than an old-style full page redirect to an approval_url , it's much nicer to use the new checkout's in-context UI that keeps your site loaded in the background. Here is a demo pattern. Another benefit is that it gives an embedded/in-line credit card form.

  3. If you start out with intent=capture(v2) or sale(v1), the capture(v2)/execution(v1) call will be final and complete the transaction, there will be no authorize step, so (4) on your list is skipable. (You should only bother with implementing something other than intent=capture/sale if you find you have a specific business need for delaying captures, as it adds complexity)

  4. More general information on implementing the server-side portion of the integration: https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/

Upvotes: 1

Related Questions