I’m want to know how can I call this method “squareClient.getPaymentsApi().cancelPaymentByIdempotencyKey(new CancelPaymentByIdempotencyKeyRequest(createPaymentRequest.getIdempotencyKey()));” currently I’m only doing the createPaymentRequest() to squareclient.
What Square product are you using? Currently canceling a payment by the idempotencyKey
isn’t currently available.
Square client interface has been used in the code base on which I’m currently working and the new requirement is such that I just need to implement a call to cancel payment by idempotency key
This could just be me getting confused and getting it wrong…
If you’re using the API (and it looks like you are) you should be able to use this API call to cancel the payment via idempotency key:
https://developer.squareup.com/reference/square/payments-api/cancel-payment-by-idempotency-key
The caveat is that the documentation implies it is only for cancellation shortly after/during the payment being made.
If the payment has been fully completed, the doco sounds like the cancellation may still work, but if not, you could easily search for the number and do a refund.
If this form of idempotency call doesn’t work it would be great to know, and to have the API documentation corrected, just to avoid confusion in my brain at least.