Problem/Motivation

It is a common business requirement to refund payments. The current payment gateway does not support refunds.

Steps to reproduce

Not applicable.

Proposed resolution

Implement the interface Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\SupportsRefundsInterface

Remaining tasks

Implement

User interface changes

Add field to config form for the refund API URL (https://api-reference.datatrans.ch/#credit-refunds)

API changes

Add methods canRefundPayment and refundPayment as per the interface.

Data model changes

Add field to config for the Datatrans API Url.

CommentFileSizeAuthor
#3 commerce-datatrans-refund-3173515-2.patch16.16 KBberdir

Comments

tcrawford created an issue. See original summary.

berdir’s picture

Assigned: Unassigned » berdir
berdir’s picture

Status: Active » Needs review
StatusFileSize
new16.16 KB

Here's a patch, seems to be working for me.

I did add a setting for the password, that is mandatory for this, the URL for now I just adapt from the default URL. That is a bit ugly, but should work for now. Also corrected the default configuration to the use the format.

This is the new API while the rest of the module still works with the old API. I think in light of the issues with session cookies and so on, it would be better to rewrite the module to use the new API only. That will likely require a completely new approach to settings anyway, most won't be needed anymore and I think I will then just use the test/live setting and hardcode the actual URL's, they are unlikely to change I assume.

But for now, it should work, I verified with the Datatrans team that it is OK to use to mix the two API's, but of course they recommend to only use the new API.

tcrawford’s picture

@Berdir Thanks. This looks good to me. What was the reason for not allowing redirects by the guzzle client? In testing I found that some of the older Datatrans urls redirect to newer urls.

berdir’s picture

We're doing POST requests, redirects on POST result in losing the body which can be very confusing and hard to debug. I usually add the no redirect argument whenever I'm doing POST requests on an API.

berdir’s picture

Status: Needs review » Fixed

Committed.

  • Berdir committed b332027 on 8.x-1.x
    Issue #3173515 by Berdir: Support refunds
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.