use crate::context::crate_private::CratePrivate;
use crate::context::Context;
use crate::ComponentImports;
#[repr(C)]
pub struct StripeJsSdkInstanceHandle(i64);
impl StripeJsSdkInstanceHandle {
pub fn temporary_way_to_get_i64(&self) -> i64 {
self.0
}
}
#[repr(C)]
pub struct StripeElementsHandle(i64);
impl StripeElementsHandle {
pub fn temporary_way_to_get_i64(&self) -> i64 {
self.0
}
}
impl ComponentImports {
pub fn initialize_stripe<C: Context>(&self, context: C) {
let context = context.to_isize(CratePrivate);
unsafe { afia_component_sys::initialize_stripe(self.component_imports_ptr, context) };
}
pub fn create_stripe_elements(
&self,
handle: &StripeJsSdkInstanceHandle,
amount_cents: u32,
) -> StripeElementsHandle {
let elements = unsafe {
afia_component_sys::create_stripe_elements(
self.component_imports_ptr,
handle.0,
amount_cents,
)
};
StripeElementsHandle(elements)
}
pub fn submit_stripe_elements<C: Context>(&self, handle: &StripeElementsHandle, context: C) {
let context = context.to_isize(CratePrivate);
unsafe {
afia_component_sys::submit_stripe_elements(
self.component_imports_ptr,
handle.0,
context,
)
};
}
}