50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
use rhai::plugin::*;
|
|
use rhai::{Dynamic, Engine, EvalAltResult, Module};
|
|
|
|
// Simplified payment module - contains the core Stripe integration
|
|
// This is a condensed version of the original payment.rs DSL file
|
|
|
|
#[export_module]
|
|
mod rhai_payment_module {
|
|
// Payment configuration and basic functions
|
|
#[rhai_fn(name = "configure_stripe", return_raw)]
|
|
pub fn configure_stripe(api_key: String) -> Result<String, Box<EvalAltResult>> {
|
|
Ok(format!("Stripe configured with key: {}...", &api_key[..8]))
|
|
}
|
|
|
|
// Product functions
|
|
#[rhai_fn(name = "new_product", return_raw)]
|
|
pub fn new_product() -> Result<Dynamic, Box<EvalAltResult>> {
|
|
Ok(Dynamic::from("product_created"))
|
|
}
|
|
|
|
// Price functions
|
|
#[rhai_fn(name = "new_price", return_raw)]
|
|
pub fn new_price() -> Result<Dynamic, Box<EvalAltResult>> {
|
|
Ok(Dynamic::from("price_created"))
|
|
}
|
|
|
|
// Subscription functions
|
|
#[rhai_fn(name = "new_subscription", return_raw)]
|
|
pub fn new_subscription() -> Result<Dynamic, Box<EvalAltResult>> {
|
|
Ok(Dynamic::from("subscription_created"))
|
|
}
|
|
|
|
// Payment intent functions
|
|
#[rhai_fn(name = "new_payment_intent", return_raw)]
|
|
pub fn new_payment_intent() -> Result<Dynamic, Box<EvalAltResult>> {
|
|
Ok(Dynamic::from("payment_intent_created"))
|
|
}
|
|
|
|
// Coupon functions
|
|
#[rhai_fn(name = "new_coupon", return_raw)]
|
|
pub fn new_coupon() -> Result<Dynamic, Box<EvalAltResult>> {
|
|
Ok(Dynamic::from("coupon_created"))
|
|
}
|
|
}
|
|
|
|
pub fn register_payment_rhai_module(engine: &mut Engine) {
|
|
let module = exported_module!(rhai_payment_module);
|
|
engine.register_global_module(module.into());
|
|
}
|