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.
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?
5 People are following this question.