Hi @ck765765
I hope you’re well today!
The code that you use to fix the first issue is pretty old and shouldn’t be necessary anymore. The issue with JPY (and a few other currencies) was actually identified way more in the past than 6 months and should already be fixed. Fix was released over a year ago and since then we don’t have any active bugs open about it.
The code that you got added to the site does have a side-effect of stripping everything that’s after a dot or comma or similar non-digit characters. Your calculation field on the form – the one that you shared with us – currently is set to use commas as separators too.
So please try this:
1. make sure to set the calculation field (and fields that a used for calculation) to not use separators in value
2. and remove the code that you have added.
Fully clear all caches after that and test it. It should work then. If it still doesn’t, let us know.
Kind regards,
Adam
Thank you for your response.
I have checked to ensure the plugin is up to date and removed the additional code from the mu-plugin. I also adjusted the settings to avoid using commas in the calculation for {calculation-1}.
After clearing the cache and testing again, I encountered an issue where, after clicking the “PayPal Checkout” button, the error message appeared a few seconds later, without opening a new window.
When I checked the API logs on PayPal, it seems that the value is still being processed with a comma attached.
Below is a part of the PayPal API log results.
Status:400
Description:Request is not well-formed, syntactically incorrect, or violates schema.
"purchase_units": [
{
"amount": {
"currency_code": "JPY",
"value": "1,500"
}
}
],
The test payment on Stripe worked without any issues. I also checked the Stripe logs, and the values without commas were processed correctly.
-
This reply was modified 1 year, 9 months ago by
ck765765.
Hello @ck765765
Hope you’re doing well today!
I imported the form you shared on my lab site and made a test about the PayPal issue. I was able to replicate the Status: 400 Issue on trying to make the payment.
Based on my test, I was able to notice that the AJAX Payload sent by the form seemed fine and did not have the comma on the payload request, however, when I checked on the PayPal end, the request did also include a comma on the currency value, even when the calculation field was set to not use any separator.
Further, I also removed and readded the paypal field to see if that helps somehow, however, it did not make any difference.
Additionally, I also created a new form on my lab site and added a PayPal field to use JPY currency which was a similar setup like your form, and it worked fine. This makes me believe the issue could be limited to something within your form.
I have escalated the issue to our developer team to see if they can notice anything specific within the form that could be causing it, we will keep you posted about it here.
However, in the meantime, can you please try creating a new test form and see if the PayPal Field works fine?
Kind Regards,
Saurabh
Hello @ck765765
We got further feedback from our development team, can you please try using the following code snippet and let us know if still fixes the issue?
add_filter( 'forminator_paypal_create_order_request', 'wpmudev_fix_jpy_paypal_submit', 10, 2 );
function wpmudev_fix_jpy_paypal_submit( $request, $data ) {
if ( 46564 !== intval( $data['form_id'] ) ) { // Please change 46564 to your form's ID.
return $request;
}
$request['purchase_units'][0]['amount']['value'] = str_replace( ',', '', $request['purchase_units'][0]['amount']['value'] );
return $request;
}
Note: please change the 46564 to your form ID (the form ID can be found in your form shortcode).
It can be added as a mu-plugin on your site, you can find more information about how to implement the code here in these documents, and it would be better to test it first in a development environment.
https://developer.ww.wp.xz.cn/advanced-administration/plugins/mu-plugins/
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Kind Regards,
Amin
@wpmudev-support7
Thank you for your response.
I apologize for the delayed reply.
I created a new form and tested it again, but unfortunately, the error still occurs.
The website itself is built using Elementor, and I am displaying the Forminator form via a shortcode. Could that be one of the causes?
──────────
@wpmudev-support2
Thank you for the code snippet.
After implementing the code as an mu-plugin, the PayPal error was resolved, and I was able to proceed with the transaction with the correct amount.
I would like to continue using this code for the time being.
──────────
Your help was greatly appreciated. Thank you so much.
I am grateful for your thorough support.