c# - PayPal 定期捐款分期付款

标签 c# .net vb.net paypal

我想在我的 .NET 网站上发起一项捐赠事件,请人们同意向我的组织捐赠 200.00 美元。由于有些人可能没有预付所有的钱,我想让他们选择现在捐赠 50 美元或更多,然后将剩余的部分分摊到 1-3 个月的额外付款中。

我是否需要为每个可能的场景设置循环支付按钮,然后使用一些脚本来确定我应该将用户引导至哪个 PayPal 表单按钮?还是有更灵活的方法来做到这一点?

最佳答案

我认为您必须创建一个计费计划。以下片段来自 PayPal SDK .我根据您的需要对其进行了一些修改,但您仍然需要对其进行自定义。

var plan = new Plan
{
    name = "Donation Split Payment",
    description = "Monthly plan for the less fortunate.",
    type = "fixed",
    // Define the merchant preferences.
    // More Information: https://developer.paypal.com/webapps/developer/docs/api/#merchantpreferences-object
    merchant_preferences = new MerchantPreferences()
    {
        setup_fee = GetCurrency("0"),
        return_url = httpContext.Request.Url.ToString(),
        cancel_url = httpContext.Request.Url.ToString() + "?cancel",
        auto_bill_amount = "YES",
        initial_fail_amount_action = "CONTINUE",
        max_fail_attempts = "0"
    },
    payment_definitions = new List<PaymentDefinition>
    {
        // Define a trial plan that will only charge $50 for the first
        // month. After that, the standard plan will take over for the
        // remaining 4 months.
        new PaymentDefinition()
        {
            name = "First Payment",
            type = "REGULAR",
            frequency = "MONTH",
            frequency_interval = "1",
            amount = GetCurrency("50.00"),
            cycles = "1",
            charge_models = new List<ChargeModel>
            {
                new ChargeModel()
                {
                    type = "TAX",
                    amount = GetCurrency("9.99")
                }
            }
        },
        // Define the standard payment plan. It will represent a monthly
        // plan for $50 USD that charges once month for 3 months.
        new PaymentDefinition
        {
            name = "Other payment",
            type = "REGULAR",
            frequency = "MONTH",
            frequency_interval = "1",
            amount = GetCurrency("50.00"),
            // > NOTE: For `IFNINITE` type plans, `cycles` should be 0 for a `REGULAR` `PaymentDefinition` object.
            cycles = "3",
            charge_models = new List<ChargeModel>
            {
                new ChargeModel
                {
                    type = "TAX",
                    amount = GetCurrency("9.99")
                }
            }
        }
    }
};

关于c# - PayPal 定期捐款分期付款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57731023/

相关文章:

c# - DateTime 在使用 Refit 序列化并用作 url 参数时失去精度

.net - 使用 itextsharp 从 Pdf 文件中提取文本和文本矩形坐标

vb.net - 句柄与 AddHandler

VB.net HTTP post,计算进度条异步发送的字节数

c# - 使用额外的属性扩展 TreeView?

c# - 在 ASP.NET Core 7 WebApi 中使用 RouteGroupBuilder 时如何获取路由组前缀

c# - 写入文件系统。如何有效锁定

c# - 将 DLL 加载到单独的 AppDomain 中

.net - Identity Server 4 和用于用户管理的 Web API

vb.net - SerialPort 将 VB6 设置 "57600,N,8,1"转换为 VB.NET