Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(wasm): fetch list of country codes and country names (#7642)
Sayak Bhattacharya63d9b534d0b6
diff --git a/crates/euclid_wasm/src/lib.rs b/crates/euclid_wasm/src/lib.rsindex f977fc4554..9b945c7513 100644--- a/crates/euclid_wasm/src/lib.rs+++ b/crates/euclid_wasm/src/lib.rs@@ -32,6 +32,9 @@ use wasm_bindgen::prelude::*;use crate::utils::JsResultExt;type JsResult = Result<JsValue, JsValue>;+use api_models::payment_methods::CountryCodeWithName;+use common_enums::CountryAlpha2;+use strum::IntoEnumIterator;struct SeedData {cgraph: hyperswitch_constraint_graph::ConstraintGraph<dir::DirValue>,@@ -73,6 +76,20 @@ pub fn convert_forex_value(amount: i64, from_currency: JsValue, to_currency: JsVOk(serde_wasm_bindgen::to_value(&converted_amount)?)}+/// This function can be used by the frontend to get all the two letter country codes+/// along with their country names.+#[wasm_bindgen(js_name=getTwoLetterCountryCode)]+pub fn get_two_letter_country_code() -> JsResult {+ let country_code_with_name = CountryAlpha2::iter()+ .map(|country_code| CountryCodeWithName {+ code: country_code,+ name: common_enums::Country::from_alpha2(country_code),+ })+ .collect::<Vec<_>>();++ Ok(serde_wasm_bindgen::to_value(&country_code_with_name)?)+}+/// This function can be used by the frontend to provide the WASM with information about/// all the merchant's connector accounts. The input argument is a vector of all the merchant's/// connector accounts from the API.