mollie / mollie-api-python

Mollie API client for Python
http://www.mollie.com
BSD 2-Clause "Simplified" License
113 stars 55 forks source link

The payment status is not the same as in Mollie's web dashboard account. #310

Closed nikolaysm closed 1 year ago

nikolaysm commented 1 year ago

The transaction was charged back, but through the API we still get the status "paid". How can we get the right transaction status?

fjbender commented 1 year ago

Hi @nikolaysm,

This sounds like unusual behavior. However, it has nothing really to do with the Python API Client. May I ask you to contact our support team, please? They'll be able to help you find out what happened to your payment exactly, and can advise you on how to handle those cases in the future.

Thanks Florian

fjbender commented 1 year ago

Just for clarification, as I might have misunderstood/over-interpreted your question: Does payment.has_chargebacks() return True or False for you on that particular payment?

In our API, payments remain paid, but get a chargeback object attached to them.

nikolaysm commented 1 year ago

Hi @fjbender,

Yes, payment.has_chargebacks() does return True.

Why don't we get the same statuses through the API?:

image

According to API docs, the status can have the following values: ["open", "canceled", "pending", "authorized", "expired", "failed", "paid"].

And how about the following values?:

CHARGEBACK = "chargeback" -> payment.has_chargebacks()
REFUNDED = "refunded"  - > payment.has_refunds()
SETTLED = "settled" - > bool(payment. settlement_id) ?
PARTIALLY_REFUNDED = "partially-refunded"  - > ????
REFUND_PROCESSING = "refund-processing"  - > ????
BLOCKED = "blocked" - > ????

Thanks, Nikolay

nikolaysm commented 1 year ago

It is not clear to me, why Mollie doesn't provide the same status through the API as it used in Mollie's web dashboard?

Through the Mollie's internal API you can get the right status:

{
  "resource":"payment",
  "id":"tr_xxxxxx",
  "mode":"test",
  "createdDatetime":"2023-04-xxxxxxx",
  "status":"charged_back" ⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️⬅️
  ...
}
fjbender commented 1 year ago

The Payment State Machine is very simple and doesn't contain all statuses listed above.

The other statuses you list are not part of that state machine, but rather properties of the payment in general. This is why the Python API Client provides you with shortcuts like payment.has_chargebacks(). A similar approach is used to prepare data to be displayed in the Dashboard, which is why you see that status there but not on the Payments API.

whyscream commented 1 year ago

I'll see if we can add Payment.has_settlement() shortly, all data for this is already available in the payment object.

For partially-refunded and refund-processing, I guess we need to actually fetch the refunds and inspect the data, which is higher-level functionality that I'd to leave to the developer (as this needs additional API requests).

From the status change docs, I don't really see how the blocked status could be extracted from the payment data.

Reopening as a reminder for implementing Payment.has_settlement()