Bootpay 패키지는 ASP.NET 언어로 작성된 어플리케이션, 프레임워크 등에서 사용가능합니다. .net standart 2.0 이상부터 지원합니다.
- PG 결제창 연동은 클라이언트 라이브러리에서 수행됩니다. (Javascript, Android, iOS, React Native, Flutter 등)
- 결제 검증 및 취소, 빌링키 발급, 본인인증 등의 수행은 서버사이드에서 진행됩니다. (Java, PHP, Python, Ruby, Node.js, Go, ASP.NET 등)
- PG API 사용하기
- Commerce API 사용하기
- Example 프로젝트
- Documentation
- 기술문의
- License
- 솔루션 탐색기(Solution Explorer) 열기
- 만드신 솔루션 프로젝트 우클릭
- Manage Nuget Packages 클릭
- Bootpay 검색
- Bootpay 클릭 후 설치
BootpayExample.java
using System.Threading.Tasks;
using Bootpay;
using Microsoft.AspNetCore.Mvc;
String getToken() {
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
var res = await api.GetAccessToken();
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);
}함수 단위의 샘플 코드는 이곳을 참조하세요.
부트페이와 서버간 통신을 하기 위해서는 부트페이 서버로부터 토큰을 발급받아야 합니다.
발급된 토큰은 30분간 유효하며, 최초 발급일로부터 30분이 지날 경우 토큰 발급 함수를 재호출 해주셔야 합니다.
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
var res = await api.GetAccessToken();
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);결제창 및 정기결제에서 승인/취소된 결제건에 대하여 올바른 결제건인지 서버간 통신으로 결제검증을 합니다.
string receiptId = "62b12d7fd01c7e001ebc71de";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.GetReceipt(receiptId);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);price를 지정하지 않으면 전액취소 됩니다.
- 휴대폰 결제의 경우 이월될 경우 이통사 정책상 취소되지 않습니다
- 정산받으실 금액보다 취소금액이 클 경우 PG사 정책상 취소되지 않을 수 있습니다. 이때 PG사에 문의하시면 되겠습니다.
- 가상계좌의 경우 CMS 특약이 되어있지 않으면 취소되지 않습니다. 그러므로 결제 테스트시에는 가상계좌로 테스트 하지 않길 추천합니다.
부분취는 카드로 결제된 건만 가능하며, 일부 PG사만 지원합니다. 요청시 price에 금액을 지정하시면 되겠습니다.
- (지원가능 PG사: 이니시스, kcp, 다날, 페이레터, 나이스페이, 카카오페이, 페이코)
간혹 개발사에서 실수로 여러번 부분취소를 보내서 여러번 취소되는 경우가 있기때문에, 부트페이에서는 부분취소 중복 요청을 막기 위해 cancel_id 라는 필드를 추가했습니다. cancel_id를 지정하시면, 해당 건에 대해 중복 요청방지가 가능합니다.
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.receiptCancel(cancel);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);REST API 방식으로 고객으로부터 카드 정보를 전달하여, PG사에게 빌링키를 발급받을 수 있습니다. 발급받은 빌링키를 저장하고 있다가, 원하는 시점, 원하는 금액에 결제 승인 요청하여 좀 더 자유로운 결제시나리오에 적용이 가능합니다.
- 비인증 정기결제(REST API) 방식을 지원하는 PG사만 사용 가능합니다.
Subscribe subscribe = new Subscribe();
subscribe.itemName = "정기결제 테스트 아이템";
subscribe.orderId = "" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
subscribe.pg = "nicepay";
subscribe.cardNo = "5570**********1074"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.cardPw = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.expireYear = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.expireMonth = "**"; //실제 테스트시에는 *** 마스크처리가 아닌 숫자여야 함
subscribe.identifyNumber = ""; //주민등록번호 또는 사업자 등록번호 (- 없이 입력)
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.getBillingKey(subscribe);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);REST API 방식으로 고객의 계좌 정보를 전달하여, PG사에게 빌링키 발급을 요청합니다. 요청 후 빌링키가 바로 발급되진 않고, 출금동의 확인 절차까지 진행해야 빌링키가 발급됩니다. 먼저 빌링키를 요청합니다.
Subscribe subscribe = new Subscribe();
subscribe.orderName = "정기결제 테스트 아이템";
subscribe.subscriptionId = "" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
subscribe.pg = "nicepay";
subscribe.username = "홍길동";
subscribe.bankName = "국민";
subscribe.identityNo = "901014";
subscribe.phone = "01012341234";
subscribe.bankAccount = "67560123422472";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.GetBillingKeyTransfer(subscribe);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);이후 빌링키 발급 요청시 응답받은 receipt_id로, 출금 동의 확인을 요청합니다.
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.PublishBillingKeyTransfer("6655e139d79bea0da31c05e5");
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);출금 동의가 확인되면 응답값으로 빌링키가 발급됩니다.
발급된 빌링키로 원하는 시점에 원하는 금액으로 결제 승인 요청을 할 수 있습니다. 잔액이 부족하거나 도난 카드 등의 특별한 건이 아니면 PG사에서 결제를 바로 승인합니다.
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "615d00f0238684001f60241e";
payload.itemName = "아이템01";
payload.price = 1000;
payload.orderId = "" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.requestSubscribe(payload);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);원하는 시점에 4-1로 결제 승인 요청을 보내도 되지만, 빌링키 발급 이후에 바로 결제 예약 할 수 있습니다. (빌링키당 최대 10건)
SubscribePayload payload = new SubscribePayload();
payload.billingKey = "615d00f0238684001f60241e";
payload.itemName = "아이템01";
payload.price = 1000;
payload.orderId = "" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
payload.executeAt = (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() / 1000) + 10;
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.reserveSubscribe(payload);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);예약시 응답받은 reserveId로 예약된 건을 조회합니다.
string reserveId = "6490149ca575b40024f0b70d";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.ReserveSubscribeLookup(reserveId);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);예약시 응답받은 reserveId로 예약된 건을 취소합니다.
string reserveId = "615d08a67b5ba4002011cd41";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.reserveCancelSubscribe(reserveId);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);발급된 빌링키를 삭제합니다. 삭제하더라도 예약된 결제건은 취소되지 않습니다. 예약된 결제건 취소를 원하시면 예약 취소하기를 요청하셔야 합니다.
string billingKey = "62b12d7fd01c7e001ebc71de";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.DestroyBillingKey(billingKey);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);클라이언트에서 빌링키 발급시, 보안상 클라이언트 이벤트에 빌링키를 전달해주지 않습니다. 그러므로 이 API를 통해 조회해야 합니다. 다음은 빌링키 발급 요청했던 receiptId 로 빌링키를 조회합니다.
string receiptId = "62b12d7fd01c7e001ebc71de";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.LookupBillingKey(receiptId);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);아래는 billingKey로 조회합니다.
string billingKey = "66542dfb4d18d5fc7b43e1b6";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.LookupBillingKeyByKey(billingKey);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);ㅇㅇ페이 사용을 위해 가맹점 회원의 토큰을 발급합니다. 가맹점은 회원의 고유번호를 관리해야합니다. 이 토큰값을 기반으로 클라이언트에서 결제요청(payload.user_token) 하시면 되겠습니다.
UserToken userToken = new UserToken();
userToken.userId = "1234";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.getUserToken(userToken);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);결제승인 방식은 클라이언트 승인 방식과, 서버 승인 방식으로 총 2가지가 있습니다.
클라이언트 승인 방식은 javascript나 native 등에서 confirm 함수에서 진행하는 일반적인 방법입니다만, 경우에 따라 서버 승인 방식이 필요할 수 있습니다.
필요한 이유
- 100% 안정적인 결제 후 고객 안내를 위해 - 클라이언트에서 PG결제 진행 후 승인 완료될 때 onDone이 수행되지 않아 (인터넷 환경 등), 결제 이후 고객에게 안내하지 못할 수 있습니다
- 단일 트랜잭션의 개념이 필요할 경우 - 재고파악이 중요한 커머스를 운영할 경우 트랜잭션 개념이 필요할 수 있겠으며, 이를 위해서는 서버 승인을 사용해야 합니다.
string receiptId = "62b13138d01c7e001bbc71d9";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.Confirm(receiptId);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);다날 본인인증 후 결과값을 조회합니다. 다날 본인인증에서 통신사, 외국인여부, 전화번호 이 3가지 정보는 다날에 추가로 요청하셔야 받으실 수 있습니다.
string receiptId = "";
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.Certificate(receiptId);
string json = JsonConvert.SerializeObject(res,
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);- (에스크로 이용시) PG사로 배송정보 보내기 현금 거래에 한해 구매자의 안전거래를 보장하는 방법으로, 판매자와 구매자의 온라인 전자상거래가 원활하게 이루어질 수 있도록 중계해주는 매매보호서비스입니다. 국내법에 따라 전자상거래에서 반드시 적용이 되어 있어야합니다. PG에서도 에스크로 결제를 지원하며, 에스크로 결제 사용을 원하시면 PG사 가맹시에 에스크로결제를 미리 얘기하고나서 진행을 하시는 것이 수월합니다.
PG사로 배송정보( 이니시스, KCP만 지원 )를 보내서 에스크로 상태를 변경하는 API 입니다.
Shipping shipping = new Shipping();
shipping.receiptId = "628ae7ffd01c7e001e9b6066";
shipping.trackingNumber = "123456";
shipping.deliveryCorp = "CJ대한통운";
ShippingUser user = new ShippingUser();
user.username = "홍길동";
user.phone = "01000000000";
user.address = "서울특별시 종로구";
user.zipcode = "08490";
shipping.user = user;
BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
await api.GetAccessToken();
var res = await api.PutShippingStart(shipping);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);bootpay api를 통해 결제된 건에 대하여 현금영수증을 발행합니다.
CashReceipt cashReceipt = new CashReceipt();
cashReceipt.receiptId = "62e0f11f1fc192036b1b3c92";
cashReceipt.username = "테스트";
cashReceipt.email = "[email protected]";
cashReceipt.phone = "01000000000";
cashReceipt.identityNo = "01000000000";
cashReceipt.cashReceiptType = "소득공제";
//BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
BootpayApi api = new BootpayApi(Constants.dev_application_id, Constants.dev_private_key, BootpayObject.MODE_DEVELOPMENT);
await api.GetAccessToken();
var res = await api.RequestCashReceiptByBootpay(cashReceipt);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);9-1을 통해 발행한 현금영수증을 취소합니다.
Cancel cancel = new Cancel();
cancel.receiptId = "62e0f11f1fc192036b1b3c92";
cancel.cancelUsername = "관리자";
cancel.cancelMessage = "테스트 결제";
//cancel.price = 1000.0; //부분취소 요청시
//cancel.cancelId = "12342134"; //부분취소 요청시, 중복 부분취소 요청하는 실수를 방지하고자 할때 지정
//RefundData refund = new RefundData(); // 가상계좌 환불 요청시, 단 CMS 특약이 되어있어야만 환불요청이 가능하다.
//refund.account = "675601012341234"; //환불계좌
//refund.accountholder = "홍길동"; //환불계좌주
//refund.bankcode = BankCode.getCode("국민은행");//은행코드
//cancel.refund = refund;
//BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
BootpayApi api = new BootpayApi(Constants.dev_application_id, Constants.dev_private_key, BootpayObject.MODE_DEVELOPMENT);
var token = await api.GetAccessToken();
var res = await api.RequestCashReceiptCancelByBootpay(cancel);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);부트페이 결제와 상관없이 금액, 상품명, 현금영수증 발행정보 등을 보내 현금영수증을 발행하는 API 입니다
CashReceipt cashReceipt = new CashReceipt();
cashReceipt.pg = "토스";
cashReceipt.price = 1000;
cashReceipt.orderName = "테스트";
cashReceipt.cashReceiptType = "소득공제";
cashReceipt.identityNo = "01000000000";
cashReceipt.orderId = "" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
cashReceipt.purchasedAt = DateTime.Now.AddSeconds(100).ToString("yyyy-MM-dd'T'HH:mm:ss zzz");
//BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
BootpayApi api = new BootpayApi(Constants.dev_application_id, Constants.dev_private_key, BootpayObject.MODE_DEVELOPMENT);
await api.GetAccessToken();
var res = await api.RequestCashReceipt(cashReceipt);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);9-3을 통해 발행한 현금영수증을 취소합니다.
Cancel cancel = new Cancel();
cancel.receiptId = "62f5bbb91fc192036f9f4c05";
cancel.cancelUsername = "관리자";
cancel.cancelMessage = "테스트 결제";
//cancel.price = 1000.0; //부분취소 요청시
//cancel.cancelId = "12342134"; //부분취소 요청시, 중복 부분취소 요청하는 실수를 방지하고자 할때 지정
//RefundData refund = new RefundData(); // 가상계좌 환불 요청시, 단 CMS 특약이 되어있어야만 환불요청이 가능하다.
//refund.account = "675601012341234"; //환불계좌
//refund.accountholder = "홍길동"; //환불계좌주
//refund.bankcode = BankCode.getCode("국민은행");//은행코드
//cancel.refund = refund;
//BootpayApi api = new BootpayApi(Constants.application_id, Constants.private_key);
BootpayApi api = new BootpayApi(Constants.dev_application_id, Constants.dev_private_key, BootpayObject.MODE_DEVELOPMENT);
var token = await api.GetAccessToken();
var res = await api.RequestCashReceiptCancel(cancel);
string json = JsonConvert.SerializeObject(await res.Content.ReadAsStringAsync(),
Newtonsoft.Json.Formatting.None,
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
return Ok(json);부트페이 Commerce API를 사용하여 사용자, 상품, 주문, 정기구독 등을 관리할 수 있습니다.
using BootpayCommerce;
var commerce = new BootpayCommerceApi(
"hxS-Up--5RvT6oU6QJE0JA", // client_key
"r5zxvDcQJiAP2PBQ0aJjSHQtblNmYFt6uFoEMhti_mg=", // secret_key
"development" // mode: "production", "development", "stage"
);
// 토큰 발급
await commerce.GetAccessToken();// 사용자 목록 조회
var users = await commerce.UserList(new { page = 1, limit = 10 });
// 사용자 상세 조회
var user = await commerce.UserDetail("USER_ID");
// 회원가입
var newUser = await commerce.UserJoin(new {
login_id = "[email protected]",
login_pw = "password123",
name = "홍길동",
email = "[email protected]",
phone = "010-1234-5678"
});
// 사용자 정보 수정
var updatedUser = await commerce.UserUpdate(new {
user_id = "USER_ID",
name = "수정된 이름"
});// 상품 목록 조회
var products = await commerce.ProductList(new { page = 1, limit = 10 });
// 상품 생성
var product = await commerce.ProductCreate(new {
name = "테스트 상품",
price = 10000,
description = "상품 설명"
});
// 상품 상세 조회
var productDetail = await commerce.ProductDetail("PRODUCT_ID");
// 상품 수정
var updatedProduct = await commerce.ProductUpdate(new {
product_id = "PRODUCT_ID",
name = "수정된 상품명",
price = 15000
});// 주문 목록 조회
var orders = await commerce.OrderList(new { page = 1, limit = 10 });
// 주문 상세 조회
var order = await commerce.OrderDetail("ORDER_ID");
// 월별 주문 조회
var monthOrders = await commerce.OrderMonth("USER_GROUP_ID", "2024-12");// 정기구독 목록 조회
var subscriptions = await commerce.OrderSubscriptionList();
// 정기구독 상세 조회
var subscription = await commerce.OrderSubscriptionDetail("ORDER_SUBSCRIPTION_ID");
// 정기구독 일시정지
await commerce.OrderSubscriptionPause(new {
order_subscription_id = "ORDER_SUBSCRIPTION_ID",
pause_days = 30,
reason = "일시정지 사유"
});
// 정기구독 재개
await commerce.OrderSubscriptionResume(new {
order_subscription_id = "ORDER_SUBSCRIPTION_ID"
});
// 정기구독 해지
await commerce.OrderSubscriptionTermination(new {
order_subscription_id = "ORDER_SUBSCRIPTION_ID",
reason = "해지 사유"
});// 청구서 목록 조회
var invoices = await commerce.InvoiceList();
// 청구서 생성
var invoice = await commerce.InvoiceCreate(new {
user_id = "USER_ID",
amount = 50000,
title = "청구서 제목"
});
// 청구서 알림 전송
await commerce.InvoiceNotify("INVOICE_ID", new int[] { 1, 2 }); // 1: SMS, 2: Email더 자세한 Commerce API 사용 예제는 Sample/Commerce 디렉토리를 참고해주세요.
적용한 샘플 프로젝트을 참조해주세요
부트페이 개발매뉴얼을 참조해주세요
부트페이 홈페이지 우측 하단 채팅을 통해 기술문의 주세요!