question

coder12 avatar image
coder12 asked coder12 commented

PaymentConnector onSaleResponse() Function not Being Called on an Override Interface Implementation

I have a payment connector that I create with a listener but for some reason the listener is not called at all. It sometimes got called but now it just stopped being executed once running code. Did I do something wrong or am I missing something?

The class that I override and implement is: public class PaymentConnectorListener implements IPaymentConnectorListener { private Context context;

    public PaymentConnectorListener(Context context) {
        this.context = context;
    }

    @Override
    public void onSaleResponse(SaleResponse response) {
        String result;
        if (response.getSuccess()) {
            result = "Sale was successful";
        } else {
            result = "Sale was unsuccessful" + response.getReason() + ":" + response.getMessage();
        }

        // Use the context to start a new activity or create a new intent
        Intent intent = new Intent(context, YourActivity.class);
        intent.putExtra("result", result);
        context.startActivity(intent);
    }
}

I initialize the Listener in a service class as:

final IPaymentConnectorListener ccListener = new PaymentConnectorListener(this);

and in that service I initialize the payment connector as:

private PaymentConnector initializePaymentConnector() {
        if (account == null) {
            account = Accounts.getAccount(this);

            if (account == null) {
                Toast.makeText(this, "there is no account", Toast.LENGTH_SHORT).show();
            }
        }
        if (paymentConnector == null) {
            // Set your RAID as the remoteApplicationId
            String remoteApplicationId = "some_id";
            paymentConnector =  new PaymentConnector(this, account, ccListener, remoteApplicationId);
            paymentConnector.initializeConnection();
            return paymentConnector;
        }
        return paymentConnector;
    }

but for some reason the listener is not being called on payment response. Is my implementation correct? Any help would be appreciated.

Clover Android SDKsemi-integrationsPaymentConnector
2 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.

bryanvargas avatar image bryanvargas ♦♦ commented ·

I know we have an example of using the paymentConnector: https://docs.clover.com/docs/take-a-payment-with-payment-connector

are you initializing the paymentConnector in your onCreate?

0 Likes 0 ·
coder12 avatar image coder12 bryanvargas ♦♦ commented ·
Hi I found the issue, it seems to be that my listener was initialized outside the class so it wasn't called. moving that to the corresponding class fixed the issue.
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