square / in-app-payments-react-native-plugin

Apache License 2.0
118 stars 50 forks source link

No enum constant sqip.Country.Australia #145

Closed camiewwatman closed 3 years ago

camiewwatman commented 3 years ago

Describe the issue

I'm trying to open the card entry page via onStartCardEntry (Card entry flow with buyer verification) but my app crashes before loading this page. I have everything well configured (square location ID and api key set) but looks like I'm missing something in earlier configuration.

This works fine in IOS but not in Android.

Here is the log:

  Fatal Exception: java.lang.IllegalArgumentException: No enum constant sqip.Country.Australia
       at java.lang.Enum.valueOf(Enum.java:257)
       at sqip.Country.valueOf(:2)
       at sqip.react.CardEntryModule.getContact(CardEntryModule.java:272)
       at sqip.react.CardEntryModule.startCardEntryFlowWithVerification(CardEntryModule.java:223)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
       at android.os.Looper.loop(Looper.java:237)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
       at java.lang.Thread.run(Thread.java:919)

To Reproduce

Steps to reproduce the issue.

  1. Initialise the SDK
  2. call await SQIPCardEntry.startCardEntryFlowWithBuyerVerification via function onStartCardEntry()

    Here the piece of code that reproduce the issue.

         async function onStartCardEntry(charge,restaurant,user) {
          console.log(user)
          const cardEntryConfig = {
            collectPostalCode: false,
            squareLocationId: restaurant.squareLocationID,
            buyerAction: 'Store',
            amount: charge.ammount,
            currencyCode: charge.currencyCode,
            givenName: user.firstName,
            familyName: user.lastName,
            addressLines: user.address.details,
            city: user.address.city,
            countryCode: user.address.countryCode,
            email: user.emailAddress,
            phone: user.phoneNo,
            postalCode: user.address.postCode
          };
    
          await SQIPCardEntry.startCardEntryFlowWithBuyerVerification(
            cardEntryConfig,
            onBuyerVerificationSuccess,
            onBuyerVerificationFailure,
            onCardEntryCancel,
          );
        }

    -->

Expected behavior

I press the button which enacts the function described above, passing info to the cardEntryConfig variable. The Card Entry screen should then open and allow me to enter card details to generate a Nonce.

Environment (please complete the following information):

camiewwatman commented 3 years ago

Fixed issue. I had incorrectly classed Country Code. Needed AU not Australia.