【问题标题】:PayPal Recurring Payments for Installment Donations分期付款的 PayPal 定期付款
【发布时间】:2020-01-03 23:03:45
【问题描述】:

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

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

【问题讨论】:

  • 只是为了确定,在您编写 C#、.net 和 vb.net 的标签中是正确的。您在寻找代码解决方案还是概念解决方案?如果代码解决方案,是c#,请澄清。
  • 主要是一个概念解决方案。我只是更熟悉 .NET 语言。
  • 您对 PayPal 的替代方案是否满意,或者您只是在寻找基于 Paypal 的解决方案?
  • 我猜 - 只要费用不高。

标签: c# .net vb.net paypal


【解决方案1】:

我认为您必须创建一个计费计划。以下 sn-p 来自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")
                }
            }
        }
    }
};

【讨论】:

    【解决方案2】:

    我对“PayPal-Button”本身并不熟悉,但我想,它只是一些改变的参数。很可能在 URL 本身中。 (GET-请求)

    因此,您可以在您的网站上放置一个带有选项的下拉菜单,而不是创建多个按钮,将付款分成 n 等份,然后使用它重定向到相应的 PayPal-URL。

    我不知道你的堆栈,但是使用 MVC (Razor) 和一些 Javascript,看起来并没有太多的努力。

    所以要么在页面上使用 JS 通过单击按钮进行重定向,要么在服务器端评估后返回重定向。

    如果 PayPal 使用 POST,那么您可以使用表单,通过表单外部的其他 INPUT 的某些事件更改 INPUT 的值。这将需要 JavaScript。
    因此,在 Select-Click-Event 上:设置输入元素的值,“PayPal 按钮”将其用于 POST 请求。类似于以下内容。

    <script>
      function SetValue(){
        buttonValue.value = selector.value;
      }
    </script>
    <SELECT id="selector" onClick="SetValue()">
     ... options
    </SELECT>
    <Form ...>
     <input id="buttonValue" ... />
     <button...>Send</button>
    </Form>
    

    【讨论】:

      【解决方案3】:

      检查此工作流程 https://developer.paypal.com/docs/subscriptions/

      https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

      我没有完整的工作代码,以前称为计费协议。 Paypal .net sdk 已有两年历史。 https://github.com/paypal/PayPal-NET-SDK/blob/develop/Samples/Source/BillingAgreementCreateAndExecute.aspx.cs 在贝宝网站上提到了这一点。 计费协议 API 弃用通知: /v1/billing-agreements 端点已弃用。请改用 /v1/billing/subscriptions 端点。有关详细信息,请参阅订阅集成。

      【讨论】:

        猜你喜欢
        • 2011-09-16
        • 2013-02-15
        • 2014-05-08
        • 2013-01-19
        • 2013-05-06
        • 2012-04-05
        • 2014-01-23
        • 2012-03-13
        相关资源
        最近更新 更多