forked from xendit/xendit-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEWalletsExample.php
More file actions
83 lines (70 loc) · 1.97 KB
/
EWalletsExample.php
File metadata and controls
83 lines (70 loc) · 1.97 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* EWalletsExample.php
* php version 7.2.0
*
* @category Example
* @package Xendit/Examples
* @author Ellen <ellen@xendit.co>
* @license https://opensource.org/licenses/MIT MIT License
* @link https://api.xendit.co
*/
use Xendit\Xendit;
require 'vendor/autoload.php';
Xendit::setApiKey('SECRET_API_KEY');
$ovoParams = [
'external_id' => 'demo-' . time(),
'amount' => 32000,
'phone' => '081298498259',
'ewallet_type' => 'OVO'
];
$danaParams = [
'external_id' => 'demo_' . time(),
'amount' => 32000,
'phone' => '081298498259',
'expiration_date' => '2020-02-20T00:00:00.000Z',
'callback_url' => 'https://my-shop.com/callbacks',
'redirect_url' => 'https://my-shop.com/home',
'ewallet_type' => 'DANA'
];
$linkajaParams = [
'external_id' => 'demo_' . time(),
'amount' => 32000,
'phone' => '081298498259',
'items' => [
[
'id' => '123123',
'name' => 'Phone Case',
'price' => 100000,
'quantity' => 1
],
[
'id' => '345678',
'name' => 'Powerbank',
'price' => 200000,
'quantity' => 1
]
],
'callback_url' => 'https =>//yourwebsite.com/callback',
'redirect_url' => 'https =>//yourwebsite.com/order/123',
'ewallet_type' => 'LINKAJA'
];
try {
$createOvo = \Xendit\EWallets::create($ovoParams);
var_dump($createOvo);
} catch (\Xendit\Exceptions\ApiException $exception) {
var_dump($exception);
}
$createDana = \Xendit\EWallets::create($danaParams);
var_dump($createDana);
$createLinkaja = \Xendit\EWallets::create($linkajaParams);
var_dump($createLinkaja);
$getOvo = \Xendit\EWallets::getPaymentStatus($ovoParams['external_id'], 'OVO');
var_dump($getOvo);
$getDana = \Xendit\EWallets::getPaymentStatus($danaParams['external_id'], 'DANA');
var_dump($getDana);
$getLinkaja = \Xendit\EWallets::getPaymentStatus(
$linkajaParams['external_id'],
'LINKAJA'
);
var_dump($getLinkaja);