我正在尝试创建定期付款资料。我能够成功创建订阅。现在,我想用初始付款创建订阅。我添加了以下代码:

    CurrencyCodeType currency = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), "USD");
    BasicAmountType intialPaymentAmount = new BasicAmountType(currency, "4000");
    scheduleDetails.ActivationDetails.InitialAmount = intialPaymentAmount;


但是上面的代码抛出空引用对象错误。

这恰恰引发了我的错误:

scheduleDetails.ActivationDetails.InitialAmount = intialPaymentAmount;


但是在调试模式下,intialPaymentAmount中包含所有内容。

我究竟做错了什么?

最佳答案

这样我解决了这个问题

        BasicAmountType intialPaymentAmount = new BasicAmountType(currency, "4000");
        ActivationDetailsType acd = new ActivationDetailsType();
        acd.InitialAmount = intialPaymentAmount;
        acd.FailedInitialAmountAction = FailedPaymentActionType.CANCELONFAILURE;
        scheduleDetails.ActivationDetails = acd;

09-12 14:26