C# 条带连接API更新PaymentIntent

C# 条带连接API更新PaymentIntent,c#,stripe-payments,C#,Stripe Payments,我在API中使用stripe connect,我想更新现有的paymentIntent。API的官方库提供了这些方法 public PaymentIntent Get(string paymentIntentId, PaymentIntentGetOptions options = null, RequestOptions requestOptions = null) public PaymentIntent Update(string paymentIntentId, Pa

我在API中使用stripe connect,我想更新现有的paymentIntent。API的官方库提供了这些方法

public PaymentIntent Get(string paymentIntentId, 
    PaymentIntentGetOptions options = null, RequestOptions requestOptions = null)
public PaymentIntent Update(string paymentIntentId, 
    PaymentIntentUpdateOptions options, RequestOptions requestOptions = null);
我只想更新资源的目的地,所以我在意识到没有简单的方法之前就开始更新:

var paymentIntentService = new PaymentIntentService();
var paymentIntent = paymentIntentService.Get(transaction.ExternalTransactionId);

if (null != destinationStripeAccount)
{
    paymentIntent.TransferData.DestinationId = destinationStripeAccount.AccountId;
}

//This takes in a PaymentIntentUpdateOptions instead of a paymentIntent WTF
paymentIntentService.Update(paymentIntent.Id, new PaymentIntentUpdateOptions {  });
PaymentIntent不是PaymentIntentUpdate选项,因此我需要将所有值映射到其他值。我宁愿不需要安装像AutoMapper这样的附加依赖项,手动映射字段会很麻烦


有人知道是否有一种方法可以只更新目的地,还是有一种简单的方法可以更新支付意图

因为根据文档,大多数成员都是可选的,我相信您只需要提供需要更改/更新到options对象的内容

var paymentIntentService = new PaymentIntentService();
var paymentIntent = paymentIntentService.Get(transaction.ExternalTransactionId);

if (null != destinationStripeAccount) {
    var options = new PaymentIntentUpdateOptions() {
        TransferData = new PaymentIntentTransferDataOptions {
            Destination = destinationStripeAccount.AccountId
        }
    };
    paymentIntentService.Update(paymentIntent.Id, options);
}

参考

你不需要只提供更新选项对象中需要更改的内容吗?我会看看是否能找到该对象的源代码并确认。嗯,有趣的是,当模型是可选的时,我没有想到行为会是怎样的。我只是假设可选,他们的意思是,如果省略该字段,状态将被清除。我需要调查我已经和stripe小组确认了这件事。我对它们如何处理您显式希望为可选值设置null的情况感到有点困惑,但这使我的代码简单得多