#api-bindings #api #payment #swish

swish-api

Swish 支付 API 的 API 绑定

1 个不稳定版本

使用旧的 Rust 2015

0.1.0 2018 年 12 月 2 日

#2 in #swish

MIT/Apache

31KB
465

Swish

Rust API 绑定用于 Swish API。使用 hypertokio 构建。

使用方法

一个简单的使用示例

extern crate swish;
extern crate tokio_core;

use swish::{client, error};
use tokio_core::reactor::Core;

fn main() {
    let core = Core::new().unwrap();
    let handle = core.handle();
    let current_dir = env::current_dir()?;
    let cert_path = current_dir.join("./test_cert.p12");
    let root_cert_path = current_dir.join("./root_cert.der");

    let swish_client = cert_path
        .into_os_string()
        .to_str()
        .and_then(|cert_path_string| {
            root_cert_path
                .into_os_string()
                .to_str()
                .map(|root_cert_path_string| {
                    client::SwishClient::new(
                        "1231181189",
                        cert_path_string,
                        root_cert_path_string,
                        "swish",
                        handle,
                    )
                })
        })
        .unwrap();


    let mut payment_params = client::PaymentParams::default();
    payment_params.amount = 100.00;
    payment_params.payee_alias = "1231181189";
    payment_params.payee_payment_reference = Some("0123456789");
    payment_params.callback_url = "https://example.com/api/swishcb/paymentrequests";
    payment_params.message = Some("Kingston USB Flash Drive 8 GB");

    let payment = client.create_payment(payment_params);
    let payment: Result<client::CreatedPayment, error::SwishClientError> = core.run(payment);
}

功能和错误

请将功能请求和错误提交到 问题跟踪器

许可证

许可协议为以下之一

依赖项

~10–21MB
~281K SLoC