paypal-js | Loading wrapper and TypeScript types for the PayPal JS SDK | SDK library
kandi X-RAY | paypal-js Summary
kandi X-RAY | paypal-js Summary
A client-side loader for the PayPal JS SDK.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return the banner text for the pacak
paypal-js Key Features
paypal-js Examples and Code Snippets
Community Discussions
Trending Discussions on paypal-js
QUESTION
The official NPM package @paypal/react-paypal-js: https://www.npmjs.com/package/@paypal/react-paypal-js only supports buttons that require client_id, I have not been able to find anything that simplifies the implementation of Donate button. PayPal provides only this HTML code below on the Donate button documentation. Please let me know if anyone has had a similar experience and how did you manage to implement it properly in React/Gatsby.
...ANSWER
Answered 2022-Mar-29 at 04:26There are two ways to use the Donate SDK HTML/JS from react.
Configure the app to load the SDK script at page load time (typically as part of the page's
). The JS to render the button can then be run/outputted whenever as part of a component.
Insert the script element into the DOM after page load and once loaded render buttons with a callback function. This can all be placed in a React component's
useEffect
or similar. The linked example usingloadAsync
is for the Checkout SDK, but that's easily swapped out for Donate SDK code.
You can use the Donate SDK with a hosted_button_id
as you mentioned (created at https://www.paypal.com/buttons (live) or www.sandbox.paypal.com/buttons) -- or alternatively, instead of a hosted button id just pass a business
parameter with either the receiving account's PayPal email address or (ideally) its PayPal Merchant ID (since that will never change whereas an email can be removed from the account and no longer point to it)
Later edit: Note that the Donate SDK is separate from simply relabeling a normal PayPal Checkout SDK button with the text "Donate", which can be done per the react-paypal-js storybook example, as another answer mentioned. The issue with this approach is after clicking the button it will look like a standard PayPal checkout, not a donation-specific flow...
Using the actual Donate SDK instead results in a more tailored donor flow where they can select any amount in the large input, and even check an option to make their donation recurring:
QUESTION
I'm trying to implement the PayPal Subscription API but I'm not sure about the process flow.
I use the react-paypal-js
package to generate the subscription button.
The way the users are created on my website is only through the Paypal subscription.
The process is as follow:
- The user choose a plan and click on the subscribe button
- The PayPal window open and the user follows the subscription process on Paypal
- The user is redirected to my website
- Using webhooks or with the
onApprove
callback, I receive the newly created subscription, create a user on my website with the Paypal email address associated with the subscription.
It all works. My problem is that I need to check, before accepting the subscription, if I already have a local user with given email and in this case, I don't want to accept the subscription (as I would then have 2 subscriptions for the same user) and display a message saying that their is already an active (or suspended) subscription associated with the given email.
As far as I can tell, when the onApprove
is called or the webhook is called, the subscription has already been processed and activated.
Thanks!
...ANSWER
Answered 2022-Mar-25 at 19:30You don't have to design a system in which the PayPal email used to make the payment, and the email of the user used to log into your site, have a 1:1 relationship. Instead you can have the user log and create their account with you first (as they will always need that to manage something subscription-based) and then you will know there is no subscription associated with that user before displaying the PayPal Subscribe button. Then they can pay with any PayPal account (might be the same email, might be different)
As far as I can tell, when the onApprove is called or the webhook is called, the subscription has already been processed and activated.
That is the default behavior, yes. Per the above it shouldn't be ncessary, but you can change the subscription to start in an inactive state, and show a final review step on your site that will activate it via API. This is controlled by setting application_context
-> user_action
-> CONTINUE (vs default SUBSCRIBE_NOW). See the API reference for subscription create, and you would of course need to use the subscription activate API call as a final step after confirmation.
QUESTION
I have a website with multiple payment forms. I can switch between them and then I have a button with "Continue to checkout" label that when you click, it does something depending on the payment method chosen. The handler function looks something like this:
...ANSWER
Answered 2022-Feb-25 at 22:49If you use the PayPal JS SDK to open the checkout, you have to use its button, and the user has to click it themselves. PayPal does this intentionally so that the button shown uses their consistent branding.
If you want an alternative, you can integrate without the JS SDK (REST API only) and have your own button which redirects to the PayPal page for approval, which will then return to your site. This is an old integration pattern, for old websites, and not recommended.
Despite your misgivings and desire not to use it, the JS SDK and its button in a container sized to your requirements is in fact the best available solution.
Based on the UI shown, what you might op to do is hide your "Pay" button and replace it with one that says "Pay With PayPal" when that method is selected, which could look like this (sized to fit your container): Here's sample HTML/JS for that, you can do the same from react-paypal-js :
QUESTION
I'm using PayPal in sandbox mode and @paypal/react-paypal-js in my React application and I'm using .NET 5 as my REST API. Here is my payload when I want to create an order:
...ANSWER
Answered 2022-Feb-05 at 06:46Within onApprove
, the order hasn't been captured when you are printing that data. Capture the order first. When an order is captured, its transaction ID will be in the response's purchase_units[0].payments.captures[0]
If you need to do anything important with that ID, such as store it in a database, used a server-side integration (not actions.order.capture nor actions.order.create, client-side code is not for database operations). See the optional step #5 in the 'Add and modify the code' section of the guide for Integrate Checkout, and be sure to use the client-side error handling code in its linked demo pattern example.
QUESTION
I am using @paypal/paypal-js from npm in react app to integrate payment, any idea how to pass down style props in the button component that this library offers ?
...ANSWER
Answered 2022-Jan-19 at 00:33There are some examples in the documentation. For your case:
QUESTION
Hi i've been using paypal's sample code but adapted with react-paypal-js.
I'm wondering if there is an example for suspend subscription?
There doesn't seem to be an equivalent suspendSubscription? I tried looking at subscription API but not sure how to adapt that here. Thanks!
...ANSWER
Answered 2022-Jan-01 at 09:49Suspending a subscription is done with server API calls, so reactjs is not relevant.
See the Subscriptions documentation, which gives an example in curl format
QUESTION
Trying to pre-fill some details for the card payment based on https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/. But the example https://developer.paypal.com/docs/checkout/integration-features/standard-card-fields/ is not working, because the json does not fit to the types in "@paypal/paypal-js": "^4.1.0".
So I adjusted it --> https://developer.paypal.com/docs/api/orders/v2/#definition-payer See also: @paypal\paypal-js\types\apis\orders.d.ts
But now the following error accours:
...ANSWER
Answered 2021-Oct-29 at 16:00Per the documentation, phone_number must have a national_number
key. Do not include a payer_id
or invalid tax_info
object.
QUESTION
I am using @paypal/react-paypal-js
to display the PayPal button and create an order. I am specifically interested in processing credit card payments. Once my Django backend receives the payment capture completion event from PayPal, it needs to store information about a particular user owning a particular product. Hence, the notification has to contain both the user ID (i.e. email) and the product ID.
This is how I am trying to pass these two pieces of information in my frontend:
...ANSWER
Answered 2021-Oct-21 at 02:03I also tried adding payee: {email_address: userEmail} into purchase_units, but then there was no option to pay with credit card after pressing on the PayPal button. That option got replaced by the option to create a PayPal account.
payee
sets which account receives the PayPal payment. The black Debit or Credit Card button will generally be available for guest payments if the recipient PayPal account exists and is confirmed.
How can I pass the two pieces of information so as to get them in webhook_event?
If you absolutely must store two pieces information as part of a custom value (usually only useful for subscriptions, although even for subscriptions there are better solutions that involve using your own database), you could encode a JSON object with json.dumps({'email': somevalue, 'product': somevalue}
and store that json string value in custom_id -- then decode it later on receipt with json.loads
.
It's unusual to need to do anything like this, however, especially for one-time Order payments. You should implement order creation and capture from your own server routes and store the necessary information on your own database immediately on successful capture, before returning the capture result to the button JavaScript. See the information for a server integration in Set up standard payments.
Webhooks are not necessary at all in such a case, much less retrieving item information from a webhook. You however can and should include item information as part of the PayPal transaction for informational purposes, via an items
array. This will also show to the payer in the upper right cart dropdown during checkout, and be visible in the completed paypal.com transaction details.
QUESTION
I'm using react-paypal-js
and need to set a dynamic amount when the PayPal button is clicked.
The problem: the createOrder
function can not take data from my state (might because it is under PayPal script context).
Not Working Example:
...ANSWER
Answered 2021-Sep-21 at 09:30Integrating from a backend is the most robust solution in general, especially for ecommerce -- but as this is for a simple donation use case I can see how you may wish to avoid that.
There are various possible solutions, including using an additional state framework such as Redux, but it seems what you want to do is manage the state at a parent component level above the buttons, and bind
its createOrder ("handleCreatePayPal") methods, etc so that this
is in context and they can access its state.
Here is a runnable codesandbox example (based on the documented example that uses a re-render, but none is done here)
QUESTION
Hi I am using this module to integrate the Paypal solution in my site: https://www.npmjs.com/package/@paypal/react-paypal-js
However even though it seems to be developed by paypal officially, there seems to be no option to disable the shipping address during checkout
...ANSWER
Answered 2021-Jun-09 at 12:06After digging through the source code you can supply many options.. I was able to set no shipping address like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install paypal-js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page