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 ์ฌ์ฉํ๊ธฐ
- 1. ํ ํฐ ๋ฐ๊ธ
- 2. ๊ฒฐ์ ๋จ๊ฑด ์กฐํ
- 3. ๊ฒฐ์ ์ทจ์ (์ ์ก ์ทจ์ / ๋ถ๋ถ ์ทจ์)
- 4. ์๋/๋น๋ง/์ ๊ธฐ ๊ฒฐ์
- 5. ํ์ ํ ํฐ ๋ฐ๊ธ์์ฒญ
- 6. ์๋ฒ ์น์ธ ์์ฒญ
- 7. ๋ณธ์ธ ์ธ์ฆ ๊ฒฐ๊ณผ ์กฐํ
- 8. ์์คํฌ๋ก ์ด์ฉ์ PG์ฌ๋ก ๋ฐฐ์ก์ ๋ณด ๋ณด๋ด๊ธฐ
- 9-1. ํ๊ธ์์์ฆ ๋ฐํํ๊ธฐ
- 9-2. ํ๊ธ์์์ฆ ๋ฐํ ์ทจ์
- 9-3. ๋ณ๊ฑด ํ๊ธ์์์ฆ ๋ฐํ
- 9-4. ๋ณ๊ฑด ํ๊ธ์์์ฆ ๋ฐํ ์ทจ์
- 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 = "test@bootpay.co.kr";
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 = "test@example.com",
login_pw = "password123",
name = "ํ๊ธธ๋",
email = "test@example.com",
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 ๋๋ ํ ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
์ ์ฉํ ์ํ ํ๋ก์ ํธ์ ์ฐธ์กฐํด์ฃผ์ธ์
๋ถํธํ์ด ๊ฐ๋ฐ๋งค๋ด์ผ์ ์ฐธ์กฐํด์ฃผ์ธ์
๋ถํธํ์ด ํํ์ด์ง ์ฐ์ธก ํ๋จ ์ฑํ ์ ํตํด ๊ธฐ์ ๋ฌธ์ ์ฃผ์ธ์!