我们为卖家和客户搭建了一个平台。
使用 Stripe,这称为目的地费用,平台向客户收取费用,但实际的钱会转给卖家。然后卖家会看到他收到了金额,但不是由谁支付的(除了“通过我们的平台”)。
我在 C# ASP.NET 后端使用 Stripe.NET,但我的问题与技术无关。
我可以创建一个费用来完全按照上面描述的那样做。
示例代码:
var stripeCharge = stripeChargeService.Create(
new Stripe.ChargeCreateOptions
{
Amount = (int)(price * multiplier),
Currency = currency,
CustomerId = stripeCustomer.Id,
SourceId = source,
Destination = new Stripe.ChargeDestinationCreateOptions
{
Account = stripeSellerId
},
StatementDescriptor = "PLATFORM: " + invoiceNumber,
Description = "PLATFORM Payment for invoice number " + invoiceNumber,
Metadata = new Dictionary<string, string>
{
{ "InvoiceNumber", invoiceNumber }
}
});
Run Code Online (Sandbox Code Playgroud)
当我这样做时,它起作用了。我可以在我的平台帐户中看到费用。我可以在我的卖家帐户中看到付款。但是卖家没有得到我提供的任何信息。“描述”和“元数据”仅显示在我的平台帐户的费用中。卖家付款只说“123.45€”。呃......太好了......谁支付了他们的发票?事实上,我不在乎是谁。但支付哪张发票似乎是每个人建立平台或在平台上销售的核心要求。
我检查了 Stripe.NET 的文档,并检查了它是否比 Stripe API 本身更旧。但是没有我可以设置的参数。在没有什么ChargeDestinationCreateOptions我可以设置(类似DestinationDescription为例)。
卖家的描述字段存在,我可以在仪表板中看到它,但它是空的。那么我错过了什么?
如何设置卖家在进行“目的地收费”时可以在其帐户中看到的付款说明或元数据?
当您使用 Stripe 创建目的地费用时,会创建三个对象:
ch_xxx平台账户上的收费对象( )tr_xxx平台账户上的转账对象( ),表示向目标连接账户的转账。py_xxx连接帐户上的支付对象(在 API 级别上相当于费用对象),表示从转账中支付到该帐户的资金。从您的描述来看,这听起来像是您要在其上设置元数据或描述的第三个对象?您说得对,您不能直接在创建目的地费用的参数中执行此操作。但是,一旦创建了费用,您就可以轻松获取对创建的付款的引用,并使用所需字段对其进行更新:
var chargeService = new StripeChargeService();
chargeService.ExpandTransfer = true;
var chargeOptions = new StripeChargeCreateOptions
{
Amount = 1000,
Currency = "usd",
SourceTokenOrExistingSourceId = "tok_visa",
Description = "Payment for Invoice #42",
Destination = "acct_1DHFyLAXrgjEhAUx",
DestinationAmount = 800
};
var charge = chargeService.Create(chargeOptions);
var paymentId = charge.Transfer.DestinationPaymentId;
var paymentUpdateOptions = new StripeChargeUpdateOptions
{
Description = "Payment for Invoice #42"
};
chargeService.Update(paymentId, paymentUpdateOptions, new StripeRequestOptions
{
StripeConnectAccountId = "acct_1DHFyLAXrgjEhAUx"
});
Run Code Online (Sandbox Code Playgroud)
这里的关键点是收费对象链接到转账,而转账链接到付款。因此,通过将其与API的扩展对象功能相结合,您可以访问付款并对其进行更新!
| 归档时间: |
|
| 查看次数: |
2477 次 |
| 最近记录: |