question

vhernandez avatar image
vhernandez asked David Marginian Deactivated commented

(Clover Mini, Android) capturePreAuth does not call the callback method (onCapturePreAuthResponse)

(Clover Mini, Android)

I'm trying to do capturePreAuth, however the behaivour is so weird, I made two implementations, and any of them don't work. Can someone help me, maybe I doing something wrong. thanks.

First implementation:

I have a background service running each 30 seconds, in this service I call the method, on this implementation always onCapturePreAuthResponse (the callback) is executed, however if someone is writing on the android keyboard during capturePreAuth is happening, the keyboard goes away, how can it happen? why?.


Second implelentation>

I moved the implementation into a fragment, the problem here is almost never onCapturePreAuthResponse (the callback) is executed, so the application gets stuck.


I basically have the same implementation in both cases:



   //I call this method when the fragment or service is ready 
   @Override
   public void initPaymentConnector() {
       if (paymentConnector == null) {
           paymentConnector = new PaymentConnector(getActivity(),
                   CloverAccount.getAccount(getActivity()),
                   this, BuildConfig.APPLICATION_ID);
           paymentConnector.initializeConnection();
       }
   }


   // IPaymentConnectorListener Methods 

   //Sometimes this method is called and sometimes is not
   @Override
   public void capture(CapturePreAuthRequest request) {
       paymentConnector.capturePreAuth(request);
   }

...

    @Override
    public void onCapturePreAuthResponse(CapturePreAuthResponse response) {
        presenter.deleteCaptureData(response);
    }

   //When the device is connected, I got the captureData and I call 
   @Override
   public void onDeviceConnected() {
           presenter.getCaptureData();
           }
   
   
   // Presenter
   public void getCaptureData(IReceiptOptionsContract.IView callback) {
   
           getCaptureData.execute(new UseCaseObserver<CaptureEntity>() {
   @Override
   protected void onSuccess(CaptureEntity r) {
   
           //... Some validations
   
           CapturePreAuthRequest request = new CapturePreAuthRequest();
           request.setAmount(collected.longValue());
           request.setPaymentId(r.getPaymentId());
           request.setTipAmount(new Long(0));
   
           //
           callback.capture(request);
           }
   
   @Override
   public void onError(Throwable e) {
           super.onError(e);
           ErrorUtils.send(e, "Could capture, could not get capture data.");
           }
           }, null);
   
           }
   
   //Capture call
   @Override
   public void capture(CapturePreAuthRequest request) {
           paymentConnector.capturePreAuth(request);
   }


Clover Android SDKClover MiniPaymentConnectorRemote Pay Android
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

Are you trying to do all this work on the UI thread?

-1 Like -1 ·
vhernandez avatar image vhernandez David Marginian ♦♦ commented ·

No, I'm not, actually I saw the clover's call code and there is an AsyncTask, however my methods are happening in other thread.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ vhernandez commented ·

I'll take a closer look at what you posted later, but if this is in a fragment and you are posting complete code it doesn't look like you are firing off a new thread.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community