带有初始金额的经常性PayPal付款的空参考

时间:2015-01-02 09:52:46

标签: c# asp.net paypal paypal-sandbox

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

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

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

这确实让我错误:

scheduleDetails.ActivationDetails.InitialAmount = intialPaymentAmount;

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

我做错了什么?

1 个答案:

答案 0 :(得分:1)

这样我解决了问题

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