/** * Get the currency to use for Stripe transactions. * * At all stages attempt to use the Site Currency and ultimately fallback to the Stripe currency set in the gateway * settings. Note, Stripe will revert to merchant currency if a currency is not supported. Bonus! * * @return mixed|void */ public static function currency() { global $psts; $stripe_currency = $psts->get_setting('stripe_currency', 'USD'); $currency = $psts->get_setting('currency', $stripe_currency); $currency = ProSites_Helper_Gateway::supports_currency($currency, 'stripe') ? $currency : $stripe_currency; return $currency; }
/** * Return Currency for Paypal * @return mixed|void */ private static function currency() { global $psts; //Get the general currency set in Pro Sites $paypal_currency = $psts->get_setting('pypl_currency', 'USD'); $currency = $psts->get_setting('currency', $paypal_currency); //Check if PayPal supports the selected currency $supported = ProSites_Helper_Gateway::supports_currency($currency, 'paypal'); //Choose the selected currency $sel_currency = $supported ? $currency : $psts->get_setting('pypl_currency'); return $sel_currency; }
/** * 'Payment Settings' * * @return string */ public static function render_tab_payment() { global $psts; ProSites_Helper_Settings::settings_header(ProSites_Helper_Tabs_Settings::get_active_tab()); ?> <div class="inside"> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Currency', 'psts'); echo $psts->help_text(esc_html__('This is the currency that customers will be charged in. Your gateway currency is a fall-back option.', 'psts'), 'site-currency'); ?> </th> <td> <select id="psts-currency-select" name="psts[currency]" class="chosen" data-placeholder="<?php echo esc_attr__('Enable gateways', 'psts'); ?> "> <?php $super = array('⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹'); $gateways = ProSites_Helper_Gateway::get_gateways(); $count = 0; $supported_key = ''; foreach ($gateways as $key => $gateway) { if ('manual' == $key) { continue; } $count++; $gateways[$key]['idx'] = $count; if ($count > 1) { $supported_key .= '<sup> | </sup>'; } $supported_key .= '<sup>' . $count . ' - ' . $gateway['name'] . '</sup>'; } // supports_currency // foreach ( $psts->currencies as $key => $value ) { $all_currencies = ProSites_Model_Data::$currencies; ksort($all_currencies); foreach ($all_currencies as $key => $currency) { $supported_by = ''; foreach ($gateways as $slug => $gateway) { if (ProSites_Helper_Gateway::supports_currency($key, $slug)) { if (strlen($supported_by) > 0) { $supported_by .= '⁻'; } $supported_by .= $super[$gateway['idx']]; } } ?> <option value="<?php echo $key; ?> "<?php selected($psts->get_setting('currency'), $key); ?> ><?php echo esc_attr(strtoupper($key)) . '' . $supported_by . ' - ' . esc_attr($currency['name']) . ' - ' . $psts->format_currency($key); ?> </option><?php } ?> </select> <div> <?php echo $supported_key; ?> <br /> <?php echo sprintf('<sup>%s</sup>', esc_html__('Note: Where a currency is not supported by your gateway it may revert to your merchant account currency. (e.g. Stripe)', 'psts')); ?> <?php echo sprintf('<sup><br />%s</sup>', esc_html__('Note: Updating your site currency might take time to load, please be patient.', 'psts')); ?> </div> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Currency Symbol Position', 'psts'); ?> </th> <td> <label><input value="1" name="psts[curr_symbol_position]" type="radio"<?php checked($psts->get_setting('curr_symbol_position', 1), 1); ?> > <?php echo $psts->format_currency(); ?> 100</label><br/> <label><input value="2" name="psts[curr_symbol_position]" type="radio"<?php checked($psts->get_setting('curr_symbol_position'), 2); ?> > <?php echo $psts->format_currency(); ?> 100</label><br/> <label><input value="3" name="psts[curr_symbol_position]" type="radio"<?php checked($psts->get_setting('curr_symbol_position'), 3); ?> > 100<?php echo $psts->format_currency(); ?> </label><br/> <label><input value="4" name="psts[curr_symbol_position]" type="radio"<?php checked($psts->get_setting('curr_symbol_position'), 4); ?> > 100 <?php echo $psts->format_currency(); ?> </label> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Show Decimal in Prices', 'psts'); ?> </th> <td> <label><input value="1" name="psts[curr_decimal]" type="radio"<?php checked($psts->get_setting('curr_decimal', 1), 1); ?> > <?php _e('Yes', 'psts'); ?> </label> <label><input value="0" name="psts[curr_decimal]" type="radio"<?php checked($psts->get_setting('curr_decimal'), 0); ?> > <?php _e('No', 'psts'); ?> </label> </td> </tr> </table> </div> <?php }