paypal / paypal-js

Loading wrapper and TypeScript types for the PayPal JS SDK
Apache License 2.0
238 stars 83 forks source link

[Feature] Add Paypal Donate SDK inplemetation #570

Open Vladi-ed opened 1 month ago

Vladi-ed commented 1 month ago

🚀 Feature Proposal

There is no Donate SDK implementation in @paypal/paypal-js

Motivation

I just want to gather donation in my SPA but there is no implementation i can find inside @paypal/paypal-js

Example

Example for how this feature would be used:

import { loadDonationScript } from "@paypal/paypal-js";

let paypal;

try {
    paypal = await loadDonationScript();
} catch (error) {
    console.error("failed to load the PayPal JS SDK script", error);
}

if (paypal) {
    try {
        await paypal.DonateButton({
          env: 'production',
          hosted_button_id: '123',
          image: {
            src: 'assets/donate.png',
            alt: 'Donate',
            title: 'Support my work',
          }
      } ).render("#your-container-element");
    } catch (error) {
        console.error("failed to render the PayPal Buttons", error);
    }
}