django-oscar / django-oscar-docdata

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

Bugs in sandbox setup? #34

Closed jedie closed 5 years ago

jedie commented 5 years ago

I start with a fresh sandbox virtualenv, inserted my docdata test backoffice settings and creates some orders... (with DOCDATA_ORDER_ID_START offset ;) )

Think there is a Bug in sandbox: The order will be created and i see it in the test backoffice "Payment Report"... But all orders are closed: the "Payment Cluster state" is: "closed_canceled" ... I guess that's wrong, right? Otherwise it's not possible to play around different situations.

One more question: In the sandbox the payment method is asked in the "checkout wizard" ... It should be possible to move that into the docdata Payment Page, isn't it? How to do this?

maerteijn commented 5 years ago

Think there is a Bug in sandbox: The order will be created and i see it in the test backoffice "Payment Report"... But all orders are closed: the "Payment Cluster state" is: "closed_canceled" ... I guess that's wrong, right? Otherwise it's not possible to play around different situations.

I don't know why this happens in your situation. I just tested an order with the sandbox and it looks like this in the test backoffice:

backoffice

One more question: In the sandbox the payment method is asked in the "checkout wizard" ... It should be possible to move that into the docdata Payment Page, isn't it? How to do this?

You should skip this view then and I think you can ask for the menu without any default pm (then docdata will show the available options):

url = facade.get_payment_menu_url(self.request, docdata_ref)
jedie commented 5 years ago

Thanks for response. Here it looks like:

grafik

Here a example log output: https://gist.github.com/jedie/41aa1f7ea5afe200cde8a71f4e7172bc

maerteijn commented 5 years ago

From your log output:

...
"POST /checkout/preview/ HTTP/1.1" 302 0
Returned from Docdata for A26A593801CF5FEBD8A6A084282F6238, callback: ERROR
...

So something went wrong with the payment as the ERROR callback was called from Docdata.

jedie commented 5 years ago

So something went wrong with the payment as the ERROR callback was called from Docdata.

Thank you for pointing that out.

But i used the default sandbox settings. The only thing I can spontaneously think of are the "Merchant URLs" in the testbackoffice under "Settings / View/Edit Merchant Profile / URL" ?

This condition should then be mentioned in the README, right?

maerteijn commented 5 years ago

Those URL's are the callback url's for delayed payments so Docdata can notify the Oscar system. In this case you are redirected immediately back by the callback URL from the payment menu, so this is not related to these Merchant URL settings.

In your case there was an error with the actual payment, that's why you are (directly) redirected back with an ERROR callback.

jedie commented 5 years ago

In your case there was an error with the actual payment, that's why you are (directly) redirected back with an ERROR callback.

Okay. Then the questions is: What's happens here? You use the same sandbox setup and it works and i used the same and it doesn't ?!?

maerteijn commented 5 years ago

Well something goes wrong with the actual payment (and the selected payment provider), that's why there is an error callback.

This is happening outside the sandbox application, as the callback is just a result of the actual payment.

What is the payment method you use? What do you seen when you follow the flow and come back?

jedie commented 5 years ago

I didn't see any page from docdata, because i will be redirected form

directly back to

see:

grafik

That's with all payment method.

maerteijn commented 5 years ago

So the error occurs at Docdata.

Can you post the complete redirect url? (the https://test.docdatapayments.com/ps/menu?...)

jedie commented 5 years ago

https://test.docdatapayments.com/ps/menu?command=show_payment_cluster&payment_cluster_key=07...23&merchant_name=foo_bar&return_url_success=http%3A%2F%2F127.0.0.1%3A8000%2Fapi%2Fdocdata%2Freturn%2F%3Fcallback%3DSUCCESS%26order_id%3D07...23&return_url_pending=http%3A%2F%2F127.0.0.1%3A8000%2Fapi%2Fdocdata%2Freturn%2F%3Fcallback%3DPENDING%26order_id%3D07...23&return_url_canceled=http%3A%2F%2F127.0.0.1%3A8000%2Fapi%2Fdocdata%2Freturn%2F%3Fcallback%3DCANCELLED%26order_id%3D0...23&return_url_error=http%3A%2F%2F127.0.0.1%3A8000%2Fapi%2Fdocdata%2Freturn%2F%3Fcallback%3DERROR%26order_id%3D07...23&client_language=EN-US&default_pm=IDEAL

maerteijn commented 5 years ago

The merchant_name=foo_baris in your real situation replaced with the correct merchant name right?

Other than that I don't see any strange thing heres: The payment_cluster_key was successfully returned in an earlier call by Docdata's API and the rest of the URL looks fine to me.

You should contact Docdata about this: The error occurs in their platform.

jedie commented 5 years ago

The merchant_name=foo_baris in your real situation replaced with the correct merchant name right?

Yes, it's the real merchant name and i replace it here...

Btw. i also try the new SKIP_PAYMENT_CHOICES=True with the same result.

I will contact docdata...

maerteijn commented 5 years ago

SKIP_PAYMENT_CHOICES=1 (not True, see https://github.com/django-oscar/django-oscar-docdata/blob/master/sandbox/settings.py#L225)

jedie commented 5 years ago

Sorry. I set SKIP_PAYMENT_CHOICES=True directly into src/django-oscar-docdata/sandbox/settings.py

I'm in contact with docdata... First idea from them: "&client_language=EN-US" should be "&client_language=en"

I changed oscar_docdata/gateway.py

@@ -480,7 +480,7 @@ class DocdataClient(object):
             'return_url_pending': url_format.format(return_url, callback='PENDING', order_id=order_key),
             'return_url_canceled': url_format.format(return_url, callback='CANCELLED', order_id=order_key),
             'return_url_error': url_format.format(return_url, callback='ERROR', order_id=order_key),
-            'client_language': (client_language or get_language()).upper()
+            'client_language': to_iso639_part1(client_language or get_language())
         }
         args.update(extra_url_args)

@@ -1113,4 +1113,6 @@ def to_iso639_part1(language_code):
     """
     Convert codes like "en-us" to "en"
     """
-    return language_code.split('-', 1)[0]
+    return language_code.split('-', 1)[0].lower()

But nothing changed: cancelled immediately

jedie commented 5 years ago

The fault was with the docdata provider. They changed something and now it works.