@aodjo/gitfle-kakaopay
v1.0.2
Published
KakaoPay payment API client for Node.js
Downloads
259
Readme
Gitfle
자신의 평소 코딩 습관을 진단 받아 보세요
프로젝트 소개
이 프로젝트는 조코딩 x OpenAI x Primer AI 해커톤를 위해 제작되었습니다. 이 레포지토리의 모든 저작물에 대한 저작권은 Junsung Lee에 있습니다. (자세한 내용은 LICENSE를 확인하세요) 이 레포지토리는 Junsung Lee에 의해 관리됩니다. 이 레포지토리는 대회가 종료됨에 따라 26. 03. 08. 이후 Public Archive 처리 되었습니다. 이 프로젝트에 관해 문의가 있으신가요? [email protected]를 통해 문의주세요.
Gitfle 소개
- 본인의 Github으로 로그인을 하면, Gitfle 에서 본인의 레포지토리를 선택할 수 있어요.
- 선택한 레포지토리를 AI Agent가 각각 탐색하면서 평가를 해요.
- 각각의 Agent의 평가를 기반으로 최종 레포트와 학습 방향을 정리해 줘요.
레포지토리 소개
위 레포지토리는
카카오페이 결제 API 클라이언트에 관해 다룹니다. Gitfle 프로젝트의 레포지토리는 여러 레포지토리로 분리되어 있으며, 이 레포지토리는 그 중 하나에 속합니다. 자세한 내용은 아래 표를 확인하세요. (별(*)표는 현재 레포지토리를 의미합니다.)
| Part | URL | | ----- | ----- | | client | aodjo/gitfle-client | | server | aodjo/gitfle-server | | payco | aodjo/gitfle-payco | | naverpay | aodjo/gitfle-naverpay | | *kakaopay | aodjo/gitfle-kakaopay |
설치
npm install @aodjo/gitfle-kakaopay사용법
초기화
import { KakaoPay } from '@aodjo/gitfle-kakaopay';
const kakaopay = new KakaoPay({
secretKey: process.env.KAKAOPAY_SECRET_KEY,
cid: 'TC0ONETIME', // 테스트용 CID
});결제 준비
const ready = await kakaopay.ready({
partnerOrderId: 'order_123',
partnerUserId: 'user_456',
itemName: '코인 100개',
quantity: 1,
totalAmount: 8000,
taxFreeAmount: 0,
approvalUrl: 'http://example.com/payment/success',
cancelUrl: 'http://example.com/payment/cancel',
failUrl: 'http://example.com/payment/fail',
});
// PC: ready.nextRedirectPcUrl
// Mobile: ready.nextRedirectMobileUrl
// App: ready.nextRedirectAppUrl결제 승인
const approve = await kakaopay.approve({
tid: ready.tid,
partnerOrderId: 'order_123',
partnerUserId: 'user_456',
pgToken: 'pg_token_from_callback',
});
console.log(approve.paymentMethodType); // "MONEY" or "CARD"
console.log(approve.amount.total); // 8000에러 처리
import { KakaoPayApiError, KakaoPayNetworkError } from 'gitfle-kakaopay';
try {
await kakaopay.ready({ ... });
} catch (error) {
if (error instanceof KakaoPayApiError) {
console.log(error.errorCode); // -731
console.log(error.errorMessage); // "invalid cid!"
console.log(error.extras); // 원천사 에러 정보
} else if (error instanceof KakaoPayNetworkError) {
console.log(error.message);
}
}테스트 정보
- CID:
TC0ONETIME(테스트용) - Secret Key: 카카오페이 개발자센터에서 발급받은 dev 키
API 문서
라이선스
MIT 라이선스입니다. 자세한 내용은 LICENSE를 참고하세요.
