Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected currency: JPY passed to order.create. Please ensure you are passing /sdk/js?currency=JPY in the paypal script tag. #4

Closed
zhakamizhako opened this issue Mar 14, 2019 · 4 comments

Comments

@zhakamizhako
Copy link

zhakamizhako commented Mar 14, 2019

Hi, Good day. I've followed your examples, but i seem to stumble across an error whenever i try to change the currency. We're using React 15.6.2 with Redux 4.4.9.

Error: Unexpected currency: JPY passed to order.create. Please ensure you are passing /sdk/js?currency=JPY in the paypal script tag.

Here's my code for our page.

import { PayPalButton } from "react-paypal-button-v2";

import { toast } from 'react-toastify'

class PaymentTest extends Component {
  constructor (props) {
    super(props)

    this.state = {
      
    }
  }

  componentDidMount () {

  }

  componentWillReceiveProps (nextProps) {
    let { } = nextProps
  }

  render() {
    
    return (
      <PayPalButton
      amount="0.01"
      options={{currency:'JPY'}}
      
      onSuccess={(details, data) => {
        alert("Transaction completed by " + details.payer.name.given_name);

        // OPTIONAL: Call your server to save the transaction
        return fetch("/paypal-transaction-complete", {
          method: "post",
          body: JSON.stringify({
            orderID: data.orderID
          })
        });
      }}
    />
    );
  }
}

PaymentTest.propTypes = {

}

export default PaymentTest

Even then if i try to place it inside the <PayPalButton>, it returns with the same error.

<PayPalButton
      amount="0.01"
      currency='PHP'
      onSuccess={(details, data) => {
        alert("Transaction completed by " + details.payer.name.given_name);
        // OPTIONAL: Call your server to save the transaction
        return fetch("/paypal-transaction-complete", {
          method: "post",
          body: JSON.stringify({
            orderID: data.orderID
          })
        });
      }}
    /> 
@Luehang
Copy link
Owner

Luehang commented Mar 14, 2019

Hi,

Do you have a script tag anywhere in your html pointing to paypal's api or a tag that looks like this <script src="https://www.paypal.com/sdk/js?client-id=sb"></script>? If you do, then delete the script tag.

@Luehang
Copy link
Owner

Luehang commented Mar 14, 2019

If you like react-paypal-button-v2, please give it a star! Thanks.

@Luehang Luehang closed this as completed Mar 14, 2019
@Fl4v10
Copy link

Fl4v10 commented Apr 18, 2019

Hi,

Do you have a script tag anywhere in your html pointing to paypal's api or a tag that looks like this <script src="https://www.paypal.com/sdk/js?client-id=sb"></script>? If you do, then delete the script tag.

Hello, thanks for the component and sorry for bad English.

I did not set the mentioned script but got the same error while passing different currencies.

At first, I've tried to pass the currency through the options and it doesn't work, then I passed by currency prop listed in IPayPalButtonProps and it worked for while until suddenly stop.

My code:

<PayPalButton
    amount={this.calcAmount()}
   currency={symbol}
   options={{
         	clientId
   }}
   onSuccess={this.onSuccess.bind(this)}
   onError={this.onError.bind(this)}
/>

Error message:
"Unexpected currency: EUR passed to order.create. Please ensure you are passing /sdk/js?currency=EUR in the paypal script tag."

Stack

Error: Unexpected currency: EUR passed to order.create. Please ensure you are passing /sdk/js?currency=EUR in the paypal script tag.
    at Xt.(anonymous function) (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:51890)
    at Object.<anonymous> (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:58149)
    at JSON.parse (<anonymous>)
    at o (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:58009)
    at cr (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:58160)
    at u.on (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:62923)
    at gr (https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]:1:63112)
    at https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]0:1:67549
    at https://www.paypal.com/sdk/js?client-id=[CLIENT-ID]0:1:67595

@svengau
Copy link

svengau commented Apr 24, 2020

In case someone has the same issue, you need to pass also the currency in the options:

      <PayPalButton
           amount={total}
           currency={currency}
           options={{
             currency: currency.toUpperCase(),
             clientId: PAYPAL_CLIENT_ID,
           }}
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants