Code Monkey home page Code Monkey logo

Comments (5)

jonarderic74 avatar jonarderic74 commented on July 24, 2024

Hello,
personnaly, i use findViewById(com.izettle.payments.android.ui.R.id.payment_failure_dismiss) and callOnClick().

from sdk-android.

pynting avatar pynting commented on July 24, 2024

Hi jonarderic74, and thanks a lot for you reply!
I was not able to get this to work, I maybe would need a more fleshed out example... When I tried to create a variable that held that view the app crashed... How do you know when that view is visible from the MainActivity?

My crude solution that seems to work, but is not at all fool proof, is to have a postDelayed set at 80 seconds, restarting the payment request with a Intent.FLAG_ACTIVITY_NO_HISTORY, so that it kills off any already existing payment requests. This is a crude solution, and can cause problems if people are slow when typing their pin code for example. For now it is probably ok, everyone has contactless cards in my region, and has gotten well accustomed to using it over the last year or so!

from sdk-android.

jonarderic74 avatar jonarderic74 commented on July 24, 2024

Hello,

You can not do a FindView on a MainActivity for the intent of zettle.
The SDK use another activity for the log and another for the payment.
So, you need to get the current activity to do a FindView to activate a button (Imageview for the back or Button for the dissmiss).

Waiting a Listen, Handler, or statepayment from the sdk or better soluce, i do a spy for the current activity in a thread.
There is 2 activity :

  1. Com.izettle.android.auth.OAuthActivity for the logging
  2. Com.izettle.payments.android.ui.payment.CardPaymentActivity for all event to the payment.
    (After it is a Fragment for all event to the payment, so there is no event for activity change)
    When the activity is CardPaymentActivity your can request a FindViewById to know the event :
  • payment_connect_card_reader_title (Connexion to the reader)
  • payment_present_card_reader_image (waiting card) => you call click to the back imageview to cancel it
  • payment_pin_bullets (waiting code) => to get the state of code entrance
  • payment_processing_amount (validate payment)
  • payment_failure_dismiss (echec time out or cancel) => Timeout screen or Technicall Error
  • payment_remove_card_title

from sdk-android.

pynting avatar pynting commented on July 24, 2024

Wow, thanks for the comprehensive answer! I will try to work this into my code. Now it is a fragile thing, but somehow works. But I would definitively like it to be more robust. I wish there was an easier way to do this though through the SDK. Maybe integrate some variable you could add to the payment intent builder to have it return automatically and report what happened. It seems it would be a lot more friendly to developers wanting to make something that relies less on interaction from a user on screen, instead of spying on the current activity. But again perhaps this is the way it is supposed to be done in mobile development?

Anyway, thanks again for being so helpful!

from sdk-android.

bobzettle avatar bobzettle commented on July 24, 2024

Hi, this seems to be a feature request for a headless SDK, one without UI for the app holder, and it's not something we have planned for at the moment.

If a transaction fails for any reason it's essential for the app holder to know that the transaction failed, and also to acknowledge that by pressing ok, or back out of the view. You should not try to do a retry of a failed transaction without the app holder invoking it. The SDK also tries to handle retries in a safe way, so to automatically retry a request after failure is rather error prone and can easily cause double charges or other side effects.

And I strongly recommend to not β€œspy” on the components of SDK since that is internal code that can change with any update and does not offer any migration-information, head op nor guarantees over different Android operating systems. It’s dangerous to assume a constant behaviour from that.

from sdk-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.