Paypal currency BGN to EUR
-
Hi. I’m trying to implement a paypal checkout feature with Woocommerce. We do that by using the Woocommerce PayPal gateway for checkout. We want to have our default currency as BGN. The problem is PayPal doesn’t support Bulgarian lev so we have to find a way to change the currency to EUR on checkout. I found some code snippet that I used in functions.php of our child time.
<?php // allow BGN for WooCommerce and PayPal add_filter( 'woocommerce_paypal_supported_currencies', 'add_bgn_paypal_valid_currency' ); function add_bgn_paypal_valid_currency( $currencies ) { array_push ( $currencies , 'BGN' ); return $currencies; } // Convert BGN to EUR for PayPal payments add_filter('woocommerce_paypal_args', 'convert_bgn_to_eur'); function convert_bgn_to_eur($paypal_args){ if ( $paypal_args['currency_code'] == 'BGN'){ $convert_rate = 1.955; //set the converting rate $paypal_args['currency_code'] = 'EUR'; //change BGN to EUR $i = 1; while (isset($paypal_args['amount_' . $i])) { $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2); ++$i; } if (isset($paypal_args['tax_cart'])) { $paypal_args['tax_cart'] = round($paypal_args['tax_cart'] / $convert_rate, 2); } if (isset($paypal_args['shipping_1'])) { $paypal_args['shipping_1'] = round($paypal_args['shipping_1'] / $convert_rate, 2); } if ( $paypal_args['discount_amount_cart'] > 0 ) { $paypal_args['discount_amount_cart'] = round( $paypal_args['discount_amount_cart'] / $convert_rate, 2); } } return $paypal_args; }
The issue here is the woocommerce_paypal_args filter. I doubt that it’s working since it still returns an error when the user tries to make paypal purchase. Here is the response from PayPal:
message: “[UNPROCESSABLE_ENTITY] The requested action could not be performed, semantically incorrect, or failed business validation. https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED”
name: “UNPROCESSABLE_ENTITY”Now I’m sure the code called with the woocommerce_paypal_supported_currencies filter does work as it adds BGN as a currency code. Question is how to make the code called by the woocommerce_paypal_args filter actually work? I’ve tried debugging it but it doesn’t return anything. Is this filter working at all?
Woocommerce version: 5.9.0
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by .
- This topic was modified 3 years, 3 months ago by . Reason: final changes
- The topic ‘Paypal currency BGN to EUR’ is closed to new replies.