It would be nice to be able to do refunds (credit requests): https://www.datatrans.ch/showcase/settlement/xml-credit-request

For the time being only as an API so that we could call it from custom code.

Are the maintainers interested in this or should I put this in a custom module instead?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

czigor created an issue. See original summary.

czigor’s picture

Status: Active » Needs review
FileSize
3.8 KB

The API function to call is commerce_datatrans_refund_request($transaction, $amount). For usage see the DOxygen.

mikl’s picture

Status: Needs review » Reviewed & tested by the community
Berdir’s picture

Status: Reviewed & tested by the community » Needs review
index 0000000..9a66f16
--- /dev/null

--- /dev/null
+++ b/commerce-datatrans-refund.tpl.php

Hm, using a template for this is a bit strange.

Can we use something like the xml writer API instead?

It's pretty easy to use and shouldn't be much more complicated than preparing and passing the values to the template.

See http://api.worldempire.ch/api/tmgmt/translators%21file%21tmgmt_file.form... for an example implementation, you just write out tags and attributes seqentually.

czigor’s picture

FileSize
2.92 KB

The attached patch uses XMLWriter instead of the template.

Berdir’s picture

Status: Needs review » Needs work

Nice, looks a lot better I think. The indendation will make coding sniffers unhappy but I agree that it makes it easier to follow for humans.

+++ b/commerce_datatrans.module
@@ -603,3 +603,68 @@ function _commerce_datatrans_settings_ok($settings) {
+  if (empty($amount) || ($amount > $transaction->amount) ) {
+    $amount = $transaction->amount;
+  }
...
+          $writer->writeElement('amount', $transaction->amount);

Shouldn't this be using $amount then, otherwise it's always the full amount?

czigor’s picture

Status: Needs work » Needs review
FileSize
2.9 KB
629 bytes

Yes, it should, grrrr. Fixed it.

Berdir’s picture

Status: Needs review » Fixed

Thanks, committed and pushed.

  • Berdir committed 827cbff on 7.x-1.x authored by czigor
    Issue #2602652 by czigor, Berdir: Refund API
    

Status: Fixed » Closed (fixed)

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