PHP code example of bootpay / backend-php
1. Go to this page and download the library: Download bootpay/backend-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bootpay / backend-php example snippets
Bootpay\ServerPhp\BootpayApi;
BootpayApi::setClientKeyConfiguration(
getenv('BOOTPAY_PG_CLIENT_KEY_PROD'),
getenv('BOOTPAY_PG_SECRET_KEY_PROD')
);
// Legacy application_id/private_key 방식은 setConfiguration()으로 계속 지원됩니다.
$response = BootpayApi::getAccessToken();
var_dump($response);
Bootpay\ServerPhp\BootpayApi;
BootpayApi::setClientKeyConfiguration(
getenv('BOOTPAY_PG_CLIENT_KEY_PROD'),
getenv('BOOTPAY_PG_SECRET_KEY_PROD')
);
$response = BootpayApi::getAccessToken();
var_dump($response);
$token = BootpayApi::getAccessToken();
if (!$token->error_code) {
$response = BootpayApi::receiptPayment('receipt_id_here');
var_dump($response);
}
$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);
}
$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);
}
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();
}
$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' => '[email protected] ',
'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'
));
// 매니저 역할로 설정
$bootpay->asManager();
// 사용자 역할로 설정
$bootpay->asUser();
// 파트너 역할로 설정
$bootpay->asPartner();
// 역할 초기화
$bootpay->clearRole();
bash
composer