Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot reach approved status #15

Open
makasim opened this issue Dec 20, 2011 · 21 comments · Fixed by #35
Open

cannot reach approved status #15

makasim opened this issue Dec 20, 2011 · 21 comments · Fixed by #35

Comments

@makasim
Copy link
Contributor

makasim commented Dec 20, 2011

It is often the paypal payment $this->requestDoExpressCheckoutPayment is finished with these:

PAYMENTINFO_0_PAYMENTSTATUS: pending
PAYMENTINFO_0_PENDINGREASON: multi-currency

so the code

<?php
        //https://github.com/schmittjoh/JMSPaymentPaypalBundle/blob/master/Plugin/ExpressCheckoutPlugin.php#L212
        $transaction->setReferenceNumber($response->body->get('PAYMENTINFO_0_TRANSACTIONID'));
        $transaction->setProcessedAmount($response->body->get('PAYMENTINFO_0_AMT'));
        $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
        $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);

is never executed and I cannot finish the payment.

If I tried to call aproveAndDeposit once again the requestGetExpressCheckoutDetails method returns checkout status:

CHECKOUTSTATUS: PaymentActionCompleted

which is not supported.

what about to add:

<?php

       // verify checkout status
        switch ($details->body->get('CHECKOUTSTATUS')) {
            // ...
            case 'PaymentActionCompleted':
                $transaction->setReferenceNumber($details->body->get('PAYMENTREQUEST_0_TRANSACTIONID'));
                $transaction->setProcessedAmount($details->body->get('PAYMENTREQUEST_0_AMT'));
                $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS);
                $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS);
                return;

             //...
       }
@makasim
Copy link
Contributor Author

makasim commented Dec 20, 2011

another case of having pending when the user dont have enough money at the moment

@schmittjoh
Copy link
Owner

Is the payment actually approved by PayPal?

@makasim
Copy link
Contributor Author

makasim commented Dec 20, 2011

yes it does.

If I can go to the sandbox and login as a buyer. I see that the requested amount of money was sent to the customer.

In my case the problem come because I use EUR as a currency to pay but the buyer account don't have moneys in EUR only on USD so the payapl should convert money (that's why it returns pending status and multi-currency reason).

http://www.khokhar.info/2010/10/03/paypal-ipn-pending-because-of-multi_currency-issue/

Another case when the payment cannot be finished at the request: when the buyer doesn't have enough money at that moment (but he can finish it manually when he has money). so we have to check the state of payment from paypal

If I try to request details on payment after the payment is "finished" I am getting CHECKOUTSTATUS: PaymentActionCompleted

the code I propose above solve my problem I can fetch pending payments and recheck their state.

Actually I dont know whether it is right or not. I want to discuss it with you what would be the best way to handle such situation.

@makasim
Copy link
Contributor Author

makasim commented Dec 20, 2011

http://stackoverflow.com/questions/2433329/possible-payment-status-values

from there:

The most common status that I usually get is Completed and Pending. Common cause of Pending is the usage of different currency between buyer and seller, e.g: You sell in USD, buyer pay with GBP, PayPal will mark the transaction as Pending and it will be cleared after a few day. One of my client want me to handle Pending same as Completed, since he just sell digital goods (PDF file) and possess no risk if the payment is delayed, unlike merchant with physical goods.

@schmittjoh
Copy link
Owner

I think it makes sense to keep the payment's state on "APPROVING" as long as the PayPal transaction is "PENDING" as there is still a chance that it might not complete successfully. If you still want to go ahead in your application, you could check the reason code to see why it is still in APPROVING state.

However, it should also be possible to finally move the payment to APPROVED if the transaction moves to COMPLETED. If I understand you correctly, this is not possible right now.

@makasim
Copy link
Contributor Author

makasim commented Dec 21, 2011

yes, it is not possible, I will try to solve it.

@schmittjoh
Copy link
Owner

any news on this?

@kayue
Copy link

kayue commented Feb 12, 2012

I got the pending state once, there was insufficient fund in my test account.

And I can actually login to my buyer test account, add some money, and complete the payment later in Paypal's control panel.

I don't know how to handle this. Does it means we should implement IPN?

@schmittjoh
Copy link
Owner

IPN is a different topic that we can consider to implement. Actually, a patch for this would be appreciated. We also might introduce the listener system that I had in the jmsPaymentPlugin for symfony 1.4 then.

@makasim
Copy link
Contributor Author

makasim commented Feb 13, 2012

I haven't had a chance to do it

@makasim
Copy link
Contributor Author

makasim commented Apr 18, 2012

I have found the way approved status code be reached. It requires some changes in the ExpressCheckoutPlugin. As the logic of the plugin too complicated I am gonna write tests. I really want you to merge #32.

@makasim
Copy link
Contributor Author

makasim commented Apr 18, 2012

I've just found QueryablePluginInterface interface in the core bundle. Could the method updatePayment be used in scope of checking whether payment pending or not. Is it right approach?

@schmittjoh
Copy link
Owner

Yeah, that can be used as well to update the payment's status, but it would have to be initiated from our end.

In addition, or alternatively, we can use IPN. Then, Paypal initiates the change which should be faster:
https://www.paypal.com/ipn

For both, solutions we need to add some events though. So that, people can update their order statuses.

@makasim
Copy link
Contributor Author

makasim commented Apr 19, 2012

what about to create a cli command which can fetch pending payments and try to update them using updatePayment.

The update payment metod should be implemented in PluginController like
https://github.com/schmittjoh/JMSPaymentCoreBundle/blob/master/PluginController/PluginController.php#L135

@schmittjoh
Copy link
Owner

Basically, any payment could change it's status.

I think we would need to implement some filter in the CLI command, but in general, a CLI command is a good idea.

@makasim
Copy link
Contributor Author

makasim commented Apr 24, 2012

It is not clean and good solution but might help someone to manage pendings: https://gist.github.com/2477272

@hacfi
Copy link

hacfi commented Oct 3, 2012

Part of the problem is definitely CHECKOUTSTATUS should be PaymentActionCompleted and not PaymentCompleted:
https://github.com/schmittjoh/JMSPaymentPaypalBundle/blob/master/Plugin/ExpressCheckoutPlugin.php#L174

Not sure if this alone solves the problem though!

@schmittjoh
Copy link
Owner

Would you mind posting the links to the respective parts of the PayPal
documentation?

On Wed, Oct 3, 2012 at 12:36 PM, hifi7 [email protected] wrote:

Part of the problem is definitely CHECKOUTSTATUS should be
PaymentActionCompleted and not PaymentCompleted:

https://github.com/schmittjoh/JMSPaymentPaypalBundle/blob/master/Plugin/ExpressCheckoutPlugin.php#L174

Not sure if this alone solves the problem though!


Reply to this email directly or view it on GitHubhttps://github.com//issues/15#issuecomment-9101993.

@hacfi
Copy link

hacfi commented Oct 3, 2012

Couldn't find anything on this in the documentation but as others already reported (see also schmittjoh/JMSPaymentCoreBundle#25) this response actually comes up:
http://i.imgur.com/Hq9Ln.png

Adding PaymentActionCompleted seems to work but I'm not completely sure..still working on it.

@derekclapham
Copy link

@schmittjoh @hacfl - I ran in to this same issue today with requestGetExpressCheckoutDetails returning PaymentActionCompleted as the value for CHECKOUTSTATUS.

Unfortunately PayPal's documentation is all over the place and there's no clear picture as to what's up to date. However, here's the documentation supporting PaymentActionCompleted as a valid response: https://www.x.com/developers/paypal/documentation-tools/api/getexpresscheckoutdetails-api-operation-nvp

I've modified the bundle in my fork to accept PaymentActionComplete in the switch statement on L165 of ExpressCheckoutPlugin. I'll tidy up the code an submit a pull request. For the time being I've left the check for 'PaymentCompleted' in place because that is also documented in other disparate PayPal documentation.

@snake77se
Copy link

@schmittjoh, @hacfi

"Part of the problem is definitely CHECKOUTSTATUS should be
PaymentActionCompleted and not PaymentCompleted:"

PAYPAL Documentation

https://developer.paypal.com/docs/classic/api/merchant/GetExpressCheckoutDetails_API_Operation_NVP/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants