Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda