question

georgi avatar image
georgi asked Bryanne Vega answered

Void a transaction programmatically

We have an app which is registered to MODIFY_ORDER and adds discount to an order. I want if our server is down to void the Clover transaction after it happened. I have set a receiver for:

<action android:name="com.clover.intent.action.ORDER_CREATED" />
<action android:name="com.clover.intent.action.PAYMENT_PROCESSED" />

How can I void the transaction and let merchant have the order paid without discount?

More details:

We give loyalty points to customers when the merchant uses our app. He can also spend the points the customer earns.

When he spends the points we make a request to our server and save the order id and the points count and also add discount to the order based on the points.

After the order is paid in the receiver we actually make a request to our server and spend the customer points on our side. But what happens if we gave a discount to the customer and after the order is paid we could not contact our server to spend customer points? Can I just void the transaction and display a message?

Solution 1: Other way is to refund the payment. But using the Void Transaction option is better.

P.S.1 I get the this error when I use void payment 2. What is the required permission? I have them all checked... :

orderConnector.voidPayment2(orderId, order.getPayments().get(0).getId(), null, VoidReason.USER_CANCEL, packageName);

W/System.err: com.clover.sdk.v1.ForbiddenException: App doesn't have required permission
Orders
10 |2000

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

Bryanne Vega avatar image
Bryanne Vega answered

I believe the only chance to do a void is though the "Void" button in the receipt screen, afterwards you must do a refund.

10 |2000

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

Jeffrey Blattman avatar image
Jeffrey Blattman answered

To augment Bryanne's comment, yes third-parties are not allowed to void. This is a sensitive operation since it essentially undo's the payment taking, money away from the merchant. You probably wouldn't want to do this even if you could, since the customer would walk out with merchandise they didn't pay for.

I'd suggest that instead of doing a try and fail, you implement a reliable queue of network operations, so even if the server is down, the client will retry the operation until it eventually succeeds. This is what we do for most of our online operations.

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