bazzar/crates/payment_adapter
2023-05-16 21:34:46 +02:00
..
src Implement dynamic payment session 2023-05-16 21:34:46 +02:00
Cargo.toml Medusa 2023-05-15 22:55:09 +02:00
Readme.adoc Start update status 2022-12-15 15:10:21 +01:00

= Payment Adapter Implementation

== Extention Lifetime

Payment Adapter extension is loaded as WASI file and initialize as a module.
Then to store it in runtime `name` function is called to load extension unique `name` (`String`).

Using this `name` extension configuration from application configuration, names must match! In config is missing is missing application will print error message is stop.

Then configuration is passed to extension to setup client. If everything goes as expected it should return `Status::Success`, in any other situation it must return `Status::Failure`, this also will cause to print error message and stop application.

Lastly if extension will be be dropped for some reason it will be detached from store and `teardown` function will be called.

1. `name`
2. `init`
3. `teardown`

== Example

[rust]
```
/// Mandatory for WASM runtime
#[no_mangle]
pub fn wapc_init() {
    wapc::register_function("name", name);
    wapc::register_function("init", init);
    wapc::register_function("teardown", teardown);
    wapc::register_function("create_payment", create_payment);
    wapc::register_function("cancel_order", cancel_order);
    wapc::register_function("update_status", update_status);
}
```