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 MiniIntentsSaleAuth
10 |2000

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

Raymond Lee avatar image
Raymond Lee Deactivated answered
Hi @Janaka,

Here are my answers to your questions below:

Question 1: How to read declined payment reason from Secure Pay?

Currently there is no method of getting the declined information from Secure Pay. I will file a request for an easy way to get the declined information for you.

Question 2: If the resultCode == RESULT_OK in onActivityResult(), can the Payment object cloverPayment that is returned be null?

Yes, if the resultCode == RESULT_OK, the cloverPayment Payment object will not be null, as a RESULT_OK means a payment was successfully made and returned.

Question 3: Can I pass a customer ref field to Secure Pay to be able to search for this customer ref in the web Transactions app?

No, our Payment objects currently do not have a field to store a Customer reference, so there is no customer ref field to pass to Secure Pay to insert into the Payment object returned. Also, in the web Transactions app, you can only search transactions by transaction id, transaction number, or last4 digits of credit card number.

Hope that helps,

Raymond
10 |2000

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

dhanaraj avatar image
dhanaraj answered Raymond Lee Deactivated commented
@Raymond Lee I am also facing the same issue. onActivityResult method always return RESULT_CANCELED.
6 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.

Raymond Lee avatar image Raymond Lee commented ·

Hi @Dhanaraj,

You will get RESULT_CANCELED as a return value if you exit out of the Secure Pay app without completing a payment, cancel a payment in progress, or if your payment was declined and you decide not to retry the payment.

You will only get a RESULT_OK if a payment was successfully completed.
-Raymond

0 Likes 0 ·
dhanaraj avatar image dhanaraj Raymond Lee commented ·

Hi @Raymond Lee,

https://github.com/clover/android-examples/tree/master/paywithsecurepaymentexample

Paywithsecurepayment example also returns the RESULT_CANCELED value when I tried to make a payment for order.

0 Likes 0 ·
dhanaraj avatar image dhanaraj Raymond Lee commented ·
@Raymond Lee Here I attached the logs for your reference. logs.pdf
0 Likes 0 ·
logs.pdf (24.6 KiB)
Raymond Lee avatar image Raymond Lee dhanaraj commented ·

@Dhanaraj, can you provide more detail on how to reproduce what you are seeing? Are you seeing RESULT_CANCELED right after hitting "Pay with intent"/"Pay", or during the Secure Pay transaction? What was the last message you received from the Secure Pay app?

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community