简体   繁体   English

分期付款的PayPal定期付款

[英]PayPal Recurring Payments for Installment Donations

I would like to start a donation campaign on my .NET website, asking people to agree to donate $200.00 to my organization. 我想在我的.NET网站上开始捐赠活动,要求人们同意向我的组织捐赠200.00美元。 Since some people might not have all the money up front, I want to give them the option of donating $50 or more now, and then spread out the remainder between 1-3 additional monthly payments. 由于有些人可能没有预先支付所有的钱,我想让他们现在可以选择捐赠50美元或更多,然后将剩余的金额分摊到每月1-3次之间。

Do I need to set up recurring payment buttons for every possible scenario, and then use some script to determine which PayPal form button I should direct the user to? 我是否需要为每种可能的方案设置定期付款按钮,然后使用一些脚本来确定我应该将用户引导到哪个PayPal表单按钮? Or is there a more flexible way of doing this? 或者有更灵活的方式吗?

I think you have to create a Billing Plan. 我认为你必须制定一个计费方案。 Below snippet is from the PayPal SDK . 以下代码段来自PayPal SDK I modified it a little for your needs, but you still would need to customize it. 我根据您的需要对其进行了一些修改,但您仍需要对其进行自定义。

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")
                }
            }
        }
    }
};

I am not familiar with the "PayPal-Button" itself, but I guess, it is just some parameters that change. 我不熟悉“PayPal-Button”本身,但我想,这只是一些参数的变化。 Most likely in the URL itself. 最有可能在URL本身。 (GET-Request) (GET请求)

So instead of creating multiple buttons, you could place a dropdown with options on your site, to split the payment into n equal portions and then using this to redirect to the respective PayPal-URL afterwards. 因此,您可以在网站上放置带有选项的下拉列表,将付款分成n个相等的部分,然后使用此按钮重定向到相应的PayPal-URL,而不是创建多个按钮。

I don't know your stack, but with MVC (Razor) and some Javascript, it does not seem too much of an effort. 我不知道你的堆栈,但使用MVC(Razor)和一些Javascript,它似乎没有太大的努力。

So either use JS on the page to redirect with a button click or return a redirect after evaluating on the server side. 因此,要么在页面上使用JS来重定向,只需单击按钮,或者在服务器端进行评估后返回重定向。

If PayPal uses POST, then you could use a Form, where you change the values of the INPUT with some events of other INPUTs outside of the Form. 如果PayPal使用POST,那么您可以使用Form,在其中使用Form 外部的其他INPUT的某些事件更改INPUT的值。 This will require JavaScript. 这需要JavaScript。
So on the Select-Click-Event: set the value of your input-element, which the "PayPal-button" uses for the POST Request. 所以在Select-Click-Event上:设置input-element的值,“PayPal-button”用于POST请求。 Something like the following. 像下面这样的东西。

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

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

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

I don't have a fully working code and it was called billing agreement before. 我没有完整的代码,之前称之为计费协议。 The Paypal .net sdk is two years old. Paypal .net sdk已经两年了。 https://github.com/paypal/PayPal-NET-SDK/blob/develop/Samples/Source/BillingAgreementCreateAndExecute.aspx.cs On paypal Website this is mentioned. https://github.com/paypal/PayPal-NET-SDK/blob/develop/Samples/Source/BillingAgreementCreateAndExecute.aspx.cs在paypal网站上提到了这一点。 Billing Agreements API Deprecation notice: The /v1/billing-agreements endpoints are deprecated. 帐单协议API弃用通知:不推荐使用/ v1 / billing-agreements端点。 Use the /v1/billing/subscriptions endpoints instead. 请改用/ v1 / billing / subscriptions端点。 For details, see Subscriptions Integration. 有关详细信息,请参阅订阅集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM