简体   繁体   中英

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. 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.

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? 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 . 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. Most likely in the URL itself. (GET-Request)

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.

I don't know your stack, but with MVC (Razor) and some Javascript, it does not seem too much of an effort.

So either use JS on the page to redirect with a button click or return a redirect after evaluating on the server side.

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. This will require JavaScript.
So on the Select-Click-Event: set the value of your input-element, which the "PayPal-button" uses for the POST Request. 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/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. https://github.com/paypal/PayPal-NET-SDK/blob/develop/Samples/Source/BillingAgreementCreateAndExecute.aspx.cs On paypal Website this is mentioned. Billing Agreements API Deprecation notice: The /v1/billing-agreements endpoints are deprecated. Use the /v1/billing/subscriptions endpoints instead. For details, see Subscriptions Integration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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