#fintech #shurjopay #payment-gateway #plugin

无需 std sp-plugin-rust-test

Rust 插件,用于快速集成 shurjopay API

9 个版本

0.3.6 2022年12月31日
0.3.5 2022年12月30日
0.2.0 2022年12月11日
0.1.0 2022年12月11日

#56 in 金融

MIT/Apache

46KB
732 代码行

image

ShurjoPay

Test Status Crate Book API API Minimum rustc version

Shurjopay 支付网关 Rust Crate

它处理了大多数人需要手动完成的事情

  • 处理 HTTP 请求和请求错误
  • JSON 序列化和反序列化
  • 结账期间的认证和支付验证

Shurjopay Rust 集成步骤

📝 注意 对于 shurjoPay 实时引擎集成,所有必要的凭证将在商在 shurjoPay 网关完成订阅后提供。

用法

将以下内容添加到您的 Cargo.toml

[dependencies]
sp-plugin-rust-test = "0.1.0"

Shurjopay-Rust-Plugin

要将 shurjoPay 支付网关集成到您的 Rust 项目中,请按以下任务顺序执行。

步骤:1 Cargo.toml 文件配置

[dependencies]
sp-plugin-rust-test = "0.1.0"

步骤:2 将 Crate 导入到您的项目中

use sp_plugin_rust_test::Shurjopay::ShurjopayPlugin;

步骤:3 创建 Shurjopay 插件的新实例

let mut sp_instance = ShurjopayPlugin::new();

配置 Shurjopay

步骤:4 设置 Shurjopay 插件的配置

您可以通过两种方式配置 ShurjopayPlugin

  • 选项1:使用 .env 文件配置插件
sp_instance.set_config_from_env_file();

这种方式,您需要这样配置 .env 文件。

*** 将 .toml 和 .evn 文件保存在同一目录下 ***

# .env
SP_USER="sp_sandbox"
SP_PASS="pyyk97hu&6u6"
POST_DEFAULT_ADDRESS="https://sandbox.shurjopayment.com"
TOKEN_END_POINT="/api/get_token"
SECURE_PAYMENT_END_POINT="/api/secret-pay"
VERIFICATION_END_POINT="/api/verification"
PAYMENT_STATUS_END_POINT="/api/payment-status"
DEFAULT_RETURN_URL="https://sandbox.shurjopayment.com/response"
DEFAULT_CANCEL_URL="https://sandbox.shurjopayment.com/response"
  • 选项2:使用此函数配置插件
sp_instance.set_all_config(
        "sp_sandbox".to_string(),
        "pyyk97hu&6u6".to_string(),
        "https://sandbox.shurjopayment.com".to_string(),
        "/api/get_token".to_string(),
        "/api/secret-pay".to_string(),
        "/api/verification".to_string(),
        "/api/payment-status".to_string(),
        "https://www.sandbox.shurjopayment.com/response".to_string(),
        "https://www.sandbox.shurjopayment.com/response".to_string(),
        );

发起支付

步骤:5 要发起支付,首先需要使用以下函数配置支付请求对象,并将其传递给 make_payment_no_auto_redirect() 函数

let payment_req_obj = sp_instance.make_payment_request_object(
    "786".to_string(),              // amount
    "abc123".to_string(),           // order_id
    "BDT".to_string(),              // currency
    "Mahmudul Islam".to_string(),   // customer_name
    "Dhaka".to_string(),            // customer_address
    "01811177722".to_string(),      // customer_phone
    "Dhaka".to_string(),            // customer_city
    "1203".to_string(),             // customer_post_code
    );
let checkout_url = sp_instance.make_payment(payment_req_obj) 

验证支付

步骤:6 要验证支付,您需要使用此函数

let response = sp_instance.verify_payment(Some("sp63935da67dfd3".to_string()));
println!("verify Payment Response:  {:?}",response);
if response.is_some()
{
		println!("{:#?}", response.unwrap().clone().sp_message.unwrap());
}

许可证

许可下

我该找谁?

For any technical assistance please contact to: https://shurjopay.com.bd/#contacts

依赖关系

~7–23MB
~301K SLoC