c# - 付款错误 : PayPal error: Invalid request. 查看详情。 (VALIDATION_ERROR) Paypal

标签 c# paypal paypal-sandbox paypal-rest-sdk paypal-subscriptions

我在我的项目中使用 PayPal 定期付款。我想在一段时间内免费试用一次,初始订单总额应为零,一旦免费试用完成,实际订单金额将从帐户中扣除。

例如,用户购买一件产品(100 美元)并申请免费试用的折扣代码,那么第一笔订单应以 0 美元下单,一旦试用结束,将进入 100 美元的周期。

为此,我将“0”传递给 MerchantPreferences 中的 setup_fee:

merchant_preferences = new MerchantPreferences
{
    return_url = url,
    cancel_url = url,
    auto_bill_amount = "YES",
    setup_fee = new PayPal.Api.Currency
    {
        currency = currency != null ? currency.CurrencyCode : null,
        value = "0.00"
    }
}

但它给了我一个错误:

Payment error: PayPal error: Invalid request. See details. (VALIDATION_ERROR)
Payment error: note Note is missing from the request or Note length is too long
Payment error: amount.currency Required field is missing.

如果我传递一些值而不是 0.00 它工作正常,但我想发送零作为初始金额。

谁能告诉我我的代码有什么问题?

最佳答案

错误描述了缺少的“注释”参数和无效的“货币”。您是否检查过您没有为 currency 发送 null 值,或者在值为 0 时跳过发送 Note 参数?从您的代码看来,如果 currencynullcurrency.CurrencyCodenull,那么您是在 PayPal 不允许的情况下发送 null 值。

附带说明一下,我知道许多以财务为导向的网站使用约 1 美分而不是 0 的存款值(value)来验证资金是否已正确转移。

关于c# - 付款错误 : PayPal error: Invalid request. 查看详情。 (VALIDATION_ERROR) Paypal ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46483056/

相关文章:

c# - 具有完整属性的私有(private)字段初始化

c# - 在 TabControl 内恢复 SplitterDistance 不一致

magento - 如何编辑 Paypal API 错误信息?

php - 如何将钱从 Paypal 转移到付款?

c# - Paypal REST API SDK - 在 C# 中激活计费计划

c# - Linq 到 xml : generic approach

c# - RemoveAll() 的目的

paypal - 我可以将变量发送到 paypal,并在付款完成后将其发回给我吗?

ruby-on-rails - RoR - PayPal ActiveMerchant - 退款

php - Paypal REST-API 预批准支付场景