Flutter支付处理插件seerbit_flutter的使用
Flutter支付处理插件seerbit_flutter的使用
 
Seerbit Flutter SDK
Seerbit Flutter SDK 可用于将 SeerBit 支付网关集成到您的 Flutter 应用程序中。
要求
注册一个商家账户以开始使用:
- Dart SDK: >=3.4.3 <4.0.0
- Flutter: >=1.17.0
- Android: 最低 SDK 版本为 17,并添加对 androidx 的支持(查看 AndroidX 迁移来迁移现有应用)
- iOS: 使用 Swift,Xcode 版本 >= 12
安装
flutter pub get seerbit_flutter
API 文档
支持
如果您有任何问题、疑问或建议,请在这里创建一个问题或发送邮件至 care@seerbit.com
实现
您应该已经拥有您的 API 密钥。如果没有,请访问 https://dashboard.seerbitapi.com。登录 -> 设置菜单 -> API 密钥菜单 -> 复制您的公钥
属性
| 属性 | 类型 | 必须 | 默认值 | 描述 | 
|---|---|---|---|---|
| currency | String | 可选 | NGN | 交易货币,例如 NGN | 
| String | 必须 | 无 | 用户的电子邮件地址 | |
| description | String | 可选 | 无 | 交易描述,可选 | 
| fullName | String | 可选 | 无 | 需要收费的用户的全名 | 
| country | String | 可选 | 无 | 交易国家,可选 | 
| transRef | String | 必须 | 无 | 每笔交易设置一个唯一的交易参考 | 
| amount | String | 必须 | 无 | 交易金额(单位为 kobo) | 
| callbackUrl | String | 可选 | 无 | 成功交易时的重定向 URL | 
| publicKey | String | 必须 | 无 | 您的公钥或参见上述步骤获取自己的公钥 | 
| closeOnSuccess | bool | 可选 | False | 成功交易时关闭结账 | 
| closePrompt | bool | 可选 | False | 如果未启动交易则关闭结账页面 | 
| setAmountByCustomer | bool | 可选 | False | 设置为 true 如果希望用户输入交易金额 | 
| pocketRef | String | 可选 | 无 | 您的口袋参考,适用于有口袋的供应商 | 
| vendorId | String | 可选 | 无 | 您业务的供应商ID | 
| tokenize | bool | 可选 | False | 对卡进行标记化 | 
| planId | String | 可选 | 无 | 订阅计划ID | 
| customization | CustomizationModel | 可选 | CustomizationModel | 自定义模式(borderColor: “#000000”, backgroundColor: “#004C64”, buttonColor: “#0084A0”, paymentMethod: [PayChannel.card, PayChannel.account, PayChannel.transfer, PayChannel.momo], confetti: false, logo: “logo_url 或 base64”) | 
| onSuccess | Method | 可选 | 无 | 成功交易时的回调方法 | 
| onCancel | Method | 可选 | 无 | 交易取消时的回调方法 | 
使用
import 'package:flutter/material.dart';
import 'package:seerbit_flutter/seerbit_flutter.dart';
class CheckOut extends StatelessWidget {
  const CheckOut({Key? key}) : super(key: key);
  SeerbitMethod SeerBit = new SeerbitMethod();
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      height: 1000,
      width: 500,
      child: Center(
        child: TextButton(
          onPressed: () => paymentStart(context),
          child: Text(
            "Checkout",
            style: TextStyle(color: Colors.red),
          ),
        ),
      ),
    );
  }
  paymentStart(context) {
    PayloadModel payload = PayloadModel(
      currency: 'NGN',
      email: "hellxo@gmxail.com",
      description: "Sneakers",
      fullName: "General ZxXXod",
      country: "NG",
      amount: "102",
      transRef: Random().nextInt(2000).toString(),
      publicKey: "merchant_public_key",
      pocketRef: "",
      vendorId: "vendorId",
      closeOnSuccess: false,
      closePrompt: false,
      setAmountByCustomer: false,
      tokenize: false,
      planId: "",
      customization: CustomizationModel(
        borderColor: "#000000",
        backgroundColor: "#004C64",
        buttonColor: "#0084A0",
        paymentMethod: [PayChannel.account, PayChannel.transfer, PayChannel.card, PayChannel.momo],
        confetti: false,
        logo: "logo_url 或 base64",
      )
    );
    SeerBit.startPayment(
      context, 
      payload: payload,
      onSuccess: (_) { print(_);}, 
      onCancel: (_) { print('*' * 400);}
    );
  }
}
onSuccess 会收到一个包含支付请求响应的 Map。
在支付过程中,您可以简单地通过调用来结束流程:
SeerbitMethod.endPayment(context);
更多关于Flutter支付处理插件seerbit_flutter的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
        
          1 回复
        
      
      
         
        
       
             
             
            


