magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.45k stars 9.29k forks source link

Paypal Pro currency issue #7977

Open HongMarketingInc opened 7 years ago

HongMarketingInc commented 7 years ago

Preconditions

  1. Magento CE 2.1.2
  2. Setup two websites, each one has its own Paypal Pro account.
  3. Setup base currency as CAD for each website
  4. Product currency is CAD

Steps to reproduce

  1. Go to the 1st website (main website), place an order (CAD $10.00) by using Paypal Pro payment, both Magento and Paypal show the amount in CAD
  2. Go to the 2nd website, place an order (CAD $10.00) by using Paypal Pro payment, Magento shows CAD10.00, but Paypal actually charge the customer USD $10.00.

Expected result

  1. The customer should be charged in CAD on the 2nd website

Actual result

  1. The customer is charged in USD on the 2nd website
alena-marchenko commented 7 years ago

Hi @HongMarketingInc

Have you used different Paypal Pro accounts for websites? PayPal can show USD instead of CAD when Paypal Pro account does not support Canadian Dollars. In this case you will need to contact PayPal support for enabling Canadian Dollars support for account.

HongMarketingInc commented 7 years ago

Yes, each website has its own paypal pro account. Each account's primary currency is CAD.

I can confirm that the client is charged by USD.

KalebHosie commented 7 years ago

I'm having the same issue, except it's charging in USD for all websites. I called PayPal and they said it's an issue with the API call.

I ran the debug in my PayPal settings and I have confirmed that when I use PayPal Express checkout, the API call specifies the CAD currency and the end result is that it works correctly. On the other hand, when I use Website Payments Pro, it doesn't doesn't specify any currency at all during the API call and the customer is charged in USD.

Could this be the issue?

gooki commented 7 years ago

Referenced in 1c7f70d

app/code/Magento/Paypal/Test/Unit/Model/Payflow/TransparentTest.php Line 169: + ->willReturn('USD');

Maybe if we (Canadian Sellers) change that line to read CAD, the correct currency will be sent?

KalebHosie commented 7 years ago

@gooki That's good thinking but sadly I already tried that with no luck.

KalebHosie commented 7 years ago

There has been a lot of communication on this subject using issue #6929 and there is a lot of missing information on this thread.

To provide an update for anyone new that can help us or is experiencing the same issue, here is a summary.

PayPal Payflow Pro now uses the currency you’ve specified in your store settings. Previously, Magento converted the total price into U.S. dollars, no matter which currency was specified in the store

Ultimately, we need to find a way to charge credit cards on our websites in our own currency.

All help is greatly appreciated!

gooki commented 7 years ago

@supanatral +1 Plus zero amount being sent (or is a consequence of the wrong currency being posted)

KalebHosie commented 7 years ago

@HongMarketingInc did you resolve this?

@gooki the API call does a $0 charge and to see if the credit card is approved, it will do a second API call with the final amount. This seems overly redundant to me but it does work.

KalebHosie commented 7 years ago

@gooki I've posted an ad on Upwork to hire a developer to fix this issue. I hope to report back with the coding changes required.

gooki commented 7 years ago

@supanatral great let me know how much it will be or a link to the ad, I can share the cost if necessary

KalebHosie commented 7 years ago

@gooki you are a gentleman and a scholar! No worries though :)

I just finished hiring the developer about 1hr ago who will start working on the issue in about 12 hours from now. I've asked him to report his finding and big fix on Github so the entire community can benefit.

gooki commented 7 years ago

@supanatral sweet, can't wait

gooki commented 7 years ago

@supanatral Any news on this buddy?

KalebHosie commented 7 years ago

No update on the developers side. Hope to have an update soon on that.

I tried setting up a new v2.1.4 dev test site with sample data and tried it out without the use of 3rd party plugins. I changed the currency to CAD and setup PayPal. In the end, the API call didn't call for the CAD currency and it was still billed in USD.

KalebHosie commented 7 years ago

I just discovered another thread regarding this issue and it appears that the person found a temporary work around #7719

I don't have time to test it because I'm about to run out

KalebHosie commented 7 years ago

@gooki I have tested it and i seems like @H3dz findings were correct.

If you add "$request->setCurrency('CAD'); // Hardcoded to CAD" to line 627, it appears to fix the problem.

Of course, this is not an ideal solution but it should work at least

hubaig commented 7 years ago

Hi,

That fix did change my currency to CAD but I still get an error and in my payflow logs see that it is authorising with $0.00 amount.

Any ideas why it would do that?

KalebHosie commented 7 years ago

@hubaig great to hear it worked. I tried finding a better solution but so far I've been unable to.

Magento authorizes $0 to make sure the credit card is valid. Once it gets a confirmation it's valid, it sends the full amount of the order. There's no doubt that it's overly redundant but it works so I cannot complain

hubaig commented 7 years ago

@supanatral I am actually trying to make a sale not an authorizaiton.

My Payment Action: is set to Sale in Magento. Not sure why it is authorizing instead of a sale. Any ideas?

HongMarketingInc commented 7 years ago

@supanatral

Has your programmer fixed it?

KalebHosie commented 7 years ago

@hubaig My payment is set to sale as well. It appears to authorize $0 and when it gets approved, it charges the full amount.

As I said, there's no doubt this is incredibly redundant and very much unnecessary but at least it works.

My programmer hasn't seemed to figure out the fix as of yet :S

hubaig commented 7 years ago

Mine never ends up creating a sale. Just gives up at authorization.

KalebHosie commented 7 years ago

@hubaig Strange! Does your front end supporting both PayPal express checkout AND PayPal website payments pro? I'm not looking at the config interface but are you sure that both payment methods (express and payments pro) are set to "sale"?

Sorry if my reply is overly basic.

hubaig commented 7 years ago

yes they both are set to sale. I am updating to 2.1.5 as it just came out. Lets see if it fixes anything.

KalebHosie commented 7 years ago

The changes won't do anything. Here's the release notes: "This release updates the copyright date in every file. It does not contain any functional changes or security improvements. Isolating these changes in a single release is intended to simplify future updates and developer workflow."

FAIL

Which currency do you use as a base currency? Is there any other error that is shown?

hubaig commented 7 years ago

My base currency is CAD. Right now my store is at 2.1.1. So upgrading to 2.1.5 would provide some sort of functional/security changes though.

hubaig commented 7 years ago

Upgraded to version 2.1.4 still no luck :( not sure why it won't work.

hubaig commented 7 years ago

making progress. I am getting an auth and a sale now. However the same declines due to this:

Result Code: 117 Response Message: Failed merchant rule check

According to THIS this is due to the security settings. I have softened my settings a bit and have set them all to no and it still fails.

Never ends.

KalebHosie commented 7 years ago

@hubaig Does this work? http://therealdanvega.com/blog/2013/11/29/paypal-payflowpro-result117-failed-merchant-rule-check

Sounds like your getting farther at least.

hubaig commented 7 years ago

@supanatral I was up late night figuring this out and got it all fixed. I am now able to charge credit cards for the first time. Funny thing was that when I finished with the fix, an order came within 5 minutes. God knows how much revenue I have lost due to this problem.

For the record, I did stumble upon this blog entry you mentioned last night and that was the fixed that I required on top of the hard coding of the CAD currency mentioned above.

Regards,

gooki commented 7 years ago

@hubaig @supanatral

I don't know what I'm doing wrong then. I'm still getting the invalid merchant information error. Would you guys be able to post your complete backend paypal settings and also paypal manager settings. (minus confidential stuff of course). I want to make sure I'm doing apples to apples. I am getting the proper currency now but that's about it. I have the allow reference transactions on as well.

magebay99 commented 7 years ago

I have same error. I have upgraded to Magento 2.1.4 and 2.1.5 But it still not work. On Basic Settings - PayPal Payments Pro. I setup Payment Action = Sale

magebay99 commented 7 years ago

Here are solution to fixed this problem. See more detail this error at https://bestcodestore.com/magento-2-paypal-payments-pro-wrong-currency/

This problem appeared with ( PayPal Payments Pro. I setup Payment Action = Sale ).

vendor/magento/module-paypal/Model/Payflowpro.php public function buildBasicRequest( ) { // line 627: $currencyCode = \Magento\Framework\App\ObjectManager::getInstance()->create('\Magento\Store\Model\StoreManagerInterface')->getStore()->getCurrentCurrency()->getCode(); $request->setCurrency( $currencyCode );

} It work now. You can temporarily use it while waiting magento update.

gooki commented 7 years ago

After doing the above changes and having paypal change our currency on their end to CAD we finally were able to process a payment. I do not know if it is due to us changing the above and the paypal change or just because of the paypal change. I think it is because of both.

jatkinson77 commented 7 years ago

This does seem to work as a workaround, but has some pretty significant limitations. `vendor/magento/module-paypal/Model/Payflowpro.php public function buildBasicRequest( ) { // line 627: $currencyCode = \Magento\Framework\App\ObjectManager::getInstance()->create('\Magento\Store\Model\StoreManagerInterface')->getStore()->getCurrentCurrency()->getCode(); $request->setCurrency( $currencyCode );

}`

  1. It fails if you are trying to use the authorization payment type, which is my preferred way to take order. The problem appears to be that Magento does not send a currency code to Paypal on the $0 authorization. Paypal assumes that the $0 is in your account's default currency, then when a transaction comes through with a different currency it causes an error.

  2. It also will not allow any refunds to be processed. I assume this is because when you are processing a refund from admin getCurrentCurrency is taking the default currency from the admin standpoint not the currency the order was placed in.

Hopefully Magento will sort this out sooner than later. I would rather not have to pay someone to develop a custom solution to this.

jatkinson77 commented 7 years ago

I have a working solution to this issue that seems to allow all functionality to behave as expected.

I transact sales in CAD and USD. Our main PayPal account is based in CAD.

I opened a second PayPal account and set the default currency to USD. I connected this account to our US store and now everything seems to work properly. I am paying for a second PayPal account, but that is cheaper than paying a developer to fix the core code.

Grumag commented 6 years ago

So I am on Magento 2.2.2 and received 3 sales and they are in USD? Is this issue still not fixed after more than a year? Magento currency is setup as CAD, we are using a Canadian PayPal account with Website Payments Pro / PayFlow Pro.

What happens is $0 authorization and then USD charge for the full amount.

Contacted PayPal, they said it is API issue.

I only have 1 site, not 2.

Any fix that can be applied?

Thanks!

Grumag commented 6 years ago

We have tried to hardcode CAD on line 627, getting Payment Cannot be Processed error, and billing details disappear from the checkout page. Does anyone have a working solution for Magento 2.2.2?

Grumag commented 6 years ago

Any update from anyone on this?

mariamghalleb commented 6 years ago

any solution for this?

Grumag commented 6 years ago

Not that I am aware of. We had to stop using the site until it is resolved. Awesome.

HongMarketingInc commented 6 years ago

Files changed (1)

File vendor/magento/module-paypal/Model/Payflowpro.php MODIFIED Side-by-side diff View file https://bitbucket.org/hmihmi/maplewellness/src/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c/vendor/magento/module-paypal/Model/Payflowpro.php

Comment

More https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF624T624

     $request->setVerbosity($this->getConfigData('verbosity'));

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF625T625

     $request->setData('BUTTONSOURCE', $config->getBuildNotationCode());

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF626T626

     $request->setTender(self::TENDER_CC);

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpT627

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpT628

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpT629

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF627T630

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF628T631

     return $request;

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF629T632

 }

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF630T633

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF631T634

 /**

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF632T635

  * If response is failed throw exception

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF633T636

  *

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF634T637

  * @param DataObject $response

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF635T638

  * @return void

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF636T639

  * @throws \Magento\Framework\Exception\LocalizedException

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF637T640

  * @throws \Magento\Framework\Exception\State\InvalidTransitionException

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF638T641

  */

https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#add-comment https://bitbucket.org/hmihmi/maplewellness/commits/c7b2c10c279c1e73b71c2ff9c52736a6f653ce6c#Lvendor/magento/module-paypal/Model/Payflowpro.phpF639T642

 public function processErrors(DataObject $response)

On Wed, Apr 18, 2018 at 3:37 PM, Grumag notifications@github.com wrote:

Not that I am aware of. We had to stop using the site until it is resolved. Awesome.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/7977#issuecomment-382550826, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIRtUAzbP0apiW6e0Meoh7IG2YbsXVdks5tp8AlgaJpZM4LWsj9 .

-- Best Regards, Henry Zou

amanuni commented 6 years ago

Hi Guys,

recently we have migrated from m1 to magento 2.2.2 and using paypal payflow have got strange issue some trasactions are showing in USD in paypal manager and some are in cad however default and allowed both currency is in CAD.

It would be great if you guys have any suggestion to fix this issue.

Grumag commented 6 years ago

Issue persists in 2.2.4. Maybe Adobe puts some money into Magento now and actually fixes the gazillion bugs.

amanuni commented 6 years ago

@Grumag which currency is your default currency

Grumag commented 6 years ago

Base Currency: Canadian Dollar Default Display Currency: Canadian Dollar Allowed Currencies: Canadian Dollar

rparsi commented 6 years ago

@magento-engcom-team Any progress on this? In the 2.2.5 release notes I see

Payment methods
In multistore environments, Magento now retrieves the correct PayPal Payflow Pro credentials. Previously, Magento always retrieved the credentials that are configured for the default store.

Does that fix this issue? If so what is the pull request number, or commit hash with the fix?

Grumag commented 6 years ago

Tested 2.2.5 in Single Store mode, Canadian store and PayPal, still charging USD.

Don't bother..

amanuni commented 6 years ago

Try to change default tax destination in Admin->Store->Configuration->Sales->Tax->Default Tax Destination->Default Country

To Canada

Grumag commented 6 years ago

Hi amauni, it is already Canada. If you require screenshots, videos, settings, $$$ let me know I will send.