smarkets / react-native-paypal

React Native library that implements PayPal Checkout flow using purely native code
MIT License
118 stars 54 forks source link

Can't find variable: Symbol #6

Closed ShridharCodewave closed 5 years ago

ShridharCodewave commented 5 years ago

I followed the documentation and Iam trying to set a new payment but getting the above error and my code is as below

componentWillMount() {
    gateway = braintree.connect({
      environment: braintree.Environment.Sandbox,
      merchantId: "xxxx",
      publicKey: "xxxx",
      privateKey: "xxxx"
    });
  }
  buttonPress(token) {
    var clientToken = null
    gateway.clientToken.generate({}, function (err, response) {
      clientToken = response.clientToken
    });
    try {
      const {
        nonce,
        payerId,
        email,
        firstName,
        lastName,
        phone
      } = requestOneTimePayment(
        clientToken,
        {
          amount: '500', // required
          // any PayPal supported currency (see here: https://developer.paypal.com/docs/integration/direct/rest/currency-codes/#paypal-account-payments)
          currency: 'INR',
          // any PayPal supported locale (see here: https://braintree.github.io/braintree_ios/Classes/BTPayPalRequest.html#/c:objc(cs)BTPayPalRequest(py)localeCode)
          localeCode: 'zh_XC',
          shippingAddressRequired: false,
          userAction: 'commit', // display 'Pay Now' on the PayPal review page
          // one of 'authorize', 'sale', 'order'. defaults to 'authorize'. see details here: https://developer.paypal.com/docs/api/payments/v1/#payment-create-request-body
          intent: 'authorize',
        }
      );
    }
    catch (e) {
      Alert.alert(e);
    }

and the buttonPress() function is called on press of a button.

The error is located in braintree\lib\braintree\transaction.js

riso commented 5 years ago

hello. are you using babel? if you're not, you can try and rewrite the call to requestOneTimePayment as follows

requestOneTimePayment(
        clientToken,
        {
          amount: '500', // required
          // any PayPal supported currency (see here: https://developer.paypal.com/docs/integration/direct/rest/currency-codes/#paypal-account-payments)
          currency: 'INR',
          // any PayPal supported locale (see here: https://braintree.github.io/braintree_ios/Classes/BTPayPalRequest.html#/c:objc(cs)BTPayPalRequest(py)localeCode)
          localeCode: 'zh_XC',
          shippingAddressRequired: false,
          userAction: 'commit', // display 'Pay Now' on the PayPal review page
          // one of 'authorize', 'sale', 'order'. defaults to 'authorize'. see details here: https://developer.paypal.com/docs/api/payments/v1/#payment-create-request-body
          intent: 'authorize',
        }
      ).then(function(response) {
         console.log('received', response);
     }).catch(function(error) {Alert.alert(error)})

regardless though, braintree\lib\braintree\transaction.js is not a file part of this library so I think you must have included some other library that's causing the error.

ShridharCodewave commented 5 years ago

Yes I agree the transaction.js file is inside the braintree package which is required to generate the client token to initiate the payment.

riso commented 5 years ago

I'll close this issue as I don't think it's related to the library code.