From c2e0a9530be304cbd3f499b8fc3b38b82747cb94 Mon Sep 17 00:00:00 2001 From: Yash Tripathi Date: Fri, 19 Jul 2024 16:29:55 +0530 Subject: [PATCH] Added support for additional currencies --- razorpay.php | 19 ++ supported-currencies.json | 544 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 563 insertions(+) create mode 100644 supported-currencies.json diff --git a/razorpay.php b/razorpay.php index a15bb1e..fe598c5 100644 --- a/razorpay.php +++ b/razorpay.php @@ -38,6 +38,25 @@ public static function load() GFAddOn::register('GFRazorpay'); add_filter('gform_currencies', function (array $currencies) { + + $supported_currencies = json_decode(file_get_contents(__DIR__ . "/supported-currencies.json"), true)['supported-currencies']; + + foreach ($supported_currencies as $k => $v) + { + if (in_array($v['iso_code'], $currencies) === false) + { + $currencies[$v['iso_code']] = array( + 'name' => __( $v['currency_name'], 'gravityforms' ), + 'code' => $v['iso_code'], + 'symbol_left' => $v['iso_code'], + 'symbol_right' => '', + 'symbol_padding' => ' ', + 'thousand_separator' => ',', + 'decimal_separator' => '.', + 'decimals' => $v['exponent'] + ); + } + } $currencies['INR'] = array( 'name' => __( 'Indian Rupee', 'gravityforms' ), 'code' => 'INR', diff --git a/supported-currencies.json b/supported-currencies.json new file mode 100644 index 0000000..775458f --- /dev/null +++ b/supported-currencies.json @@ -0,0 +1,544 @@ +{ + "supported-currencies": [ + { + "currency_name": "United Arab Emirates Dirham", + "iso_code": "AED", + "exponent": "2" + }, + { + "currency_name": "Albanian lek", + "iso_code": "ALL", + "exponent": "2" + }, + { + "currency_name": "Armenian dram", + "iso_code": "AMD", + "exponent": "2" + }, + { + "currency_name": "Argentine peso", + "iso_code": "ARS", + "exponent": "2" + }, + { + "currency_name": "Australian dollar", + "iso_code": "AUD", + "exponent": "2" + }, + { + "currency_name": "Aruban florin", + "iso_code": "AWG", + "exponent": "2" + }, + { + "currency_name": "Azerbaijan Manat", + "iso_code": "AZN", + "exponent": "2" + }, + { + "currency_name": "Convertible Mark", + "iso_code": "BAM", + "exponent": "2" + }, + { + "currency_name": "Barbadian dollar", + "iso_code": "BBD", + "exponent": "2" + }, + { + "currency_name": "Bangladeshi taka", + "iso_code": "BDT", + "exponent": "2" + }, + { + "currency_name": "Bulgarian Lev", + "iso_code": "BGN", + "exponent": "2" + }, + { + "currency_name": "Bermudian dollar", + "iso_code": "BMD", + "exponent": "2" + }, + { + "currency_name": "Brunei dollar", + "iso_code": "BND", + "exponent": "2" + }, + { + "currency_name": "Bolivian boliviano", + "iso_code": "BOB", + "exponent": "2" + }, + { + "currency_name": "Brazilian Real", + "iso_code": "BRL", + "exponent": "2" + }, + { + "currency_name": "Bahamian dollar", + "iso_code": "BSD", + "exponent": "2" + }, + { + "currency_name": "Bhutanese Ngultrum", + "iso_code": "BTN", + "exponent": "2" + }, + { + "currency_name": "Botswana pula", + "iso_code": "BWP", + "exponent": "2" + }, + { + "currency_name": "Belize dollar", + "iso_code": "BZD", + "exponent": "2" + }, + { + "currency_name": "Canadian dollar", + "iso_code": "CAD", + "exponent": "2" + }, + { + "currency_name": "Swiss franc", + "iso_code": "CHF", + "exponent": "2" + }, + { + "currency_name": "Chinese yuan renminbi", + "iso_code": "CNY", + "exponent": "2" + }, + { + "currency_name": "Colombian peso", + "iso_code": "COP", + "exponent": "2" + }, + { + "currency_name": "Costa Rican colon", + "iso_code": "CRC", + "exponent": "2" + }, + { + "currency_name": "Cuban peso", + "iso_code": "CUP", + "exponent": "2" + }, + { + "currency_name": "Cabo Verde Escudo", + "iso_code": "CVE", + "exponent": "2" + }, + { + "currency_name": "Czech koruna", + "iso_code": "CZK", + "exponent": "2" + }, + { + "currency_name": "Danish krone", + "iso_code": "DKK", + "exponent": "2" + }, + { + "currency_name": "Dominican peso", + "iso_code": "DOP", + "exponent": "2" + }, + { + "currency_name": "Algerian dinar", + "iso_code": "DZD", + "exponent": "2" + }, + { + "currency_name": "Egyptian pound", + "iso_code": "EGP", + "exponent": "2" + }, + { + "currency_name": "Ethiopian birr", + "iso_code": "ETB", + "exponent": "2" + }, + { + "currency_name": "European euro", + "iso_code": "EUR", + "exponent": "2" + }, + { + "currency_name": "Fijian dollar", + "iso_code": "FJD", + "exponent": "2" + }, + { + "currency_name": "Pound sterling", + "iso_code": "GBP", + "exponent": "2" + }, + { + "currency_name": "Ghanian Cedi", + "iso_code": "GHS", + "exponent": "2" + }, + { + "currency_name": "Gibraltar pound", + "iso_code": "GIP", + "exponent": "2" + }, + { + "currency_name": "Gambian dalasi", + "iso_code": "GMD", + "exponent": "2" + }, + { + "currency_name": "Guatemalan quetzal", + "iso_code": "GTQ", + "exponent": "2" + }, + { + "currency_name": "Guyanese dollar", + "iso_code": "GYD", + "exponent": "2" + }, + { + "currency_name": "Hong Kong dollar", + "iso_code": "HKD", + "exponent": "2" + }, + { + "currency_name": "Honduran lempira", + "iso_code": "HNL", + "exponent": "2" + }, + { + "currency_name": "Croatian kuna", + "iso_code": "HRK", + "exponent": "2" + }, + { + "currency_name": "Haitian gourde", + "iso_code": "HTG", + "exponent": "2" + }, + { + "currency_name": "Hungarian forint", + "iso_code": "HUF", + "exponent": "2" + }, + { + "currency_name": "Indonesian rupiah", + "iso_code": "IDR", + "exponent": "2" + }, + { + "currency_name": "Israeli new shekel", + "iso_code": "ILS", + "exponent": "2" + }, + { + "currency_name": "Indian rupee", + "iso_code": "INR", + "exponent": "2" + }, + { + "currency_name": "Jamaican dollar", + "iso_code": "JMD", + "exponent": "2" + }, + { + "currency_name": "Kenyan shilling", + "iso_code": "KES", + "exponent": "2" + }, + { + "currency_name": "Kyrgyzstani som", + "iso_code": "KGS", + "exponent": "2" + }, + { + "currency_name": "Cambodian riel", + "iso_code": "KHR", + "exponent": "2" + }, + { + "currency_name": "Cayman Islands dollar", + "iso_code": "KYD", + "exponent": "2" + }, + { + "currency_name": "Kazakhstani tenge", + "iso_code": "KZT", + "exponent": "2" + }, + { + "currency_name": "Lao kip", + "iso_code": "LAK", + "exponent": "2" + }, + { + "currency_name": "Sri Lankan rupee", + "iso_code": "LKR", + "exponent": "2" + }, + { + "currency_name": "Liberian dollar", + "iso_code": "LRD", + "exponent": "2" + }, + { + "currency_name": "Lesotho loti", + "iso_code": "LSL", + "exponent": "2" + }, + { + "currency_name": "Moroccan dirham", + "iso_code": "MAD", + "exponent": "2" + }, + { + "currency_name": "Moldovan leu", + "iso_code": "MDL", + "exponent": "2" + }, + { + "currency_name": "Malagasy Ariary", + "iso_code": "MGA", + "exponent": "2" + }, + { + "currency_name": "Macedonian denar", + "iso_code": "MKD", + "exponent": "2" + }, + { + "currency_name": "Myanmar kyat", + "iso_code": "MMK", + "exponent": "2" + }, + { + "currency_name": "Mongolian tugrik", + "iso_code": "MNT", + "exponent": "2" + }, + { + "currency_name": "Macanese pataca", + "iso_code": "MOP", + "exponent": "2" + }, + { + "currency_name": "Mauritian rupee", + "iso_code": "MUR", + "exponent": "2" + }, + { + "currency_name": "Maldivian rufiyaa", + "iso_code": "MVR", + "exponent": "2" + }, + { + "currency_name": "Malawian kwacha", + "iso_code": "MWK", + "exponent": "2" + }, + { + "currency_name": "Mexican peso", + "iso_code": "MXN", + "exponent": "2" + }, + { + "currency_name": "Malaysian ringgit", + "iso_code": "MYR", + "exponent": "2" + }, + { + "currency_name": "Mozambique Metical", + "iso_code": "MZN", + "exponent": "2" + }, + { + "currency_name": "Namibian dollar", + "iso_code": "NAD", + "exponent": "2" + }, + { + "currency_name": "Nigerian naira", + "iso_code": "NGN", + "exponent": "2" + }, + { + "currency_name": "Nicaraguan cordoba", + "iso_code": "NIO", + "exponent": "2" + }, + { + "currency_name": "Norwegian krone", + "iso_code": "NOK", + "exponent": "2" + }, + { + "currency_name": "Nepalese rupee", + "iso_code": "NPR", + "exponent": "2" + }, + { + "currency_name": "New Zealand dollar", + "iso_code": "NZD", + "exponent": "2" + }, + { + "currency_name": "Peruvian sol", + "iso_code": "PEN", + "exponent": "2" + }, + { + "currency_name": "Papua New Guinean kina", + "iso_code": "PGK", + "exponent": "2" + }, + { + "currency_name": "Philippine peso", + "iso_code": "PHP", + "exponent": "2" + }, + { + "currency_name": "Pakistani rupee", + "iso_code": "PKR", + "exponent": "2" + }, + { + "currency_name": "Polish Zloty", + "iso_code": "PLN", + "exponent": "2" + }, + { + "currency_name": "Qatari riyal", + "iso_code": "QAR", + "exponent": "2" + }, + { + "currency_name": "Romanian Leu", + "iso_code": "RON", + "exponent": "2" + }, + { + "currency_name": "Serbian Dinar", + "iso_code": "RSD", + "exponent": "2" + }, + { + "currency_name": "Russian ruble", + "iso_code": "RUB", + "exponent": "2" + }, + { + "currency_name": "Saudi Arabian riyal", + "iso_code": "SAR", + "exponent": "2" + }, + { + "currency_name": "Seychellois rupee", + "iso_code": "SCR", + "exponent": "2" + }, + { + "currency_name": "Swedish krona", + "iso_code": "SEK", + "exponent": "2" + }, + { + "currency_name": "Singapore dollar", + "iso_code": "SGD", + "exponent": "2" + }, + { + "currency_name": "Sierra Leonean leone", + "iso_code": "SLL", + "exponent": "2" + }, + { + "currency_name": "Somali shilling", + "iso_code": "SOS", + "exponent": "2" + }, + { + "currency_name": "South Sudanese pound", + "iso_code": "SSP", + "exponent": "2" + }, + { + "currency_name": "Salvadoran colón", + "iso_code": "SVC", + "exponent": "2" + }, + { + "currency_name": "Swazi lilangeni", + "iso_code": "SZL", + "exponent": "2" + }, + { + "currency_name": "Thai baht", + "iso_code": "THB", + "exponent": "2" + }, + { + "currency_name": "Turkish Lira", + "iso_code": "TRY", + "exponent": "2" + }, + { + "currency_name": "Trinidad and Tobago dollar", + "iso_code": "TTD", + "exponent": "2" + }, + { + "currency_name": "New Taiwan Dollar", + "iso_code": "TWD", + "exponent": "2" + }, + { + "currency_name": "Tanzanian shilling", + "iso_code": "TZS", + "exponent": "2" + }, + { + "currency_name": "Ukrainian Hryvnia", + "iso_code": "UAH", + "exponent": "2" + }, + { + "currency_name": "United States dollar", + "iso_code": "USD", + "exponent": "2" + }, + { + "currency_name": "Uruguayan peso", + "iso_code": "UYU", + "exponent": "2" + }, + { + "currency_name": "Uzbekistani so'm", + "iso_code": "UZS", + "exponent": "2" + }, + { + "currency_name": "East Caribbean Dollar", + "iso_code": "XCD", + "exponent": "2" + }, + { + "currency_name": "Yemeni rial", + "iso_code": "YER", + "exponent": "2" + }, + { + "currency_name": "South African rand", + "iso_code": "ZAR", + "exponent": "2" + }, + { + "currency_name": "Zambian Kwacha", + "iso_code": "ZMW", + "exponent": "2" + } + ] + } \ No newline at end of file