alexislepresle / gatsby-plugin-paypal Goto Github PK
View Code? Open in Web Editor NEW๐ฐ Add a PayPal Smart Payment Buttons to your Gatsby website easily.
๐ฐ Add a PayPal Smart Payment Buttons to your Gatsby website easily.
The project refers to "gatsby": "^2.32.13",
as a peer dependency which is kinda old and the plugin seems to work fine with v3 too.
After installing the package and navigating to the button in the web browser it fails to load with the error in the title and points to the installed directory within node_modules
window.paypal
.Buttons({
Is what seems the be undefined at ./node_modules/gatsby-plugin-paypal/index.js:40
Line 41 in 7a52048
Right now shows an error when I am trying to use createSubscription
because we can use it together with createOrder
. I think should be like that:
window.paypal
.Buttons({
createOrder: (props.createOrder ? props.createOrder : createOrderPaypal),
onApprove: (props.onApprove ? props.onApprove : onApprovePaypal),
onError: (props.onError ? props.onError : onErrorPaypal),
...props,
})
.render('#paypal-button');
ร
i have this error when i try to use this plugin
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
//component
`
import React from "react"
import Paypal from "gatsby-plugin-paypal"
const PaylpalButton = () => (
<Paypal
style={{
shape: 'rect',
color: 'blue',
layout: 'horizontal',
label: 'paypal',
}}
amount={10.1}
/>
)
export default PaylpalButton
`
//just a simple page
`
import React from 'react'
import PaypalButton from '../components/PaypalButton'
const Home= () => {
return (
)
}
export default Home
`
//config
.... plugins: [ { resolve:
gatsby-plugin-paypal, options: { clientId: process.env.PAYPAL_ID } }, .... ] ....
plugin version 1.1
How can I pass a dynamic price to the button?
I have a form in my component that updates the quantity of ordered product and and useEffect
hook that updates the orderTotal
anytime the quantity changes. The updated orderTotal is not updated in the paypal button... My issue is probably not directly related to this plugin but rather to my general understanding of React and Gatsby...
const Cart = ({ isCartOpen, close }) => {
const price = 29995;
const [orderTotal, setOrderTotal] = useState(price);
const [orderQuantity, setOrderQuantity] = useState(1);
const data = useStaticQuery(graphql`
{
file(relativePath: {eq: "assets/images/laser-smart-projector-pico_3.webp"}) {
childImageSharp {
gatsbyImageData(aspectRatio: 1, placeholder: BLURRED)
}
}
}
`);
const productPic = getImage(data.file);
useEffect(() => {
setOrderTotal(orderQuantity * price);
}, [orderQuantity]);
return (
<StyledDiv isCartOpen={isCartOpen}>
<button onClick={close}>
<div className='closing'></div>
<div className='closing'></div>
</button>
<div className='cart-content'>
<Link to='/about' onClick={close}>
<GatsbyImage image={productPic} alt='folded vze projector'/>
VZE: Music Visualizer
</Link>
<form>
<label htmlFor='quantity'>Ordered quantity:</label>
<input
type='number'
name='quantity'
id='quantity'
value={orderQuantity}
onChange={
(e) => {
setOrderQuantity(e.target.value);
}}
min={0}
max={5}
required/>
</form>
<p>your order total is {formatMoney(orderTotal)}</p>
</div>
<Paypal
style={{
shape: 'rect',
color: 'blue',
layout: 'horizontal',
label: 'paypal',
}}
amount={orderTotal}
currency='USD'
/>
</StyledDiv>
);
};
export default Cart;
Hello!
I see that the plugin doesn't use the vault
query parameter when loading the Paypal SDK script. However, in the docs it's said that this parameter must be true
in case of subscription (its default value is false
). Have you tested the plugin with subscriptions? Thanks!
I tried to integrate this plugin but I got this error. Followed instructions from gatsby official documentation. Any suggestion what this can be? I also get error Cannot read property 'Buttons' of undefined. (Sorry, my client ID was not good! It is working! )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.