Search code examples
paypalpaypal-rest-sdkpayment-processing

How to set PayPal transaction type using the SDK?


I'm using the PayPal SDK nuget package to process online orders on my website. The issue is all products are set as "physical" by default.

In this link PayPal shows how to set the type of an order/product https://developer.paypal.com/docs/api/catalog-products/v1/

But in the PayPal asp.net sdk, there's nothing like that. https://paypal.github.io/PayPal-NET-SDK/Samples/PaymentWithPayPal.aspx.html

Has anyone had any experience with this or is able to find out how to set products/orders as "Service" or "Digital" through the sdk?


Solution

  • First of all the v1/payments PayPal-NET-SDK is deprecated, use the v2/checkout/orders Checkout-NET-SDK instead

    Secondly the catalog-products API only applies to things like subscription payments. If you aren't creating products for subscription plans, this API is not relevant to you.

    With the v2 items API, if your purchase_units includes an items array (and the required separate amount_breakdown, in cases of passing an items array) , there is a category field for each item: https://developer.paypal.com/docs/api/orders/v2/#definition-item


    The above is getting a little in to the weeds though, when you probably should first take a step back and review the basics of implementing a v2 checkout.

    Create two routes on your server, one for 'Set Up Transaction' and another for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/

    Then connect to them with this front-end for the payer approval: https://developer.paypal.com/demo/checkout/#/pattern/server