Coder Social home page Coder Social logo

gatsby-plugin-paypal's Introduction

Hi there ๐Ÿ‘‹

gatsby-plugin-paypal's People

Contributors

alexislepresle avatar buddhikajay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gatsby-plugin-paypal's Issues

Update gatsby peer dependency

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.

Cannot read buttons of undefined

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

Unable to override "createOrder" function with "createSubscription"

...props,

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');

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This

ร—
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:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app
    See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

//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

Pass value to amount

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;

Vault parameter is missing

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!

Invalid hook call

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! )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.