Skip to content

Commit

Permalink
Add method for XMl download
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus authored and Markus committed Apr 12, 2019
1 parent 58e7c0b commit 8bc826b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ $payment->addTransaction($transaction);

$sepa->addPayment($payment);

header("Content-Type: text/xml");
header("Content-Disposition: attachment; filename=\"sepa.xml\"");
header("Pragma: no-cache");

$xml = new \MG\Sepa\Xml($sepa);
echo $
xml->get();
$xml->download('sepa.xml');
```

## Example of using SEPA Direct Debit
Expand Down Expand Up @@ -86,16 +81,12 @@ $payment->addTransaction($transaction);

$sepa->addPayment($payment);

header("Content-Type: text/xml");
header("Content-Disposition: attachment; filename=\"sepa.xml\"");
header("Pragma: no-cache");

$xml = new \MG\Sepa\Xml($sepa);
echo $xml->get();
$xml->download('sepa.xml');
```

## External Resources

* [German specification for remote data transfer between customer andbank according to the DFÜ agreement "Specification of Data Formats"](http://www.ebics.de/index.php?id=77)
* [German specification for remote data transfer between customer and bank according to the DFÜ agreement "Specification of Data Formats"](http://www.ebics.de/index.php?id=77)
* [ECB SEPA gateway page](http://www.ecb.europa.eu/paym/retpaym/html/index.en.html)
* [ISO20022 Message Catalog](https://www.iso20022.org/full_catalogue.page)
22 changes: 21 additions & 1 deletion src/lib/Sepa/Xml.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// $Id: Xml.php 7657 2019-04-12 21:26:58Z markus $
// $Id: Xml.php 7659 2019-04-12 22:45:54Z markus $
declare(strict_types=1);

namespace MG\Sepa;
Expand Down Expand Up @@ -144,6 +144,26 @@ public function save(string $filename) : bool
return true;
}

/**
* download XML
*
* @param string $filename
* @return void
*/
public function download(string $filename = '') : void
{
if (!$filename = trim($filename))
{
$filename = 'sepa.xml';
}
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename="' + $filename + '"');
header('Pragma: no-cache');

echo $this->get();
exit;
}

/**
* generate the XML file
*
Expand Down

0 comments on commit 8bc826b

Please sign in to comment.