laravel-paypal icon indicating copy to clipboard operation
laravel-paypal copied to clipboard

How can i use products while creating orders?

Open Pushkraj19 opened this issue 3 years ago • 6 comments

Hello,

Paypal has provided https://developer.paypal.com/api/catalog-products/v1/ but there is not any documentation on how to use them.

I am trying to create a payment option for saas but when it's created it's still asking for a shipping address. How can I disable the shipping address with https://srmklive.github.io/laravel-paypal/docs.html#item-12-1 to create an order one time payment?

Also, how can I use product id with https://srmklive.github.io/laravel-paypal/docs.html#item-12-1 ?

Please help me with these and please add these to the documentation.

Cause Paypal docs are lots of 404 pages and Paypal support have no idea how to do these things.

Pushkraj19 avatar Jan 19 '22 04:01 Pushkraj19

The current method I am using to createOrder

        $response = $provider->createOrder([
            "intent" => "CAPTURE",
            "application_context" => [
                "return_url" => route('paypal.successTransaction'),
                "cancel_url" => route('paypal.cancelTransaction'),
            ],
            "purchase_units" => [
                0 => [
                    "name" => number_format($plan->credits) . ' Plan',
                    "description" => $plan->name,
                    "type" => "DIGITAL",
                    "category" => "COMPUTER_AND_DATA_PROCESSING_SERVICES",
                    "amount" => [
                        "currency_code" => 'USD',
                        "value" => 10
                    ]
                ]
            ],
        ]);

Pushkraj19 avatar Jan 19 '22 04:01 Pushkraj19

Why do you need to do that?

srmklive avatar Jan 19 '22 06:01 srmklive

Because you don't need a shipping address for saas. If you provide saas Paypal ask you to mention that you are providing saas in type and category to avoid false disputes.

If you keep the shipping address Paypal assumes it as the physical product and if the user says I have not received the product after 30 days the Paypal automatically refunds the user money cause Paypal can see it's been 30 days and the seller have not provided tracing id for the shipping. Cause its saas how can we give them tracking id ???

"type" => "DIGITAL",
"category" => "COMPUTER_AND_DATA_PROCESSING_SERVICES",  //your service category from Paypal docs

SO we sellers lose complete rights to fight against those customers.

So the Paypal customer support said to remove shipping fields from checkout but when I asked how? they don't know cause I am not using direct Paypal SDK but srmklive/laravel-paypal/ and I also don't know how to do that cause Paypal docs suck big time compare to stripe docs.

I hope you understood the problem.

Pushkraj19 avatar Jan 19 '22 07:01 Pushkraj19

The current method I am using to createOrder

        $response = $provider->createOrder([
            "intent" => "CAPTURE",
            "application_context" => [
                "return_url" => route('paypal.successTransaction'),
                "cancel_url" => route('paypal.cancelTransaction'),
            ],
            "purchase_units" => [
                0 => [
                    "name" => number_format($plan->credits) . ' Plan',
                    "description" => $plan->name,
                    "type" => "DIGITAL",
                    "category" => "COMPUTER_AND_DATA_PROCESSING_SERVICES",
                    "amount" => [
                        "currency_code" => 'USD',
                        "value" => 10
                    ]
                ]
            ],
        ]);

This is is not working at all.

Pushkraj19 avatar Jan 19 '22 07:01 Pushkraj19

@srmklive Please give me the solution for this issue.

Pushkraj19 avatar Jan 23 '22 08:01 Pushkraj19

Hey @Pushkraj19

Actually the PayPal docs are pretty clear on this. You're mixing the Catalog Products API with the Orders API. Look at your "purchase_units" key. You need to remove "name", "type" and "category" as these aren't valid fields for the "purchase_unit_request". See https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request. Build the array using the docs as a guide to all the elements. If this is a one-off payment you don't need Products just Orders. Something like this:

            $response= $provider->createOrder([
                'intent' => 'CAPTURE',
                'application_context' => [
                    'return_url' => route('paypal.successTransaction'),
                    'cancel_url' => route('paypal.cancelTransaction'),
                ],
                'payer' => [
                    'email_address' => '[email protected]',
                    'name' => [
                        'given_name' => 'Joe',
                        'surname' => 'Bloggs,
                    ]
                ],
                'purchase_units' => [
                    [
                        'description' => $plan->name,
                        'amount' => [
                            'currency_code' => 'USD',
                            'value' => 10,
                        ],
                        'items' => [
                            [
                                'name' => number_format($plan->credits) . ' Plan',
                                'unit_amount' => 10,
                                'quantity' => 1,
                                'description' => $plan->name,
                                'category' => 'DIGITAL_GOODS',
                            ]
                        ]
                    ]
                ]
            ]);

I got all this by just reading the PayPal REST API docs at https://developer.paypal.com/api/rest/ and by lots of testing in the Sandbox. And of course the docs for this package at https://laravel-paypal-demo.srmk.info/.

ben-demotic avatar May 06 '22 23:05 ben-demotic

Hello @ben-demotic

https://developer.paypal.com/docs/api/orders/v2/#definition-item For DIGITAL_GOODS They clearly mention that This value is not currently supported for API callers that leverage the PayPal for Commerce Platform product.

So how can I use this functionality If I used commerce-platform?

ks-dipeshc avatar Dec 15 '22 04:12 ks-dipeshc

Hi @dipeshchangawala

I guess you can't then is the answer?

I'm not the author, so all I will say is this package implements the PayPal API as published on developer.paypal.com. If you have questions about the API itself I would log a ticket with PayPal's support, it's their platform.

ben-demotic avatar Dec 22 '22 22:12 ben-demotic