forked from nemiah/phpFinTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.php
54 lines (45 loc) · 1.72 KB
/
transfer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpUndefinedMethodInspection */
/** @noinspection PhpUndefinedNamespaceInspection */
/** @noinspection PhpUndefinedClassInspection */
/**
* SAMPLE - Execute a SEPA transfer.
*
* Note: The phpFinTs library only implements the FinTS protocol. For SEPA transfers, you need a separate library to
* produce the SEPA XML data, which is then wrapped into FinTS requests. This example uses the phpSepaXml library
* (see https://github.com/nemiah/phpSepaXml), which you need to install separately.
*/
use nemiah\phpSepaXml\SEPACreditor;
use nemiah\phpSepaXml\SEPADebitor;
use nemiah\phpSepaXml\SEPATransfer;
// See login.php, it returns a FinTs instance that is already logged in.
/** @var \Fhp\FinTs $fints */
$fints = require_once 'login.php';
$dt = new \DateTime();
$dt->add(new \DateInterval('P1D'));
$sepaDD = new SEPATransfer([
'messageID' => time(),
'paymentID' => time(),
]);
$sepaDD->setDebitor(new SEPADebitor([ //this is you
'name' => 'My Company',
'iban' => 'DE68210501700012345678',
'bic' => 'DEUTDEDB400', //,
//'identifier' => 'DE98ZZZ09999999999'
]));
$sepaDD->addCreditor(new SEPACreditor([ //this is who you want to send money to
//'paymentID' => '20170403652',
'info' => '20170403652',
'name' => 'Max Mustermann',
'iban' => 'CH9300762011623852957',
'bic' => 'GENODEF1P15',
'amount' => 48.78,
'currency' => 'EUR',
'reqestedExecutionDate' => $dt,
]));
$sendSEPATransfer = \Fhp\Action\SendSEPATransfer::create($oneAccount, $sepaDD->toXML());
$fints->execute($sendSEPATransfer);
if ($sendSEPATransfer->needsTan()) {
handleStrongAuthentication($sendSEPATransfer); // See login.php for the implementation.
}