用户发起商品购买监听
业务场景
用户发起商品购买监听的回调,用来处理不同渠道侧推送给用户礼包后,用户点击了购买之后,CP 侧需要在回调里面发起支付流程。
适用范围:微信 | 抖音
流程图
无
接口介绍
public virtual void OnBuyProduct(BuyProductInfo info)
调用示例
// 用户点击商品购买的监听
public override void OnBuyProduct(BuyProductInfo buyInfo)
{
// 用户点击了渠道侧的商品购买,这里需调用支付接口下单,发起支付流程
int payType = buyInfo.payType;
// 发起支付
OrderInfo info = new OrderInfo();
info.amount = (buyInfo.data.amount / 100).ToString();
info.orderNo = "xxxxx";
info.productId = buyInfo.data.productId;
info.productName = buyInfo.data.productName;
info.extstr = buyInfo.toJson(); // 通过extstr返回给SDK
// 其他支付参数的处理....
SDKManager.GetInstance().Pay(info);
}
参数说明
入参
BuyProductInfo buyInfo
参数名称 | 类型 | 说明 | 最低版本 |
---|---|---|---|
payType | int | 支付类型,回传给支付 API 即可 | |
data | BuyProductDataInfo | 需要支付的商品信息 |
int payType
枚举值 | 说明 |
---|---|
1 | 虚拟支付(默认) |
2 | 小额/直接支付【抖音】 |
3 | 礼包支付【抖音】 |
4 | 商业组件【微信】 |
BuyProductDataInfo data
参数名称 | 类型 | 说明 | 最低版本 |
---|---|---|---|
amount | int | 价格,单位:分 | |
productId | string | CP 商品 ID | |
productName | string | 商品名 | |
giftId | string | 礼包 ID(礼包支付的时候返回) |
错误码
无
FAQ
无