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

example usage in react-native #3

Open
login2tech opened this issue Jan 29, 2019 · 5 comments
Open

example usage in react-native #3

login2tech opened this issue Jan 29, 2019 · 5 comments

Comments

@login2tech
Copy link

Hi,

I am getting hard times trying to make it to work in react native.

is there any example implementation or snippet?

Anything would be really helpful.

@Kottidev
Copy link
Owner

@login2tech
You should get last SDK from hyper pay then you can integrate this package

https://github.com/Kottidev/react-native-oppwa/blob/master/android/build.gradle#L35

@YazeedAsaad
Copy link

im facing the same issue here, how can we use this package , we already contacted hyperpay and got all needed info , but there's no example how to use it , can you update the usage section @Kottidev or give us a simplified example of how to use it.

@CatalinaG
Copy link

Hello @Kottidev, I am trying to use this, but I cannot figure out how. Do you have a sample app or an example were it is used? Did somebody else here figured this out? Thanks a lot!

@vasuchawla
Copy link

hi @CatalinaG

you can try this:

import OppwaCore from 'react-native-oppwa';

then on click of a button you need to call some server side code to generate the payment ID

and then use

  OppwaCore.transactionPayment({
      checkoutID: payment_id,
      holderName: this.state.name,
      cardNumber: this.state.number,
      paymentBrand: this.state.brand_code,
      expiryMonth: this.state.month,
      expiryYear: 2024,
      cvv: this.state.cvc
    });

this will initiate the payment

then in componentDidMount use DeviceEmitter to listen to the transactionstatus change event:

  componentDidMount() {
    DeviceEventEmitter.addListener('transactionStatus', data => {
      if (data.status == 'transactionFailed') {
        alert(data.paymentError + ' : ' + data.paymentDetails);
      } else {
          alert(data.RedirectUrl);
          // open this url in webview to proceeed with the payment
      }
      alert(JSON.stringify(data));
    });
  }

@CatalinaG
Copy link

Thanks a lot @vasuchawla! This makes sense :)

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

5 participants