django-oscar / django-oscar-docdata

Docdata Payments Gateway integration for django-oscar
Apache License 2.0
22 stars 11 forks source link

wrong status on creditcard payments ? #58

Open jedie opened 4 years ago

jedie commented 4 years ago

Creditcard payments are considered safe directly after authorization by docdata. The captures are processed through a nightly capture batch with the acquirer.

Docdata facade set the status "pending" until the nightly capture batch has been running.

The result is that my actual shop action is not executed until the next day. But it will be safe to execute the shop action, after the first step (payment is considered as safe after authorization)

Here a example diff between a not save and a save authorization:

--- docdata/docdata_mastercard_not_save.xml
+++ docdata/docdata_mastercard_is_save.xml
@@ -2,11 +2,11 @@
   <statusSuccess>
     <success code="SUCCESS">Operation successful.</success>
     <report>
-      <approximateTotals exchangedTo="EUR" exchangeRateDate="2019-07-16 14:44:34">
+      <approximateTotals exchangedTo="EUR" exchangeRateDate="2019-07-16 14:45:51">
         <totalRegistered>3330</totalRegistered>
         <totalShopperPending>0</totalShopperPending>
         <totalAcquirerPending>0</totalAcquirerPending>
-        <totalAcquirerApproved>0</totalAcquirerApproved>
+        <totalAcquirerApproved>3330</totalAcquirerApproved>
         <totalCaptured>0</totalCaptured>
         <totalRefunded>0</totalRefunded>
         <totalChargedback>0</totalChargedback>
@@ -16,14 +16,16 @@
         <id>4910291206</id>
         <paymentMethod>MASTERCARD</paymentMethod>
         <authorization>
-          <status>NEW</status>
+          <status>AUTHORIZED</status>
           <amount currency="EUR">3330</amount>
           <confidenceLevel>ACQUIRER_APPROVED</confidenceLevel>
         </authorization>
       </payment>
       <consideredSafe>
-        <value>false</value>
+        <value>true</value>
         <level>SAFE</level>
+        <date>2019-07-16T14:44:38.060+02:00</date>
+        <reason>EXACT_MATCH</reason>
       </consideredSafe>
       <apiInformation conversionApplied="false">
         <originalVersion>1.3</originalVersion>

I don't know if this is just due to a wrong setting in my project or if code changes in django-oscar-docdata are necessary?

jedie commented 4 years ago

I take a look into oscar_docdata/interface.py and i think the

oscar_docdata.interface.Interface._process_authorized_payment() is the right code part to handle this.

This is interesting:

# Integration Manual Order API 1.0 - Document version 1.0, 08-12-2012 - Page 33:
#
# Safe route: The safest route to check whether all payments were made is for the merchants
# to refer to the "Total captured" amount to see whether this equals the "Total registered
# amount". While this may be the safest indicator, the downside is that it can sometimes take a
# long time for acquirers or shoppers to actually have the money transferred and it can be
# captured.
#
if totals.totalCaptured < (totals.totalRegistered - margin):
    return None

I conclude from this that it is a conscious decision not to use the "safe" status and wait for the actual payment?