• Resolved ck765765

    (@ck765765)


    When using PayPal in JPY, a payment error occurs.

    The error occurs before the PayPal window opens.
    We were able to resolve this issue by applying the following code as an mu-plugin.
    Fix code: https://pastebin.com/LRZ0JRRr

    However, we are now facing a new issue.

    When making a payment of 1,000 JPY or more, the third digit is dropped, and only the digits from the fourth onward are recognized as the payment amount.
    Example: For a payment of 5,000 JPY, PayPal processes it as 5 JPY.
    We selected the format without commas in the calculation settings, but this did not resolve the issue.
    It seems that whether the payment amount is a fixed value or a calculated value doesn’t affect this issue.

    Here is the export of the form we are using.
    Form: https://pastebin.com/UVadUdU5

    I have reviewed other threads reported on the forum. It appears that this issue was confirmed more than six months ago, but it has not been fixed in the latest version. Has there been any progress since then?

    Since JCB card payments are not possible with Stripe, we would like to process JPY payments via PayPal. If an immediate update is difficult, is there a way to fix this issue using an mu-plugin?

    ※Sorry, I use the translator.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    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

    Thread Starter ck765765

    (@ck765765)

    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 2 months, 3 weeks ago by ck765765.
    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    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

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    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.www.ads-software.com/advanced-administration/plugins/mu-plugins/
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Kind Regards,
    Amin

    Thread Starter ck765765

    (@ck765765)

    @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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.