You are here

function commerce_stripe_payment_currencies in Commerce Stripe 7.3

Supported payment currencies will vary by location of the Stripe account.

return array An associative array of three-character currency codes.

2 calls to commerce_stripe_payment_currencies()
commerce_stripe_requirements in ./commerce_stripe.install
Implements hook_requirements().
commerce_stripe_settings_form in ./commerce_stripe.module
Payment method settings form.

File

./commerce_stripe.module, line 1707
This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.

Code

function commerce_stripe_payment_currencies() {
  commerce_stripe_load_library();
  $supported_currencies = array();
  $payment_method = commerce_payment_method_instance_load('commerce_stripe|commerce_payment_commerce_stripe');
  if (!empty($payment_method['settings']['secret_key']) || !empty($payment_method['settings']['use_connected_account']) && $payment_method['settings']['use_connected_account'] == 'site account') {
    _commerce_stripe_set_api_key($payment_method);
    try {
      $info = \Stripe\Account::retrieve();
      $country_spec = \Stripe\CountrySpec::retrieve($info->country);
      $supported_currencies = $country_spec->supported_payment_currencies;
    } catch (Exception $e) {
      drupal_set_message(check_plain($e
        ->getMessage()), 'error');
    }
  }
  return $supported_currencies;
}