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

react-native-paystack for RN 0.60* and below #38

Open
tolu360 opened this issue Sep 4, 2019 · 18 comments · May be fixed by #46
Open

react-native-paystack for RN 0.60* and below #38

tolu360 opened this issue Sep 4, 2019 · 18 comments · May be fixed by #46

Comments

@tolu360
Copy link
Owner

tolu360 commented Sep 4, 2019

Hi All,

Before you submit a new issue, please ensure you are on v3.4.0 or higher for react-native-paystack and have followed the instructions below:

Suggested update path should follow the following steps:

  • npm/yarn remove react-native-paystack
  • Go give the README a read again, new instructions have been added that you should totally be aware of, to know how to proceed. !Important
  • Understand how auto-linking works in RN 0.59 and below as against how it works in RN 0.60 (essentially no linking is required on RN 60 and above) - follow whichever applies to your app.
  • Clean your project on Android, run cd android followed by ./gradlew clean
  • npm install react-native-paystack or yarn add react-native-paystack
  • Build your app and profit.
  • The latest release is 3.4.0 and is tested and works perfectly in RN 60. and below*!

Cheers!

@Ifunanyacollins
Copy link

Ifunanyacollins commented Sep 5, 2019

using the test Key I get this error but on the live key its a success.
Any pointers?
Screenshot_1567697803

@tolu360
Copy link
Owner Author

tolu360 commented Sep 5, 2019 via email

@lucasdozie
Copy link

Hi,
I followed pretty much all the steps listed on the README file, removed and added the package again.
It works on android but doesn't work on iOS (Note: I am not new to manual linking),

  • I added to library from the node_modules -> react-native-paystack -> ios -> RNPaystack.xcodeproj
  • Dragged the libRNPaystack.a file from product to -> Build Phase -> link binaries with Libraries
  • Added the library path to -> Build Settings -> Header search paths.

Info:
react-native-cli: 2.0.1
react-native: 0.57.1

react-native-paystack: "^3.4.0"

Please help attend to this
email: [email protected]

@tolu360
Copy link
Owner Author

tolu360 commented Sep 11, 2019

Hi @lucasdozie, I don't know why you resorted to manual linking, but it is very much unnecessary - the section of the README under auto-linking for iOS for RN 0.59 and lower would be adequate to set up on iOS - please go over the steps again.
And more importantly, I also don't see where you mentioned installing the CocoaPods dependencies on the list of things you did to set up your project. Make your Podfile look like the example in the docs and run pod install afterwards form the /ios directory. If you are new to CocoaPods, check the docs again for how to set it up.
Finally, note that you cannot get it to work without installing the native dependencies via CocoaPods, it is the only step that brings the Paystack framework into your project!

@lucasdozie
Copy link

lucasdozie commented Sep 11, 2019

Hi @tolu360
Thanks for the swift response, so like you suggested I tried the Pod Install as instructed the docs. but got another error google::LogMessage::LogMessage(char const*, int, int)", referenced from...
So I cleared/delete the pod folder and the podfile.lock -> did another pod install and I got same old 'Paystack/Paystack.h' file not found

Screen Shot 2019-09-11 at 12 34 46 PM

Screen Shot 2019-09-11 at 12 38 49 PM

@tolu360
Copy link
Owner Author

tolu360 commented Sep 11, 2019

@lucasdozie, so try to clean your Xcode project (Product > Clean Build Folder) and then build again.

If you still have issues, this is weird by the way, let us start from the scratch (show me your Podfile before you begin steps below - copy and paste the content here, if possible):

  1. Unlink the library, run react-native unlink react-native-paystack.
  2. Reverse all the steps you took for manual linking on iOS.
  3. Exit Xcode and remove pods, not by deleting folders but by running pod deintegrate from the /ios directory.
  4. Link the library, run react-native link react-native-paystack from the /ios directory.
  5. Install dependencies again by running pod install from the /ios directory.
  6. Open your project again in Xcode with the .xcworkspace file not the .xcodeproj file.
  7. Build again and revert.

@lucasdozie
Copy link

lucasdozie commented Sep 11, 2019

Podfile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'thrive' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for thrive
  # Pods for _YOUR_PROJECT_TARGET_
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'Core',
  'CxxBridge',
  'DevSupport',
  'RCTText',
  'RCTImage',
  'RCTNetwork',
  'RCTWebSocket',
  'RCTSettings',
  'RCTAnimation',
  'RCTLinkingIOS',
  # Add any other subspecs you want to use in your project
  # Remove any subspecs you don't want to use in your project
  ]
  
  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  # This should already be auto-added for you, if not add the line below
  pod 'react-native-paystack', :path => '../node_modules/react-native-paystack'
  # pod 'Paystack'

  pod 'react-native-simple-toast', :path => '../node_modules/react-native-simple-toast'

  target 'thriveTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'thrive-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for thrive-tvOS

  target 'thrive-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

@tolu360
Copy link
Owner Author

tolu360 commented Sep 11, 2019

So, I am going to clean that up a little and disable dynamic frameworks:

platform :ios, '9.0'

target 'thrive' do
  # use_frameworks!

  # Pods for thrive
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTImage',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTSettings',
    'RCTAnimation',
    'RCTLinkingIOS',
    # Add any other subspecs you want to use in your project
    # Remove any subspecs you don't want to use in your project
  ]

  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'react-native-paystack', :path => '../node_modules/react-native-paystack'
  pod 'react-native-simple-toast', :path => '../node_modules/react-native-simple-toast'

end

Use this with the steps I provided above earlier and revert

@lucasdozie
Copy link

So I tried the above solution but I'm now getting this error Xcode build error linker command failed with exit code 1

@tolu360
Copy link
Owner Author

tolu360 commented Sep 11, 2019

You may still have remnants of your previous failed attempts you need to remove and clean up. The linker error referenced by you is not complete - it usually shows what could not be found or what is missing, e.g:

ld: so-and-so not found..... blah blah
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Can you provide the reported missing file or library along with the error? And make sure that after installing pods, you open your project again in Xcode with the .xcworkspace file not the .xcodeproj file.
Or you may find it is easier to just start a new project altogether from react-native init newAppHere and pull in pods and libraries afresh! If at all, you opt for RN 0.60 or higher, please read about how linking works there in the README as you would need to do things differently as far as setting up is concerned.

@lucasdozie
Copy link

Thanks a lot man
Yea I saw the bug and I fixed it(Cleared the Paystack.h not found), but currently getting error response of E_BUSY

@tolu360
Copy link
Owner Author

tolu360 commented Sep 12, 2019

@lucasdozie if you are getting an error code of E_BUSY, you may be calling methods off of the library in too rapid successions, such that you are not allowing a request to the API finish before making a new one. You should employ the use of loaders/spinners and deactivating your pay buttons when a payment request is in progress e.g.

chargeCard() {
        // deactivate pay button here <-------
        // show spinner here <-------

       RNPaystack.chargeCardWithAccessCode({
              cardNumber: '4123450131001381', 
              expiryMonth: '10', 
              expiryYear: '19', 
              cvc: '883',
              accessCode: '2p3j42th639duy4'
       })
       .then(response => {
	      console.log(response); // do stuff with the token
               // hide spinner here <-------
               // activate pay button here or show success message  <-------
      })
      .catch(error => {
	       console.log(error.message);
                // activate pay button here <-------
                // hide spinner here <-------
	})
}

@lucasdozie
Copy link

Sorry for just replying now, since iOS was kinda buggy i left to to focus on android.
Now that I am done with android, I tried iOS again this time I am getting Another request is still being processed, please wait just by tapping the pay button

@lucasdozie
Copy link

Also I am getting Error charging card

@lucasdozie
Copy link

lucasdozie commented Oct 15, 2019

@tolu360 Here is my script, its works on android but iOS tends to initiate a double call, but the first console.log only shows once when that happens

Also somethings after pressing the payment btn, the loader loads for ever

chargeCard = async () => {
        console.log("chager card is Initiatelizing paystack charge card...  chargeCard state:.", this.state)
        this.setState({paymentLoadingStatus: true})
        await RNPaystack.chargeCard({
                cardNumber: this.state.cardNumber,
                expiryMonth: this.state.expiryMonth, 
                expiryYear: this.state.expiryYear,
                cvc: this.state.cvc,
                email: this.state.email,
                amountInKobo: this.state.amount * 100,
                reference: this.state.txref
                }
            )
            .then((response) => {
                console.log(response)
                if(Platform.OS === "ios"){
                    Alert.alert(
                        'Wawu!! Congratulation',
                        response.message,
                        [{text: 'Awesome', onPress: () => {
                            this.setState({
                                paymentLoadingStatus: false,
                             })
                             this.props.navigation.pop(2)
                        }}
                      ],{cancelable: false},
                    );
                }else{
                    this.setState({paymentLoadingStatus: false, resCode: "green",paymentModalResponseStatus: true, paymentModalResponseMsg: response.message})
                }   
            })
            .catch(error => {
                console.log(error)
                if(Platform.OS === "ios"){
                    Alert.alert(
                        'Oops!',
                        error.message,
                        [{text: 'Try Again', onPress: () => {
                            this.setState({
                                paymentLoadingStatus: false,
                             })
                        }}
                      ],{cancelable: false},
                    );
                }else{
                    this.setState({
                        paymentLoadingStatus: false, 
                        resCode: "red",
                        paymentModalResponseStatus: true, 
                        paymentModalResponseMsg: error.message
                    })
                }
            })
    }

@the-wunmi the-wunmi linked a pull request Jan 24, 2020 that will close this issue
@tobilastik
Copy link

@tolu360 I am still experiencing this on iOS, any solution please?

@osammy
Copy link

osammy commented Aug 13, 2020

@tolu360 I keep getting this error Error: Another request is still being processed, please wait even though the button is clicked once. Is there a solution for this ?

@osammy
Copy link

osammy commented Aug 13, 2020

@tolu360 I am still experiencing this on iOS, any solution please?

#46 fixed this for me. check it out and adjust your code accordingly

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

Successfully merging a pull request may close this issue.

5 participants