Skip to content

Can I use it in hybrid mobile app? #3

Open

Description

@ckristhoff

My mobile app is developed with hybrid technologies (javascript). Can I use this one in my mobile app?
I tried it but I'm getting errors after the payment.

Activity

  1. Cyberfolks commented on Jul 7, 2020

    @Cyberfolks

    hi @ckristhoff can you please share your way. im using in reactjs and all scripts are loaded successfully but issue is response handling. how can we handle callback/return data.

  2. ckristhoff commented on Jul 13, 2020

    @ckristhoff
    Author

    Hi @Cyberfolks
    don't use this package in your react native app. It uses browser features. Use the android and IOS native libs and integrate by native modules
    https://reactnative.dev/docs/native-modules-ios
    https://reactnative.dev/docs/native-modules-android
    Of course you need to know java and objective-c/swift basis.

  3. bhuvanmalik007 commented on Jul 9, 2021

    @bhuvanmalik007

    Hi @Cyberfolks ,
    were you able to handle the responses in React? Please let me know how you did it if you were able to. I'm stuck in the same situation.
    Thanks!

  4. fgarciapds commented on Jul 9, 2021

    @fgarciapds
  5. Cyberfolks commented on Jul 19, 2021

    @Cyberfolks

    hi @bhuvanmalik007 sorry for too much late we were busy in working.
    i did just initial setup and later on client change is mind and stop woking with Movil.
    here is my initial code how i handled this.
    REACT JS.
    load movil script in index.html of project.
    then load this script in your component.
    declare Variable before starting component.

    let PayPalButton = null;

    Start your component

    const MakePayment = ({ bill, items, itemsTotal }) => {

    use Hook useEffect to load script.

    ` useEffect(() => {

    //Check button status after each 10 sec. you can change it to any.
    PayPalButton = setInterval(intervalBtn, 10 *1000);

    const paymentData = document.createElement('script');
    let data = document.createTextNode(`ATHM_Checkout = {
          env: 'sandbox',
          publicToken: 'publicToken',
          timeout: 500,
          theme: 'btn',
          lang: 'en',
          total: 1.00,
          tax: 1.00,
          subtotal: 1.00,
          metadata1: '++ test',
          metadata2: 'metadata2 test',
          items: [
            {
              "name": "First Item",
              "description": "This is a description.",
              "quantity": "1",
              "price": "1.00",
              "tax": "1.00",
              "metadata": "metadata test"
            }
          ],
          onCompletedPayment: function (response) {
            console.log('onCompletedPayment', response)
            window.completePay = response
          },
          onCancelledPayment: function (response) {
            // console.log('onCancelledPayment', response)
            // window.canPay = response
          },
          onExpiredPayment: function (response) {
          // console.log('onExpiredPayment', response)
          // window.expirePay = response
          }
        }`
    )
    paymentData.async = true;
    paymentData.appendChild(data);
    const script = document.createElement('script');
    const jQueryData = document.createElement('script');
    script.src = `https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js`;
    jQueryData.src = `https://www.athmovil.com/api/js/v2/athmovilV2.js`;
    script.async = true;
    jQueryData.async = true;
    document.body.appendChild(script);
    document.body.appendChild(jQueryData);
    document.body.appendChild(paymentData);
    

    })

    const paymentVerify= (data) => {
    console.log('paymentVerify', data)
    fetch(https://www.athmovil.com/rs/v2/transactionStatus, {
    method: "POST",
    headers: {
    'Content-Type': 'application/json'
    },
    body: {
    "publicToken": "",
    "privateToken": "",
    "referenceNumber": ""
    }
    })
    .then((response) => response.json())
    .then((responseData) => {
    console.log('responseData', responseData);
    })
    .catch((error) => {
    console.log('error', error);
    });
    }

    const intervalBtn= () => {
    if (window.completePay != undefined) {
    paymentVerify(window.completePay);
    clearInterval(PayPalButton)
    }
    }`

    Remember its was just initial setup but it was working fine on test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions