Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
PayPal Donate SDK - Prefill Amount and Frequency

I am building an application which includes a custom donation form where users can select:

  • Frequency: monthly, single
  • Amount: 3 x Buttons with values, input for custom value

enter image description here

I am using the PayPal Donate SDK and cannot find a way to pass across the amount or frequency so that the amount is pre-filled and the "make this a monthly donation" checkbox selected/deselected based on the users input.

The PayPal button has been added to the page (just absolute styled over the form button) and the SDK opens the donation page in a modal which is my desired result.

This is the code to display my button:

window.PayPal.Donation.Button({
    env: "sandbox",
    hosted_button_id: "xxxxxxxxxxxx",
    onComplete: function() {
        // Redirect to success page, save the PP transaction details, etc.
    }
}).render("#paypal-donate-button-container");

With the standard PayPal.Buttons API, I am able to pass in a createOrder function like so, where I can set the amount, for example;

window.PayPal.Buttons({
    // ...
    createOrder: function(data, actions) {
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: document.querySelector(".selected-premium").dataset.value
                },
                reference_id: document.querySelector(".selected-premium").dataset.days + "-days"
            }]
        });
    }
}

Is there a way to pass through the amount and frequency using the SDK, similar to how I can do it with the standard payments API? If not, what are the alternatives in 2022 that don't rely on SO answers that use docs that no longer exist/deprecated methods?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With the PayPal Donations flow (this includes the Donate SDK)

  • You can pass a parameter for the amount and currency_code. If you do pass a prefilled amount, an option to make the donation recurring will not be available.

  • You cannot pre select the option to make the donation recurring in the Donations flow.


For the case of recurring donations -- since it's not possible to precheck the option to make them recurring in the Donations flow, nor is it possible to prefill the amount and have that choice of recurrence even be available -- what you could do is instead use a Subscription flow for when a recurrence is selected, and have this render in a separate div container that is shown/hidden based on your monthly vs single selection. A subscribe button for your account can be generated at: https://www.paypal.com/billing/plans . The plan it uses must have a specific amount, but this can be overridden in the JS createSubscription function (based on whatever selection or amount was entered on your site) by (in addition to the base plan_id) adding a plan object that contains a billing_cycles object with the amount/frequency you want.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!