question

skodama avatar image
skodama asked sam Deactivated commented

Calling Intents.ACTION_ADD_TIP with startActivityForResult returns Activity.RESULT_CANCELED and null Intent

I'm trying to add tip to a payment by calling Intents.ACTIONADDTIP with Intents.EXTRAPAYMENTID set, and the Tips app is showing up and I can add/modify the tip.

However, after pressing "Done", I'm receiving Activity.RESULT_CANCELED and null as the result Intent, even though the tip is added/modified successfully. (I have checked it with the Tips app)

I was expecting a result code of Activity.RESULT_OK and a payment data in the result Intent. Is this a bug?

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

sam avatar image
sam Deactivated answered sam Deactivated commented
/**
   * Launch activity to add tip to requested payment
   * <p>
   * Extras passed:
   * <ul>
   * <li>{@link #EXTRA_PAYMENT_ID} - UUID of payment associated with tip</li>
   * <li>{@link #EXTRA_TITLE} - label on the tip activity's back button</li>
   * </ul>
   * <p>
   * Result data includes:
   * <ul>
   * <li>NONE</li>
   * </ul>
   */
  public static final String ACTION_ADD_TIP = "clover.intent.action.ADD_TIP";

ACTIONADDTIP opens the tip app, allowing user to add tip to several payments. It doesn't have a response data. Would it be possible you're looking to implement ACTIONCUSTOMERADDTIP, which returns EXTRATIP_AMOUNT? This allows you to add tip to one specific order and returns data if successfully added.

/**
   * Launch activity have a customer add a tip to a payment
   * <p>
   * Extras passed:
   * <ul>
   * <li>{@link #EXTRA_ORDER_ID} - Order UUID, the order associated with the payment and tip (REQUIRED)</li>
   * <li>{@link #EXTRA_AMOUNT} - Long, the amount of the payment the tip will be added to (REQUIRED)</li>
   * </ul>
   * <p>
   * Result data includes:
   * <ul>
   * <li>{@link #EXTRA_TIP_AMOUNT} Long, the amount of the added tip </li>
   * </ul>
   * <p>
   * Result codes:
   * <ul>
   *     <li>{@link android.app.Activity#RESULT_OK} - tip added successfully</li>
   *     <li>{@link android.app.Activity#RESULT_CANCELED} - tip not added successfully</li>
   * </ul>
   */
  public static final String ACTION_CUSTOMER_ADD_TIP = "clover.intent.action.CUSTOMER_ADD_TIP";
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.

skodama avatar image skodama commented ·

Hi @Sam,

I have tried the Intents.ACTIONCUSTOMERADDTIP and confirmed that we can get the result back with Activity.RESULTOK and the tip amount in the result intent extra.

However, I noticed that the tip added this way is not actually reflected to the payment. I have checked the payment data with the Tips app and the tip amount is not added to the payment, even though I received the RESULT_OK.

0 Likes 0 ·
sam avatar image sam commented ·

ACTIONCUSTOMERADDTIP is used to allow customers to decide how much tip they want to add to their payment. You will need to grab the resulting EXTRATIPAMOUNT and pass it along to the payment flow.

If you're trying to add tips post-transaction, you will use ACTIONADDTIP for a payment and if you want to check if the tip was added, you will need to handle the logic of checking the added tip.

0 Likes 0 ·

Welcome to the
Clover Developer Community