-
Notifications
You must be signed in to change notification settings - Fork 28
/
Payment.php
51 lines (40 loc) · 1.1 KB
/
Payment.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
<?php
require __DIR__ . "/../autoload.php";
use PayMaya\API\Payments;
use PayMaya\Model\Payment\Card;
use PayMaya\Model\Payment\Amount;
use PayMaya\Model\Payment\Buyer;
$key = '[KEY]';
$secret = '[SECRET]';
$card = new Card();
$card->number = '5123456789012346';
$card->cvc = '111';
$card->expM = '05';
$card->expY = '2017';
$payment = new Payments($key, $secret);
try {
$payment->createToken($card);
} catch(\Exception $e) {
die($e->getMessage());
}
$amount = new Amount();
$amount->total = 100;
//$amount->code = 'PHP'; // [ optional ] default value is PHP
$buyer = new Buyer();
$buyer->firstname = 'John';
$buyer->middlename = 'D.';
$buyer->lastname = 'Doe';
$buyer->phone = '639102626010';
$buyer->email = 'jdoe@example.com';
$buyer->address1 = '123 East Village';
//$buyer->address2 = '124 East Village'; // [ optional ]
$buyer->city = 'Makati City';
$buyer->state = 'Metro Manila';
$buyer->zip = '1216';
//$buyer->country = 'PH' // [ optional ] default value is PH
try {
$pay = $payment->pay($buyer, $amount);
print_r(json_decode($pay, true));
} catch(\Exception $e) {
die($e->getMessage());
}