pronamic / wp-pronamic-pay

The Pronamic Pay plugin allows you to easily accept payments with payment methods like credit card, iDEAL, Bancontact and Sofort through a variety of payment providers on your WordPress website.
https://pronamicpay.com
34 stars 14 forks source link

Investigate chargeback support at payment providers #170

Closed remcotolsma closed 2 years ago

remcotolsma commented 3 years ago

We are investigating how we can add support for chargebacks. With a short summary per gateway we can hopefully come to a nice solution.

remcotolsma commented 3 years ago

We already know from Mollie that they have support for chargebacks: https://docs.mollie.com/reference/v2/chargebacks-api/get-chargeback#

Mollie keeps track of the amountChargedBack value per payment. https://docs.mollie.com/reference/v2/payments-api/get-payment

The total amount that was charged back for this payment. Only available when the total charged back amount is not zero.

In https://github.com/wp-pay-gateways/mollie/blob/09c60fdfbab9eee85d58909da24c5b82d9ff51fe/src/Gateway.php#L734-L767 we already request the payment chargebacks.

remcotolsma commented 3 years ago

The iDEAL only gateways don't have support for chargebacks:

iDEAL is an Online Banking Payment method based on a four-corner model which generates a SEPA Credit Transfer from within the consumers trusted online banking portal. By using iDEAL consumers are able to pay for their online purchases in a user-friendly, cost-efficient and secure fashion. Merchants receive real-time confirmations of the iDEAL payments which are guaranteed and irrevocable.

Source: https://www.ideal.nl/en/ideal-information/

remcotolsma commented 3 years ago

At DigiWallet I only see a mention of a payment status Chargeback on https://www.digiwallet.nl/en/documentation/:

www digiwallet nl_en_documentation_paymethods_directdebit

I assume they only support full chargebacks, we could double check with the DigiWallet support department.

rvdsteege commented 3 years ago

Adyen sends notifications for disputes which include the charged back amount. Each status of the dispute process has a unique eventCode in the notification:

A dispute starts with a:

  • (optional) Notification of Fraud (NOF) - To notify you of fraud activity, Adyen sends equivalent of a Visa TC40 and Mastercard SAFE (System to Avoid Fraud Effectively) report. This is not a dispute, and no money is withdrawn from your account.
  • (optional) Request for Information (RFI) - Issuer requests more information about a transaction, no money is withdrawn from merchant account.
  • Notification of Chargeback (NoC) - A chargeback has been initiated by the issuer, and can be defended. The NoC may follow a RFI, or occur immediately after the payment status is set to Settled or Refunded, skipping the RFI step.

From there, the dispute continues through the following statuses:

  1. 1st Chargeback - The disputed amount is withdrawn from your account. If you accept the dispute, or fail to upload your defense documents, this is the final status.
  2. InformationSupplied - Adyen receives the supporting documents and forwards them to the scheme. It is no longer possible to change these documents.
  3. ChargebackReversed - The disputed amount is transferred back to your account. In this stage, the issuer reviews the defense. If they accept the defense, this is the final status.
  4. Pre-arbitration (Only Visa, MC,Diners, and Discover) - If the issuer declines your defense, they open pre-arbitration, which Adyen will review.
  5. 2nd Chargeback - If the issuer declines your defense, or Adyen accepts their pre-arbitration case, a second chargeback occurs. You can not upload defense documents. This is the final status.

Sample notification for CHARGEBACK event:

{
   "live":"true",
   "notificationItems":[
      {
         "NotificationRequestItem":{
            "additionalData":{
               "chargebackReasonCode":"10.4",
               "modificationMerchantReferences":"",
               "chargebackSchemeCode":"visa"
            },
            "amount":{
               "currency":"EUR",
               "value":1000
            },
            "eventCode":"CHARGEBACK",
            "eventDate":"2020-03-23T13:55:31+01:00",
            "merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
            "merchantReference":"XXXXXXXXXX",
            "originalReference":"9913333333333333",
            "paymentMethod":"visa",
            "pspReference":"9915555555555555",
            "reason":"Other Fraud-Card Absent Environment",
            "success":"true"
         }
      }
   ]
} 

Including originalReference in the SECOND_CHARGEBACK and CHARGEBACK_REVERSED event notifications can be enabled in the Account » Webhooks settings in the customer area.

rvdsteege commented 3 years ago

At Buckaroo, I've found the following references for chargebacks:

  1. transaction type N505 "Creditcard Chargeback" for creditcard payment method, I assume this is TransactionType in a request to json/Transaction/Status/{transactionKey}, I expect the amount of a transaction with this type is the charged back amount;
  2. the InvoiceStatusCode of an invoice (which we don't use currently):

    InvoiceStatusCode: The current status of the invoice.

    • Possible Status codes are:
      • [...]
      • 21: PausedByDispute. Like Paused, but specifically caused by a manually registered dispute.
rvdsteege commented 3 years ago

I was unable to find any API related information regarding chargebacks at EMS.

However, one sentence of note found in a Card Acceptance Operating Guide regarding chargebacks and recurring payments (emphasis mine):

If a request for Authorisation has been denied or if transactions previously resulted in a Chargeback to you, you should terminate the recurring transaction arrangement.

With Mollie, we are 'terminating' (On Hold status) subscriptions if a chargeback occurs.

rvdsteege commented 3 years ago

ICEPAY updates the status of a payment to CBACK if a payment was charged back by the end user.

rvdsteege commented 2 years ago

In https://github.com/pronamic/wp-pronamic-pay-ems-e-commerce/issues/1 we noticed that the EMS integration seems to be outdated. In the documentation of our current integration, there is no mention of chargebacks.

In the documentation of the new integration, it seems that multiple chargebacks can be linked to a payment (chargeback_orders), which would mean it supports partial chargebacks.

chargeback_of_order_id string Order identifier of the original order, if this is a chargeback

chargeback_orders array[string] Order identifiers of the related chargeback orders

rvdsteege commented 2 years ago

With MultiSafepay, documentation of the deprecated XML API does not mention chargebacks.

With the current JSON API, there are separate order and transaction statuses. According to the payment statuses documentation, both statuses will be set to Void if the customer has requested a chargeback. Once the chargebacks has been 'completed', the statuses of both the order and transaction will be updated to Completed.

It seems there is no specific order property for the chargeback amount. However, it could be that a chargeback results in a new order (with its own order ID) which contains a partial amount. This is how refunds are handled:

rvdsteege commented 2 years ago

Ingenico includes chargebacks in the daily reporting files:

A chargeback is processed by us and will be reported as a chargeback (CB record) in the daily reporting files (WX.file and in the Appendix of the Collection Reports). These reporting files should be well integrated with your own Internal Order System in order to quickly identify the chargeback and take the appropriate action.

[…]

Another method to retrieve chargebacks is by downloading a report in the WebCollect Payment Console. Under Reports/Transaction Reports you will find ‘Chargeback/Reversal’ and from there you can download all the reported chargebacks for a specific time frame.

Source: https://epayments.developer-ingenico.com/services/chargebacks

According to https://epayments-support.ingenico.com/en/integration-solutions/integrations/directlink#directlink_integration_guides_order_response there is no chargeback amount in the order, but I'm not sure if a chargeback could be derived from the order response (e.g. through NCERROR or NCSTATUS).

rvdsteege commented 2 years ago

For OmniKassa 2.0, I couldn't find any documentation regarding chargebacks.

Order results received through notifications contain a paidAmount and totalAmount. However, I'm not sure if chargebacks (1) trigger a webhook notification and (2) these amounts in the order result differ if a chargeback occurred.

rvdsteege commented 2 years ago

At Pay.nl, there's only mention of storno at https://admin.pay.nl/docpanel/api/Transaction/info/4 but this looks like a refund and not a chargeback.

paymentDetails.storno integer Indicator whether or not the transaction is refunded

  • 0: Non refunded
  • 1: Refundend

stornoDetails array

stornoAmount: Refund amount […]

rvdsteege commented 2 years ago

Payvision only seems to list chargebacks in reports. I was unable to find anything related to chargebacks in the API reference.

rvdsteege commented 2 years ago

At Sisow, a transaction can have the status Reversed. However, it is unclear when this status is actually used. We have it mapped to our payment refunded status.

rvdsteege commented 2 years ago

Targetpay mentions a transaction status 000003 Chargeback - The money has been chargebacked by the customer in the direct debit documentation. No mention of a separate chargeback amount.

rvdsteege commented 2 years ago

@remcotolsma seems most gateways do not support partial chargebacks, except for Mollie, Adyen and EMS (and possibly Buckaroo). Should we use a boolean flag or keep track of the chargeback amount?

remcotolsma commented 2 years ago

Should we use a boolean flag or keep track of the chargeback amount?

Keep track of the chargeback amount.

Partial chargebacks seem to exist:

rvdsteege commented 2 years ago

Keeping track of the charged back amount has been added, closing this issue.