Payfast
一个开源的封装库,旨在使使用 Payfast API 和 Flutter 更加容易。
注意:仅在 Payfast 沙盒中进行了测试!
用法
添加导入
import 'package:payfast/payfast.dart';
设置简单的支付
var payfast = Payfast(
merchantId: 'merchant-id',
merchantKey: 'merchant-key',
passphrase: 'passphrase-set-in-sandbox',
paymentType: PaymentType.SimplePayment,
production: true || false,
);
payfast.createSimplePayment(
amount: 100,
itemName: 'Soap',
);
设置循环支付
var payfast = Payfast(
merchantId: 'merchant-id',
merchantKey: 'merchant-key',
passphrase: 'passphrase-set-in-sandbox',
paymentType: PaymentType.RecurringBilling,
production: true || false,
);
payfast.createSubsriptionPayment(
amount: 100,
itemName: 'CAS',
subscriptionType: SubscriptionType.subscription,
billingDate: '2022-07-06',
cycles: 2,
cyclePeriod: FrequencyCyclePeriod.Monthly,
recurringAmount: 100,
);
生成URL
print(payfast.generateURL());
受 https://github.com/GetTruck/payfast-js启发