add wasm function for billing connectors

This commit is contained in:
Spriti Aneja
2025-10-24 17:09:47 +05:30
parent 7b70d2454e
commit a805cadbda
5 changed files with 73 additions and 1 deletions

View File

@ -3,7 +3,7 @@ use std::collections::HashMap;
#[cfg(feature = "payouts")]
use api_models::enums::PayoutConnectors;
use api_models::{
enums::{AuthenticationConnectors, Connector, PmAuthConnectors, TaxConnectors},
enums::{AuthenticationConnectors, BillingConnectors, Connector, PmAuthConnectors, TaxConnectors},
payments,
};
use serde::{Deserialize, Serialize};
@ -418,6 +418,20 @@ impl ConnectorConfig {
}
}
pub fn get_billing_connector_config(
connector: BillingConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {
let connector_data = Self::new()?;
match connector {
BillingConnectors::Chargebee => Ok(connector_data.chargebee),
BillingConnectors::Stripebilling => Ok(connector_data.stripebilling),
BillingConnectors::Recurly => Ok(connector_data.recurly),
BillingConnectors::Custombilling => Ok(connector_data.custombilling),
#[cfg(feature = "dummy_connector")]
BillingConnectors::DummyBillingConnector => Ok(connector_data.dummy_connector),
}
}
pub fn get_authentication_connector_config(
connector: AuthenticationConnectors,
) -> Result<Option<ConnectorTomlConfig>, String> {

View File

@ -1584,6 +1584,20 @@ merchant_secret="Source verification key"
[celero.connector_auth.HeaderKey]
api_key="Celero API Key"
[chargebee]
[chargebee.connector_auth.HeaderKey]
api_key="Chargebee API Key"
[chargebee.connector_webhook_details]
merchant_secret="Username"
additional_secret="Password"
[chargebee.metadata.site]
name="site"
label="Site"
placeholder="Enter chargebee site"
required=true
type="Text"
[checkbook]
[[checkbook.bank_transfer]]

View File

@ -1350,6 +1350,21 @@ merchant_secret = "Source verification key"
[celero.connector_auth.HeaderKey]
api_key="Celero API Key"
[chargebee]
[chargebee.connector_auth.HeaderKey]
api_key="Chargebee API Key"
[chargebee.connector_webhook_details]
merchant_secret="Username"
additional_secret="Password"
[chargebee.metadata.site]
name="site"
label="Site"
placeholder="Enter chargebee site"
required=true
type="Text"
[checkbook]
[[checkbook.bank_transfer]]
payment_method_type = "ach"

View File

@ -1583,6 +1583,20 @@ merchant_secret = "Source verification key"
[celero.connector_auth.HeaderKey]
api_key="Celero API Key"
[chargebee]
[chargebee.connector_auth.HeaderKey]
api_key="Chargebee API Key"
[chargebee.connector_webhook_details]
merchant_secret="Username"
additional_secret="Password"
[chargebee.metadata.site]
name="site"
label="Site"
placeholder="Enter chargebee site"
required=true
type="Text"
[checkbook]
[[checkbook.bank_transfer]]
@ -4619,6 +4633,13 @@ required = true
type = "MultiSelect"
options = ["PAN_ONLY", "CRYPTOGRAM_3DS"]
[stripebilling]
[stripebilling.connector_auth.HeaderKey]
api_key="Stripe Billing API Key"
[stripebilling.connector_webhook_details]
merchant_secret="Username"
additional_secret="Password"
[stax]
[[stax.credit]]

View File

@ -381,6 +381,14 @@ pub fn get_connector_config(key: &str) -> JsResult {
Ok(serde_wasm_bindgen::to_value(&res)?)
}
#[wasm_bindgen(js_name = getBillingConnectorConfig)]
pub fn get_billing_connector_config(key: &str) -> JsResult {
let key = api_model_enums::BillingConnectors::from_str(key)
.map_err(|_| "Invalid key received".to_string())?;
let res = connector::ConnectorConfig::get_billing_connector_config(key)?;
Ok(serde_wasm_bindgen::to_value(&res)?)
}
#[cfg(feature = "payouts")]
#[wasm_bindgen(js_name = getPayoutConnectorConfig)]
pub fn get_payout_connector_config(key: &str) -> JsResult {