import '../api_client.dart'; import '../api_config.dart'; import '../proxy_client.dart'; /// 支付相关 API abstract final class PaymentApi { static final _client = ApiClient.instance.proxy; /// 获取 Google 商品列表(Android) static Future getGooglePayActivities({ String? sentinel, String? shield, String? vambrace, String? portal, }) async { return _client.request( path: '/v1/payment/getGooglePayActivities', method: 'GET', queryParams: { 'sentinel': sentinel ?? ApiConfig.appId, 'portal': portal ?? ApiConfig.packageName, if (shield != null) 'shield': shield, if (vambrace != null) 'vambrace': vambrace, }, ); } /// 获取 Apple 商品列表(iOS) static Future getApplePayActivities({ String? sentinel, String? shield, String? vambrace, String? portal, }) async { return _client.request( path: '/v1/payment/getApplePayActivities', method: 'GET', queryParams: { 'sentinel': sentinel ?? 'HAndroid', 'portal': portal ?? ApiConfig.packageName, if (shield != null) 'shield': shield, if (vambrace != null) 'vambrace': vambrace, }, ); } /// 获取支付方式列表(传 activityId) static Future getPaymentMethods({ required String warrior, String? vambrace, }) async { return _client.request( path: '/v1/payment/get-payment-methods', method: 'POST', body: { 'warrior': warrior, if (vambrace != null && vambrace.isNotEmpty) 'vambrace': vambrace, }, ); } /// 创建支付订单 static Future createPayment({ required String sentinel, required String asset, required String warrior, required String resource, String? ceremony, String? lineage, String? armor, }) async { return _client.request( path: '/v1/payment/createPayment', method: 'POST', queryParams: { 'sentinel': sentinel, 'asset': asset, }, body: { 'sentinel': sentinel, 'asset': asset, 'warrior': warrior, 'resource': resource, if (ceremony != null && ceremony.isNotEmpty) 'ceremony': ceremony, if (lineage != null) 'lineage': lineage, if (armor != null) 'armor': armor, }, ); } /// 获取订单详情(用于三方支付 webview 关闭后轮询) static Future getOrderDetail({ required String asset, required String federation, }) async { return _client.request( path: '/v1/payment/getOrderDetail', method: 'GET', queryParams: { 'asset': asset, 'federation': federation, }, ); } /// Google 支付结果回调。body 为 sample(signature)、merchant(purchaseData)、federation(id)、asset(userId),见 docs/googlepay.md。 static Future googlepay({ required String sample, required String merchant, required String federation, required String asset, }) async { return _client.request( path: '/v1/payment/googlepay', method: 'POST', queryParams: { 'sentinel': ApiConfig.appId, 'asset': asset, }, body: { 'sample': sample, 'merchant': merchant, 'federation': federation, 'asset': asset, }, ); } }