-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.php
More file actions
147 lines (115 loc) · 3.87 KB
/
Copy pathExample.php
File metadata and controls
147 lines (115 loc) · 3.87 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/*
* Access Token 요청 예제입니다.
*/
// require_once '../vendor/autoload.php';
require_once 'vendor/autoload.php';
use Bootpay\ServerPhp\BootpayApi;
BootpayApi::setConfiguration(
'5b8f6a4d396fa665fdc2b5ea',
'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw='
);
// 1. (부트페이 통신을 위한) 토큰 발급
$token = BootpayApi::getAccessToken();
if (isset($token->error_code)) {
//토큰 발급 실패
var_dump($token);
return;
}
// 2. 결제 단건 조회
$response = BootpayApi::receiptPayment('61b009aaec81b4057e7f6ecd');
var_dump($response);
// 3. 결제 취소 (전액 취소 / 부분 취소)
$response = BootpayApi::cancelPayment(
array(
'receipt_id' => '62591cfcd01c7e001c19e259',
'cancel_price' => 1000,
'cancel_tax_free' => '0',
'cancel_id' => null,
'cancel_username' => 'test',
'cancel_message' => '테스트 결제 취소',
'refund' => array(
'bank_account' => '',
'bank_username' => '',
'bank_code' => ''
)
)
);
var_dump($response);
// 4-1. 빌링키 발급
$response = BootpayApi::requestSubscribeBillingKey(array(
'pg' => '나이스페이',
'order_name' => '테스트결제',
'subscription_id' => time(),
'card_no' => '5570********1074', //카드번호
'card_pw' => '**', //카드 비밀번호 2자리
'card_identity_no' => '******', //카드 소유주 생년월일 6자리
'card_expire_year' => '**', //카드 유효기간 년 2자리
'card_expire_month' => '**', //카드 유효기간 월 2자리
'user' => array(
'phone' => '01000000000',
'username' => '홍길동',
'email' => 'test@bootpay.co.kr'
),
'reserve_execute_at' => date("Y-m-d H:i:s \U\T\C", time() + 5)
));
var_dump($response);
// var_dump($response);
// 4-2. 발급된 빌링키로 결제 승인 요청
$response = BootpayApi::requestSubscribeCardPayment(array(
'billing_key' => '62b41f88cf9f6d001ad212ad',
'order_name' => '테스트결제',
'price' => 1000,
'order_id' => time()
));
var_dump($response);
// 4-3. 발급된 빌링키로 결제 예약 요청
$response = BootpayApi::subscribePaymentReserve(array(
'billing_key' => '62b41f88cf9f6d001ad212ad',
'order_name' => '테스트결제',
'price' => 1000,
'order_id' => time(),
'user' => array(
'phone' => '01000000000',
'username' => '홍길동',
'email' => 'test@bootpay.co.kr'
),
'reserve_execute_at' => date("Y-m-d H:i:s \U\T\C", time() + 5)
));
var_dump($response);
// 4-4. 발급된 빌링키로 결제 예약 - 취소 요청
$cancel = BootpayApi::cancelSubscribeReserve('62b41f88cf9f6d001ad212ad');
var_dump($cancel);
// 4-5. 빌링키 삭제
$response = BootpayApi::destroyBillingKey('62b41f88cf9f6d001ad212ad');
var_dump($response);
// 4-6. 빌링키 조회
$response = BootpayApi::lookupSubscribeBillingKey('62b41f68cf9f6d001ad212a5');
var_dump($response);
// 5. (생체인증, 비밀번호 결제를 위한) 구매자 토큰 발급
$response = BootpayApi::requestUserToken(array(
'user_id' => 'gosomi1',
'phone' => '01012345678'
));
var_dump($response);
// 6. 서버 승인 요청
$response = BootpayApi::confirmPayment('62b4200acf9f6d001ad212b1');
var_dump($response);
// 7. 본인 인증 결과 조회
$response = BootpayApi::certificate('625783a6cf9f6d001d0aed19');
var_dump($response);
// 8. (에스크로 이용시) PG사로 배송정보 보내기
$response = BootpayApi::shippingStart(
array(
'receipt_id' => "62b4200acf9f6d001ad212b1",
'tracking_number' => '3982983',
'delivery_corp' => 'CJ대한통운',
'user' => array(
'username' => '테스트',
'phone' => '01000000000',
'zipcode' => '099382',
'address' => '서울특별시 종로구'
)
)
);
var_dump($response);