generated from samchon/backend
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- typia 5.2.2 - nestia 2.2.2
- Loading branch information
Showing
11 changed files
with
132 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,38 @@ | ||
# Iamport Server API | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/payments/LICENSE) | ||
[![npm version](https://badge.fury.io/js/iamport-server-api.svg)](https://www.npmjs.com/package/iamport-server-api) | ||
[![Downloads](https://img.shields.io/npm/dm/iamport-server-api.svg)](https://www.npmjs.com/package/iamport-server-api) | ||
[![Build Status](https://github.com/samchon/payments/workflows/build/badge.svg)](https://github.com/samchon/payments/actions?query=workflow%3Abuild) | ||
# SDK Library | ||
This is a SDK library generated by [`nestia`](https://nestia.io). | ||
|
||
```bash | ||
npm install --save iamport-server-api | ||
``` | ||
With this SDK library, you can easily and safely interact with backend server. | ||
|
||
`iamport-server-api` 는 [`fake-iamport-server`](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) 를 기반으로 만들어진 SDK (Software Development Kit) 이다. 그리고 [`fake-iamport-server`](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) 는 아임포트의 API 명세사항을 따라 만든 목업 서버이기에, 본 `iamport-server-api` 는 진짜 아임포트 서버와의 연동에도 사용할 수 있다. | ||
Just import and call some API functions like gif image below: | ||
|
||
고로 아임포트와 연동하는 TypeScript 기반 백엔드 서버를 개발함에 있어, 가짜 아임포트 서버 [`fake-iamport-server`](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server) 는 직접 이용치 않더라도, 실제 아임포트 서버와의 연동을 위하여, 본 SDK 라이브러리만큼은 반드시 설치하기를 권장하는 바이다. | ||
![nestia-sdk-demo](https://user-images.githubusercontent.com/13158709/215004990-368c589d-7101-404e-b81b-fbc936382f05.gif) | ||
|
||
- **Swagger Editor**: [packages/iamport-server-api/swagger.json](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Fpayments%2Fmaster%2Fpackages%2Fiamport-server-api%2Fswagger.json) | ||
- 자료 구조: [src/api/structures/IIamportPayment.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/structures/IIamportPayment.ts) | ||
- API 함수: [src/api/functional/payments/index.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/src/api/functional/payments/index.ts) | ||
- 예제 코드 | ||
- 본인 인증: [test_fake_certification.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_certification.ts) | ||
- 가상 계좌 결제: [test_fake_vbank_payment.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_vbank_payment.ts) | ||
- 카드 결제: [test_fake_card_payment.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_card_payment.ts) | ||
- 간편 결제 등록 | ||
- [test_fake_subscription_payment_again.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_subscription_payment_again.ts) | ||
- [test_fake_subscription_payment_onetime.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_subscription_payment_onetime.ts) | ||
- 전체 환불: [test_fake_card_payment_cancel.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_card_payment_cancel.ts) | ||
- 부분 환불: [test_fake_card_payment_cancel_partial.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_card_payment_cancel_partial.ts) | ||
- 현금 영수증 발행하기: [test_fake_receipt.ts](https://github.com/samchon/payments/tree/master/packages/fake-iamport-server/test/features/test_fake_receipt.ts) | ||
> Left is server code, and right is client code utilizing the SDK | ||
```typescript | ||
import { v4 } from "uuid"; | ||
|
||
import imp from "iamport-server-api"; | ||
import { IIamportCardPayment } from "iamport-server-api/lib/structures/IIamportCardPayment"; | ||
import { IIamportPayment } from "iamport-server-api/lib/structures/IIamportPayment"; | ||
import { IIamportResponse } from "iamport-server-api/lib/structures/IIamportResponse"; | ||
|
||
export async function test_fake_card_payment(): Promise<IIamportCardPayment> | ||
{ | ||
// 커넥터 정보 구성, 토큰 만료시 자동으로 갱신해 줌 | ||
const connector: imp.IamportConnector = new imp.IamportConnector | ||
( | ||
"http://127.0.0.1:10851", | ||
{ | ||
imp_key: "test_imp_key", | ||
imp_secret: "test_imp_secret" | ||
} | ||
); | ||
|
||
// 카드로 결제하기 | ||
const output: IIamportResponse<IIamportCardPayment> = | ||
await imp.functional.subscribe.payments.onetime | ||
( | ||
await connector.get(), | ||
{ | ||
card_number: "1111-2222-3333-4444", | ||
expiry: "2028-12", | ||
birth: "880311", | ||
# What [`Nestia`](https://nestia.io) is: | ||
![Nestia Logo](https://nestia.io/logo.png) | ||
|
||
merchant_uid: v4(), | ||
amount: 25_000, | ||
name: "Fake 주문" | ||
} | ||
); | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE) | ||
[![npm version](https://img.shields.io/npm/v/@nestia/core.svg)](https://www.npmjs.com/package/@nestia/core) | ||
[![Downloads](https://img.shields.io/npm/dm/nestia.svg)](https://www.npmjs.com/package/nestia) | ||
[![Build Status](https://github.com/samchon/nestia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild) | ||
[![Guide Documents](https://img.shields.io/badge/guide-documents-forestgreen)](https://nestia.io/docs/) | ||
|
||
// 결제 내역 조회하기 | ||
const reloaded: IIamportResponse<IIamportPayment> = | ||
await imp.functional.payments.at | ||
( | ||
await connector.get(), | ||
output.response.imp_uid, | ||
{}, | ||
); | ||
[Nestia](https://nestia.io) is a set of helper libraries for NestJS, supporting below features: | ||
|
||
// 결제 방식 및 완료 여부 확인 | ||
const payment: IIamportPayment = reloaded.response; | ||
if (payment.pay_method !== "card") | ||
throw new Error("Bug on payments.at(): its pay_method must be card."); | ||
else if (!payment.paid_at || payment.status !== "paid") | ||
throw new Error("Bug on payments.at(): its status must be paid."); | ||
- `@nestia/core`: super-fast decorators | ||
- `@nestia/sdk` | ||
- SDK generator for clients | ||
- Swagger generator evolved than ever | ||
- Automatic E2E test functions generator | ||
- `nestia`: just CLI (command line interface) tool | ||
|
||
// 첫 번째 if condition 에 의해 자동 다운 캐스팅 된 상태 | ||
payment.card_number; | ||
return payment; | ||
} | ||
``` | ||
> **Note** | ||
> | ||
> - **Only one line** required, with pure TypeScript type | ||
> - Runtime validator is **20,000x faster** than `class-validator` | ||
> - JSON serialization is **200x faster** than `class-transformer` | ||
> - SDK is similar with [tRPC](https://trpc.io), but much advanced |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
{ | ||
"name": "iamport-server-api", | ||
"version": "4.0.2", | ||
"description": "API for Iamport Server", | ||
"name": "@ORGANIZATION/PROJECT-api", | ||
"version": "0.0.0-dev.20991231", | ||
"description": "SDK library generated by Nestia", | ||
"main": "lib/index.js", | ||
"typings": "lib/index.d.ts", | ||
"scripts": { | ||
"build": "npm run build:sdk && npm run compile", | ||
"build:sdk": "rimraf ../fake-iamport-server/src/api/functional && cd ../fake-iamport-server && npx nestia sdk && cd ../iamport-server-api", | ||
"compile": "rimraf lib && tsc", | ||
"deploy": "npm run build && npm publish", | ||
"postinstall": "ts-patch install" | ||
"prepare": "ts-patch install" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/samchon/payments" | ||
"url": "https://github.com/samchon/nestia" | ||
}, | ||
"author": "Jeongho Nam", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/samchon/payments/issues" | ||
"url": "https://github.com/samchon/nestia/issues" | ||
}, | ||
"homepage": "https://github.com/samchon/payments", | ||
"homepage": "https://nestia.io", | ||
"files": [ | ||
"lib", | ||
"package.json", | ||
"swagger.json", | ||
"README.md" | ||
], | ||
"devDependencies": { | ||
"rimraf": "^5.0.1", | ||
"rimraf": "^5.0.5", | ||
"ts-node": "^10.9.1", | ||
"ts-patch": "^3.0.2", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"@nestia/fetcher": "^2.1.5", | ||
"typia": "^5.1.5" | ||
"@nestia/fetcher": "^2.2.2", | ||
"typia": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.