skip to Main Content

I’m making an application to send invoices via Paypal’s REST API (https://developer.paypal.com/docs/api/invoicing/v2/) but I cannot seem to find a way to disable shipping, is this possible to do?

I have tried to mess with "shipping_preference" and tried to find an answer, but I cannot seem to find any information about this.

2

Answers


  1. Through much trial and error, I found a solution to hide Shipping in the emailed invoice. This solution indirectly changes the (unconfigurable) category_code in the invoice from ‘SHIPPING‘ to ‘SERVICES‘.

    The Invoicing API documentation displays an array for shipping. In all my tests, sending the request with no tax and no shipping arrays, the API response had failed, declaring ‘unable to parse’. Note that the below does not contain shipping.

    In the (required) amount group of the API request, having the info below, has now solved this issue.

     'amount' => 
     array (
       'breakdown' => 
       array (
         'item_total' => 
         array (
           'currency_code' => 'USD',
           'value' => '14.00',          // <- calculate
         ),
         'discount' => 
         array (
           'invoice_discount' => 
           array (
             'amount' => 
             array (
               'currency_code' => 'USD',
               'value' => '0.00',       // <- calculate (for invoice)
             ),
           ),
           'item_discount' => 
           array (
             'currency_code' => 'USD',
             'value' => '0.00',         // <- calculate (for each item)
           ),
         ),
         'tax_total' => 
         array (
           'currency_code' => 'USD',
           'value' => '0.00',           // <- calculate
         ),
       ),
       'currency_code' => 'USD',
       'value' => '14.00',              // <- calculate 
     ),
    
    Login or Signup to reply.
  2. This is indeed a very annoying problem, I know that this post is old but after much digging,try and fail, I found something kind of peculiar I would say,I hope it could help anybody struggling with the same problem, if you go to API executor you will find that when you "create a draft invoice" category_code is nowhere to be found BUT if you go to fully update invoice you’ll find category_code and you can change the default value, you just need to add inside details something like category_code:SERVICES but is not limited to that, I don’t know all the options but also category_code:DIGITAL_GOODS also works.So if in create draft invoice you just add inside details something like category_code:(something) I think It should fix your problem like:

     $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.sandbox.paypal.com/v2/invoicing/invoices",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => '{
      "detail": {
        "invoice_number": "1540",
        "reference": "deal-ref",
        "invoice_date": "2018-11-12",
        "currency_code": "USD",
        "note": "Thank you for your business.",
        "term": "No refunds after 30 days.",
        "memo": "This is a long contract",
        "category_code":"SERVICES"
         and else---
    

    now a couple of links you might like to check
    paypal api excutor- create draft invoice
    https://www.paypal.com/apex/product-profile/invoicing_v2/createDraftInvoice
    paypal api-executor- fully update invoice
    https://www.paypal.com/apex/product-profile/invoicing_v2/updateInvoice

    and that’s all folks! happy coding!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search