question

janaka avatar image
janaka asked Raymond Lee Deactivated commented

Android ACTION_SECURE_PAY: Payment Response (Declined)

I'm developing an app with Clover MINI android device and using ACTION_SECURE_PAY to take payments.
Currently testing in SANDBOX environment and use "Fist Data - Test Card 01" for testing.
Also my Test Merchant have pointed to CERT gateway.

I want to test Declined Payments and was given some test card numbers that simulates Decline Payments (Eg: 375987654000004).
So to TEST declined cases just enabled CardEntering option and did test with these given test card numbers (Intents.CARD_ENTRY_METHOD_MANUAL).

Within Secure_Pay App I want user to just allow to try payment only one time. Basically if payment Failed or Declined should not allow user to re-try. Should return back with Payment Result (Declined or Failed).
For that I have specified folllwoing parameter (TransactionSettings) when start Secure_Pay intent. Also
have asked to stop perform Duplicate Check...
  • transactionSettings.setDisableRestartTransactionOnFailure(true);
  • transactionSettings.setDisableDuplicateCheck(true);

Following is the Sample code of how I start Secure_Pay Intent

TransactionSettings transactionSettings = new TransactionSettings();
// Enabled CARD_ENTRY_METHOD_MANUAL, to simulate decline payments
// entering given TEST card numbers Eg: 375987654000004
transactionSettings.setCardEntryMethods(Intents.CARD_ENTRY_METHOD_ICC_CONTACT | Intents.CARD_ENTRY_METHOD_MANUAL);
transactionSettings.setSignatureEntryLocation(DataEntryLocation.NONE);
transactionSettings.setSignatureThreshold(new Long(1000000));
// To stop re-try if failed or declined
transactionSettings.setDisableRestartTransactionOnFailure(true);
transactionSettings.setDisableDuplicateCheck(true);

// Create Intent to Start Secure Pay App.
Intent intent = new Intent(Intents.ACTION_SECURE_PAY);
intent.putExtra(Intents.EXTRA_AMOUNT, new Long(totalAmount));
intent.putExtra(Intents.EXTRA_ORDER_ID, strCloverOrderID);
intent.putExtra(Intents.EXTRA_TRANSACTION_SETTINGS, transactionSettings);
// Start 'CLOVER Secure Pay' App.
startActivityForResult(intent, SECURE_PAY_REQUEST_CODE);

And analyse payment in onActivityResult as follows

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == SECURE_PAY_REQUEST_CODE)
    {
        if (resultCode == RESULT_OK)
        {
            Payment cloverPayment = data.getParcelableExtra(Intents.EXTRA_PAYMENT);
            if (cloverPayment != null)
            {
                if (cloverPayment.getResult() == Result.SUCCESS)
                {
		     
                }
                else if (cloverPayment.getResult() == Result.FAIL)
                {
		    // DECLINED PAYMENT NOT REACH HERE ???
                }
                else
                {

                }
            }
            else
            {
                // Can "cloverPayment" be null under RESULT_OK ???
            }
        }
        else if (resultCode == RESULT_CANCELED)
        {
            // DECLINED Payment reach here. Which is WRONG....

            // parameter 'data' is null at here
	    // So no way to read decline Payment Information
            // PaymentID, Declined reason etc to check later
        }
        else
        {

        }
    }
}   


Question 1:
All good... In Secure_Pay App, the payment Declines and show the message to user that it's Declined. As I have asked not allow to re-try payment if declined or failed, it shows Done and Print buttons.

Now the problem begins. When press Done button it reach under resultCode == RESULT_CANCELED, in onActivityResult method even it isn't a cancelled case (Declined situation) .

So there is no way of reading the Declined Payment information (PaymentID etc) as 'data' parameter is NULL under RESULT_CANCELED, if try to get in the following way.
  • Payment cloverPayment = data.getParcelableExtra(Intents.EXTRA_PAYMENT);
Please check the sample code and let me know how to read Declined Payment Information.

Question 2:
In onActivityResult, under "resultCode == RESULT_OK " can cloverPayment be null for any reasons at all, when try to read as follows? Please check sample code as it's asked there as well clearly
  • Payment cloverPayment = data.getParcelableExtra(Intents.EXTRA_PAYMENT);

Question3:
Is there any specific parameter that I can send when Start Secure_Pay intent to pass a Cutomer Ref (a NON unique reference field).
Just to easily search old transaction later in Web dashboard with this Customer Ref pass in here?

Thanks





Clover Android SDKClover MiniSaleAuth
10 |2000

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

1 Answer

dhanaraj avatar image
dhanaraj answered Raymond Lee Deactivated commented
@Raymond Lee I am also facing the same issue. onActivityResult method always return RESULT_CANCELED.
10 |2000

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