Java Question Implementing a listener for sdk

DevBaby

Active Member
Licensed User
Longtime User
I am trying to use the payment verification service from devtodev. I am suppose to call their method, which will validate the purchase and return the response.

I do not understand how to implement the listener provided. most listeners that I have used have methods raised where a response value is returned.

The call is here..

B4X:
DevToDevCheat.verifyPayment(String receipt, String signature, String publicKey, OnVerifyListener onVerifyListener);

The response types are here..

B4X:
public enum VerifyStatus {  
                           Valid,
                           Invalid,
                           InternalError,
                           ServerError
                         };

I am not sure how to capture these values because the Listener has no methods such as onReturn etc. I believe this requires a different implementation that I have not seen before
 

DonManfred

Expert
Licensed User
Longtime User
How does the implementation for OnVerifyListener look like?
 

DevBaby

Active Member
Licensed User
Longtime User
How does the implementation for OnVerifyListener look like?

Thanks for your response and help with this.

The instructions does not show the implementation, below is the link and they only show what I put in the first post. I thought that I did not understand listeners but the dev may not have fully explained the implementation.

https://www.devtodev.com/help/42/android_validation_of_payments_and_time_adjustments/

I was mainly trying to find a service that verifies google transactions since I noticed fraudulent purchases in my app.
 

DonManfred

Expert
Licensed User
Longtime User
The instructions does not show the implementation
But you can look into the referenced jars in eclipse.

B4X:
        OnVerifyListener l = new OnVerifyListener(){

            @Override
            public void onVerify(VerifyStatus paramVerifyStatus) {
                // TODO Auto-generated method stub
                 if (ba.subExists(eventName + "_onverify")) {
                  BA.Log("lib:Raising.. "+eventName + "_onverify()");                               
                  //app.raiseEvent(app.context, eventName+"_pagerendered", i, pageCount, filename+"-" + i + ".png");
                  ba.raiseEventFromDifferentThread(this, null, 0, eventName + "_onverify", true, new Object[] {paramVerifyStatus.toString()});
              }else {
                  BA.Log("lib: NOTFOUND '"+eventName + "_onverify");
              }

            }};



B4X:
@Events(values={"onVerify(status As String)"})
 
Last edited:

DevBaby

Active Member
Licensed User
Longtime User
But you can look into the referenced jars in eclipse.

B4X:
        OnVerifyListener l = new OnVerifyListener(){

            @Override
            public void onVerify(VerifyStatus paramVerifyStatus) {
                // TODO Auto-generated method stub
                 if (ba.subExists(eventName + "_onverify")) {
                  BA.Log("lib:Raising.. "+eventName + "_onverify()");                              
                  //app.raiseEvent(app.context, eventName+"_pagerendered", i, pageCount, filename+"-" + i + ".png");
                  ba.raiseEventFromDifferentThread(this, null, 0, eventName + "_onverify", true, new Object[] {paramVerifyStatus.toString()});
              }else {
                  BA.Log("lib: NOTFOUND '"+eventName + "_onverify");
              }

            }};



B4X:
@Events(values={"onVerify(status As String)"})


Hi DonManfred,

Thanks for this research and your response, I will know to look there in the future. Most sdk documentation give the extra info, but now I can use your method for this issue and another listener that the vendor uses.
 
Top