-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectVAExample.php
49 lines (43 loc) · 1.29 KB
/
DirectVAExample.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
<?php
/**
* DirectVAExample.php.
*
* @author Ferdhika Yudira
* @email fer@dika.web.id
*/
require './vendor/autoload.php';
use ferdhika31\iPaymuPHP\Exceptions\InvalidApiKeyException;
use ferdhika31\iPaymuPHP\Exceptions\InvalidArgumentException;
use ferdhika31\iPaymuPHP\iPaymu;
use ferdhika31\iPaymuPHP\PaymentDirect;
$config = [
'env' => 'SANDBOX',
'virtual_account' => 'your_virtual_account',
'api_key' => 'your_api_key',
'notify_uri' => 'http://localhost:8000/notify',
];
try {
iPaymu::init($config);
$customer = [
'name' => 'Dika',
'email' => 'fer@dika.web.id',
'phone' => '083213123332',
];
iPaymu::setCustomer($customer);
$payloadTrx = [
'amount' => 5000,
// optional
'expired' => 10,
'expiredType' => 'minutes', // in:seconds,minutes,hours,days
'comments' => 'Transaction comment here',
'referenceId' => 'TRX202008310001',
];
// Available channel: bag, bni, cimb (default), mandiri
$channel = 'mandiri';
$directPayment = PaymentDirect::VA($channel)->create($payloadTrx);
var_dump($directPayment);
} catch (InvalidApiKeyException $e) {
echo $e->getMessage();
} catch (InvalidArgumentException $e) {
echo $e->getMessage();
}