srmklive / laravel-paypal

Laravel plugin for processing payments through PayPal.
https://laravel-paypal-demo.srmk.info/
MIT License
1.05k stars 317 forks source link

"No paypal_link in response"? #136

Closed karam94 closed 7 years ago

karam94 commented 7 years ago

Hi,

I have recently come back to an old project where my PayPal functionality was working fine using this package. Unfortunately (even after updating) I seem to now be encountering an issue where setExpressCheckout() does not seem to be functioning correctly.

I've inspected the ExpressCheckout provider, I've inspected the data containing an array of items etc being sent and all contains the correct information. I'm starting to wonder how the functionality has suddenly stopped working.

All I am getting back is: Array ( [type] => error [message] => [paypal_link] => )

This is similar to another closed but unresolved issue from about a month ago.

Any ideas what is causing this? It's quite urgent.

Thanks

andreyarias commented 7 years ago

Same problem

srmklive commented 7 years ago

From what i can understand is that you are not getting a valid token from PayPal on a SetExpressCheckout API call. Most of the times, it has to do with:

I have tested the package thoroughly, couldn't replicate what you have specified here.

karam94 commented 7 years ago

Well, this issue has cropped up for a lot of us so far. I'd suggest instead of just closing a ticket every time it does crop up which is the wrong approach to take, we try to at least fix the problem as it might help others in the future.

Incorrect API credentials. Nope, I've checked a million times now and the credentials given to me by PayPal match perfectly. I have not specified a certificate as afaik it is optional and it used to work fine a few months back without a certificate specified.

Correct API credentials but incorrect mode. The credentials I'm using are sandbox credentials and I have sandbox mode set in PayPal.php. Is there anywhere else I need to check for a live/sandbox mode split?

Duplicate Invoice Id No duplicate invoices neither in my database or anything linked to the PayPal account as I even test with a new account.

I think it's obvious the issue is with your package hitting the PayPal API and it not liking something. But it would be more straight forward if specifics regarding the error were output so we had an idea regarding what to chase down.

My ExpressCheckout data being fed through to setExpressCheckout is as follows:

Array ( [items] => Array ( [0] => Array ( [name] =>1,000 Points [price] => 9.99 [qty] => 1 ) ) [total] => 9.99 [invoice_id] => 1 [invoice_description] => Order Description lol [return_url] => http://project-api.dev/api/lol/paymentsuccessful [cancel_url] => http://project-api.dev/cart )

Do you see anything, whatsoever that is missing and could be causing the PayPal API to return the error?

srmklive commented 7 years ago

Add a prefix to invoice id such as KARAM94_PAYPAL_ so the invoice id being passed to PayPal is KARAM94_PAYPAL_1.

karam94 commented 7 years ago
Array
(
    [items] => Array
        (
            [0] => Array
                (
                    [name] => 1,000 Points
                    [price] => 9.99
                    [qty] => 1
                )

        )

    [total] => 9.99
    [invoice_id] => KARAM94_PAYPAL_1
    [invoice_description] => Order Description lol
    [return_url] => http://project-api.dev/api/lol/paymentsuccessful
    [cancel_url] => http://project-api.dev/cart
)
Array
(
    [type] => error
    [message] => 
    [paypal_link] => 
)
no paypal_link in response

Unfortunately, same problem.

srmklive commented 7 years ago

In the paypal demo app https://laravel-paypal-demo.srmk.info/, this is the data i am passing to SetExpressCheckout:

array:6 [▼
  "items" => array:2 [▼
    0 => array:3 [▼
      "name" => "Product 1"
      "price" => 9.99
      "qty" => 1
    ]
    1 => array:3 [▼
      "name" => "Product 2"
      "price" => 4.99
      "qty" => 2
    ]
  ]
  "return_url" => "https://laravel-paypal-demo.srmk.info/paypal/ec-checkout-success"
  "invoice_id" => "PAYPALDEMOAPP_V55_55"
  "invoice_description" => "Order #55 Invoice"
  "cancel_url" => "https://laravel-paypal-demo.srmk.info"
  "total" => 19.97
]

Following is the api response:

array:7 [▼
  "TOKEN" => "EC-3J255773UB275500B"
  "TIMESTAMP" => "2017-09-23T08:01:09Z"
  "CORRELATIONID" => "7226824275397"
  "ACK" => "Success"
  "VERSION" => "123"
  "BUILD" => "39073839"
  "paypal_link" => "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-3J255773UB275500B"
]

As you can see, i am getting a paypal_link. It is definitely an issue on your application's end.

karam94 commented 7 years ago

Here is my ExpressCheckout object... https://pastebin.com/pptBT59k

Do you see anything whatsoever that looks configured incorrectly? Otherwise, I'm stumped. I don't see how it can be down to my application when I merely just reference laravel-paypal through composter, configure things up and then call the setExpressCheckout method with the data I provided. Particularly when it used to work fine around a month ago.

Do PayPal not return an error code or something with a clue we can get a hold of to understand why their API returns an error? If so, where can I grab a hold of this in the laravel-paypal code specifically?

srmklive commented 7 years ago

Can you describe the PHP version for your application for which issue you are facing?

karam94 commented 7 years ago

PHP 7.1.2 (cli) (built: Feb 17 2017 10:52:17) ( NTS ) Running my API in Laravel Valet.

I've dug deeper in to PayPalRequest.php in to the makeHttpRequest() method. Seems like the error occurs and throws neither of the three exceptions you're trying to catch.

I'm starting to wonder if this could be an issue with Guzzle? I'm really baffled what could be going wrong.

srmklive commented 7 years ago

I would suggest that you donot test the PayPal integration on local server.

srmklive commented 7 years ago

Btw here is the paypal demo app ExpressCheckout object: https://pastebin.com/zC0N5h75

karam94 commented 7 years ago

I've pulled down the laravel-paypal-demo and am getting the following exception:

UnexpectedValueException 
…/vendor/symfony/http-foundation/Response.php409

So I went in to your PayPalController and put a print_r on the response and exit right after. Intriguingly got: Array ( [type] => error [message] => [paypal_link] => )

This is so surprising as I remember using this with Valet only a month or so ago and now it seems PayPal is no longer playing along.

Is there any way you recommend this works offline? Just saves time and hassle, as well as makes developing on the go a little easier when I don't have a dependency on an online server all the time!

Appreciate your patience and hopefully once I'm on an online server, this baffling behaviour comes to a stop.

srmklive commented 7 years ago

I don't see any other way to test this on a live server. Just setup one on Linode/Digitalocean through Laravel Forge

karam94 commented 7 years ago

Tested on Heroku, worked fine. Tested again locally, also worked fine.

So, when it used to work locally, I'd be at home in England (UK). When it wasn't working locally, I was working remotely, on holiday in Lebanon, where PayPal isn't really a thing. So I guess perhaps PayPal have Lebanese IPs potentially blocked off? sigh

Hopefully this helps others who experience this issue.

ahmed-ucasl commented 5 years ago

hi every one i had the same issue few hours ago the problem is the Signature and CERTIFICATE and the secret are some how confused after rechecking the package it self and after some testing my problem was as follow ..

the env file secret should be your sandbox paypal credentials Signature key .. not the app secret key the CERTIFICATE should be empty the credentials type at paypal account should be Signature not CERTIFICATE

this fix the problem for me hope it will do the same for some one

friana commented 5 years ago

This issue may be solve in this link. Thanks

https://github.com/srmklive/laravel-paypal/issues/229#issuecomment-472755054

Expertweblancer commented 3 years ago

@ahmed-ucasl You are great. I fixed it. The signature is the secret key!!!!