부트페이 공식 PHP 라이브러리 입니다 (서버사이드 용)
PHP 언어로 작성된 어플리케이션, 프레임워크 등에서 사용가능합니다.
- PG 결제창 연동은 클라이언트 라이브러리에서 수행됩니다. (Javascript, Android, iOS, React Native, Flutter 등)
- 결제 검증 및 취소, 빌링키 발급, 본인인증 등의 수행은 서버사이드에서 진행됩니다. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET 등)
- 사용하기
composer require bootpay/server-php- PHP >= 5.3.0
- ext-json
<?php
require_once 'vendor/autoload.php';
use Bootpay\ServerPhp\BootpayApi;
BootpayApi::setConfiguration(
'5b8f6a4d396fa665fdc2b5ea', // application_id
'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw=' // private_key
);
$response = BootpayApi::getAccessToken();
var_dump($response);함수 단위의 샘플 코드는 tests/pg 폴더를 참조하세요.
부트페이와 서버간 통신을 하기 위해서는 부트페이 서버로부터 토큰을 발급받아야 합니다. 발급된 토큰은 30분간 유효하며, 최초 발급일로부터 30분이 지날 경우 토큰 발급 함수를 재호출 해주셔야 합니다.
<?php
require_once 'vendor/autoload.php';
use Bootpay\ServerPhp\BootpayApi;
BootpayApi::setConfiguration(
'5b8f6a4d396fa665fdc2b5ea',
'rm6EYECr6aroQVG2ntW0A6LpWnkTgP4uQ3H18sDDUYw='
);
$response = BootpayApi::getAccessToken();
var_dump($response);결제창 및 정기결제에서 승인/취소된 결제건에 대하여 올바른 결제건인지 서버간 통신으로 결제검증을 합니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::receiptPayment('receipt_id_here');
var_dump($response);
}price를 지정하지 않으면 전액취소 됩니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::cancelPayment(array(
'receipt_id' => 'receipt_id_here',
'cancel_price' => 1000, // 부분취소 금액 (없으면 전액취소)
'cancel_tax_free' => 0,
'cancel_username' => '관리자',
'cancel_message' => '테스트 결제 취소'
));
var_dump($response);
}REST API 방식으로 고객으로부터 카드 정보를 전달하여, PG사에게 빌링키를 발급받을 수 있습니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::getSubscribeBillingKey(
'nicepay', // PG사
'subscription_' . time(), // subscription_id
'30일 정기권 결제', // order_name
'5570********1074', // card_no
'12', // card_pw (앞 2자리)
'25', // card_expire_year
'12', // card_expire_month
'901012' // card_identity_no (생년월일 또는 사업자번호)
);
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::requestSubscribeAutomaticTransferBillingKey(array(
'pg' => 'nicepay',
'subscription_id' => 'subscription_' . time(),
'order_name' => '자동이체 등록',
'auth_type' => 'ARS',
'username' => '홍길동',
'bank_name' => '국민은행',
'bank_account' => '12345678901234',
'identity_no' => '901012'
));
var_dump($response);
}발급된 빌링키로 원하는 시점에 결제 승인 요청을 합니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::requestSubscribeCardPayment(array(
'billing_key' => 'billing_key_here',
'order_name' => '정기결제 테스트',
'price' => 1000,
'order_id' => 'order_' . time()
));
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::subscribePaymentReserve(array(
'billing_key' => 'billing_key_here',
'order_name' => '예약결제 테스트',
'price' => 1000,
'order_id' => 'order_' . time(),
'reserve_execute_at' => date('Y-m-d H:i:s', strtotime('+1 day'))
));
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::subscribePaymentReserveLookup('reserve_id_here');
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::cancelSubscribeReserve('reserve_id_here');
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::destroyBillingKey('billing_key_here');
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::lookupSubscribeBillingKey('receipt_id_here');
var_dump($response);
}부트페이에서 제공하는 간편결제창, 생체인증 기반의 결제 사용을 위해 사용자 토큰을 발급합니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::requestUserToken(array(
'user_id' => 'user_123',
'phone' => '01012345678'
));
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::confirmPayment('receipt_id_here');
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::certificate('receipt_id_here');
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::shippingStart(array(
'receipt_id' => 'receipt_id_here',
'tracking_number' => '1234567890',
'delivery_corp' => 'CJ대한통운',
'user' => array(
'username' => '홍길동',
'phone' => '01012345678'
)
));
var_dump($response);
}기존 결제건에 대해 현금영수증을 발행합니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::cashReceiptPublishOnReceipt(array(
'receipt_id' => 'receipt_id_here',
'identity_no' => '01012345678',
'cash_receipt_type' => '소득공제'
));
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::cashReceiptCancelOnReceipt('receipt_id_here');
var_dump($response);
}결제 건과 별개로 현금영수증을 발행합니다.
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::requestCashReceipt(array(
'pg' => 'nicepay',
'price' => 1000,
'order_name' => '테스트 상품',
'order_id' => 'order_' . time(),
'cash_receipt_type' => '소득공제',
'identity_no' => '01012345678'
));
var_dump($response);
}$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::cancelCashReceipt('receipt_id_here');
var_dump($response);
}<?php
require_once 'vendor/autoload.php';
use Bootpay\ServerPhp\BootpayCommerceApi;
$bootpay = new BootpayCommerceApi(
'your_client_key',
'your_secret_key',
'production' // 또는 'development'
);
try {
// 토큰 발급
$bootpay->getAccessToken();
// API 호출 예시
$response = $bootpay->user->getList(array('page' => 1, 'limit' => 10));
print_r($response);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}함수 단위의 샘플 코드는 tests/commerce 폴더를 참조하세요.
Commerce API 사용을 위한 토큰을 발급받습니다.
$bootpay = new BootpayCommerceApi(
'your_client_key',
'your_secret_key',
'production'
);
$bootpay->getAccessToken();$response = $bootpay->user->token('user_id_here');$response = $bootpay->user->join(array(
'login_id' => 'test_user',
'login_pw' => 'password123',
'username' => '홍길동',
'email' => 'test@example.com',
'phone' => '01012345678'
));$response = $bootpay->user->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->user->detail('user_id_here');$response = $bootpay->user->update(array(
'user_id' => 'user_id_here',
'username' => '변경된 이름'
));$response = $bootpay->user->delete('user_id_here');$response = $bootpay->userGroup->create(array(
'company_name' => '테스트 회사',
'business_number' => '1234567890',
'ceo_name' => '홍길동',
'corporate_type' => 2
));$response = $bootpay->userGroup->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->userGroup->detail('user_group_id_here');$response = $bootpay->userGroup->update(array(
'user_group_id' => 'user_group_id_here',
'company_name' => '변경된 회사명'
));$response = $bootpay->product->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->product->create(array(
'name' => '테스트 상품',
'price' => 10000,
'type' => 1
));$response = $bootpay->product->detail('product_id_here');$response = $bootpay->product->update(array(
'product_id' => 'product_id_here',
'name' => '변경된 상품명'
));$response = $bootpay->product->delete('product_id_here');$response = $bootpay->order->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->order->detail('order_id_here');$response = $bootpay->orderCancel->request(array(
'order_id' => 'order_id_here',
'cancel_reason' => '고객 요청'
));$response = $bootpay->invoice->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->invoice->create(array(
'user_id' => 'user_id_here',
'price' => 10000,
'order_name' => '청구서 테스트'
));$response = $bootpay->invoice->notify('invoice_id_here', array(
'send_types' => array(1) // 1: SMS
));$response = $bootpay->orderSubscription->getList(array(
'page' => 1,
'limit' => 10
));$response = $bootpay->orderSubscription->detail('order_subscription_id_here');$response = $bootpay->orderSubscription->requestIng->pause(array(
'order_subscription_id' => 'order_subscription_id_here'
));$response = $bootpay->orderSubscription->requestIng->resume(array(
'order_subscription_id' => 'order_subscription_id_here'
));$response = $bootpay->orderSubscription->requestIng->calculateTerminationFee(array(
'order_subscription_id' => 'order_subscription_id_here'
));$response = $bootpay->orderSubscription->requestIng->termination(array(
'order_subscription_id' => 'order_subscription_id_here'
));Commerce API에서는 역할(Role)에 따라 접근 권한이 달라집니다.
// 매니저 역할로 설정
$bootpay->asManager();
// 사용자 역할로 설정
$bootpay->asUser();
// 파트너 역할로 설정
$bootpay->asPartner();
// 역할 초기화
$bootpay->clearRole();적용한 샘플 프로젝트를 참조해주세요
부트페이 개발매뉴얼을 참조해주세요
부트페이 홈페이지 우측 하단 채팅을 통해 기술문의 주세요!