【EC-CUBE4.x】PayPal payment plugin not work when you manage by NOT JPY currency.

I introduced PayPal payment plugin(1.0.4) to the website which manages by NOT JPY currency.
And I pushed PayPal payment button but it didn’t work.

If you were in the same situation, you would check the cause.

First of all, you add “paypal.debug: false” to the parameter sections of the following file.

app/Plugin/PayPalCheckOut/Resource/config/services.yaml

And you replicate the bug again.
As a result, the detail of the error is showed to the log files of under var/log.

Please check the following errors in the log files.

message: 'CreateOrderRequest has been failed'
...
'{"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"MULTI_CURRENCY_ORDER","description":"Multiple differing values of currency_code are not supported. Entire Order request must have the same currency_code."}]

After PayPal payment button is pushed, order datas is sended to PayPal server.
But you can find that this time has failed due to using multiple differing values of currency_code are not supported.

PayPal payment plugin is presupposed to using JPY. So when currency code on EC-CUBE changes another one, causes the above error and fails payments.

To deal this problem, you can correct the following file.

PayPalCheckout/Service/PayPalService.php (about 478-507 rows)

The point is to change currency_code from JPY to AUD (your site’s currency code).
If your site’s currency code deal demical point, you have to remove “roundedCurrencyFormat()” method.

By doing this, currency_code on order data is unified and be able to redirect to PayPal payment page.

ABOUTこの記事をかいた人

フリーランスとして働く、フルスタックエンジニア 初崎 匠のサイト。仕事のことから趣味のアニメーション制作、英語学習など、様々なことを通じて、少しでも多くの人が幸せになれるような価値を提供できるよう挑戦し続けます。