Giter Club home page Giter Club logo

node-iamporter's Introduction

Iamporter.js
Iamporter

A REST API client for I'mport


Iamporter아임포트에서 제공하는 REST API를 쉽게 활용하기 위하여 작성된 Node.js 클라이언트 입니다.

  • 아임포트는 국내 PG사와의간편한 연동을 제공하는 서비스입니다.
  • 이용 중 발생한 문제에 대하여 책임지지 않습니다.
  • 최초 작성은 자동차 렌트 플랫폼 CARPLAT에서 사용하기 위하여 작성되었습니다.

Features

  • Written in ES6 Syntax
  • Promise Support
  • Exception Handling with a custom error class IamporterError

Installation

$ npm install iamporter

Specification

  • 모든 API 요청은 Promise를 반환합니다.

Fulfilled

  • API 요청이 성공적으로 수행된 경우 다음과 같은 형식의 데이터를 반환합니다.
{
  "status": 200, // HTTP STATUS CODE
  "message": "", // 아임포트 API 응답 메시지 혹은 Iamporter 정의 메시지
  "data": {}, // 아임포트 API 응답 데이터
  "raw": {} // 아임포트 API RAW DATA
}

Rejected

  • API 요청을 성공적으로 수행하지 못한 경우 항상 IamporterError 에러를 반환합니다.
iamporter.paySubscription(...)
  .catch((err) => {
    console.log(err.status); // HTTP STATUS CODE
    console.log(err.message); // 아임포트 API 응답 메시지 혹은 Iamporter 정의 메시지
    console.log(err.data); // 아임포트 API 응답 데이터
    console.log(err.raw); // 아임포트 API RAW DATA
  });

Usage

Import & Create an Instance

  • iamporter 패키지는 IamporterIamporterError 두 클래스를 제공합니다.
const { Iamporter, IamporterError } = require('iamporter');

// For Testing (테스트용 API KEY와 SECRET 기본 설정)
const iamporter = new Iamporter();

// For Production
const iamporter = new Iamporter({
  apiKey: 'YOUR_API_KEY',
  secret: 'YOUR_SECRET'
});

API Token

  • iamporter는 API 요청 전에 API 토큰의 유효성을 확인 후 자동 발급/갱신하므로 직접 토큰 API를 호출할 필요가 없습니다.
// 인스턴스 생성 시 설정한 API KEY와 SECRET
iamporter.getToken()
  .then(...)

// 토큰 생성 시 사용될 API KEY와 SECRET 직접 지정
iamporter.getToken('API_KEY', 'SECRET')
  .then(...)

Subscription

  • 정기 구독(Subscription)형 서비스 등에 이용할 수 있는 빌링키를 관리합니다.
// 빌링키 생성
iamporter.createSubscription({
  'customer_uid': 'test_uid',
  'card_number': '1234-1234-1234-1234',
  'expiry': '2021-11',
  'birth': '620201',
  'pwd_2digit': '99'
}).then(result => {
  console.log(result);
}).catch(err => {
  if (err instanceof IamporterError)
    // Handle the exception
});

// 빌링키 조회
iamporter.getSubscription('test_uid')
  .then(...)

// 빌링키 삭제
iamporter.deleteSubscription('test_uid')
  .then(...)

// 비인증 결제 (빌링키 이용)
iamporter.paySubscription({
  'customer_uid': 'test_uid',
  'merchant_uid': 'test_billing_key',
  'amount': 50000
}).then(result => {
    console.log(result);
}).catch(err => {
  if (err instanceof IamporterError)
    // Handle the exception
});

Onetime Payment

  • 빌링키를 생성하지 않아도 신용카드 정보만으로 간편 결제를 할 수 있습니다.
// Onetime 비인증 결제
iamporter.payOnetime({
  'merchant_uid': 'merchant_1448280088556',
  'amount': 5000,
  'card_number': '1234-1234-1234-1234',
  'expiry': '2021-12',
  'birth': '590912',
  'pwd_2digit': '11'
}).then(result => {
    console.log(result);
}).catch(err => {
  if (err instanceof IamporterError)
    // Handle the exception
});

// 해외카드 비인증 결제
iamporter.payForeign({
  'merchant_uid': 'merchant_1448280088556',
  'amount': 5000,
  'card_number': '1234-1234-1234-1234',
  'expiry': '2021-12',
}).then(result => {
    console.log(result);
}).catch(err => {
  if (err instanceof IamporterError)
    // Handle the exception
});

Cancel the Payment

  • 아임포트 고유 아이디 혹은 상점 고유 아이디로 결제 취소가 가능합니다.
  • 부분 결제 취소 또한 지원됩니다.
// 아임포트 고유 아이디로 결제 취소
iamporter.cancelByImpUid('imp_448280090638')
  .then(...)

// 상점 고유 아이디로 결제 취소
iamporter.cancelByMerchantUid('merchant_1448280088556')
  .then(...)

// 상점 고유 아이디로 부분 결제 취소
iamporter.cancelByMerchantUid('merchant_1448280088556', {
  'amount': 2500,
  'reason': '예약 변경'
}).then(...)

// 결제 취소 후 계좌 환불
iamporter.cancel({
  'imp_uid': 'imp_448280090638',
  'reason': '제품 상태 불량',
  'refund_holder': '홍길동',
  'refund_bank': '03',
  'refund_account': '056-076923-01-017'
).then(...)

Find the Payments

  • 아임포트에서는 아임포트 고유 아이디(ImpUid)와 상점 고유 아이디(MerchantUid)로 결제정보 조회가 가능합니다.
// 아임포트 고유 아이디로 결제정보 조회
iamporter.findByImpUid('imp_448280090638')
  .then(...)

// 상점 고유 아이디로 결제정보 조회
iamporter.findByMerchantUid('merchant_1448280088556')
  .then(...)

// 상점 고유 아이디로 결제정보 목록 조회
iamporter.findAllByMerchantUid('merchant_1448280088556')
  .then(...)

// 결제 상태로 결제정보 목록 조회(status: ['all', 'ready', 'paid', 'cancelled', 'failed'])
iamporter.findAllByStatus('paid')
  .then(...)

Prepared Payment

  • 아임포트에서는 결제 건에 대한 사전 정보 등록 및 검증을 할 수 있습니다.
// 결제 예정금액 사전 등록
iamporter.createPreparedPayment({
  'merchant_uid': 'merchant_1448280088556',
  'amount', '128900'
}).then(...)

// 결제 예정금액 조회
iamporter.getPreparedPayment('merchant_1448280088556')
  .then(...)

Certifications

  • 아임포트에서는 SMS 본인인증 결과를 조회/삭제할 수 있습니다.
// 아임포트 고유 아이디로 SMS 본인인증 결과 조회
iamporter.getCertification('imp_448280090638')
  .then(...)

// 아임포트 고유 아이디로 SMS 본인인증 결과 삭제
iamporter.deleteCertification('imp_448280090638')
  .then(...)

VBanks

  • 아임포트에서는 PG 결제화면 없이 API 만으로 가상계좌 발급이 가능합니다.
// 가상계좌 발급
iamporter.createVbank({
  'merchant_uid': 'merchant_1448280088556',
  'amount': '128900',
  'vbank_code': '03',
  'vbank_due': 1485697047,
  'vbank_holder': 'PLAT Corp'
}).then(...)

Links

Contact

If you have any questions, feel free to join me at #posquit0 on Freenode and ask away. Click here to connect.

License

node-iamporter's People

Contributors

greenkeeper[bot] avatar posquit0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-iamporter's Issues

Unable to find a matching configuration of project :iamport-react-native

  • What went wrong:
    Could not determine the dependencies of task ':app:preDebugBuild'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not resolve project :iamport-react-native.
Required by:
project :app
> Unable to find a matching configuration of project :iamport-react-native:
- None of the consumable configurations have attributes.

An in-range update of debug is breaking the build 🚨

Version 3.2.0 of debug was just published.

Branch Build failing 🚨
Dependency debug
Current Version 3.1.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

debug is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ci/circleci: Your tests failed on CircleCI (Details).

Release Notes 3.2.0

A long-awaited release to debug is available now: 3.2.0.

Due to the delay in release and the number of changes made (including bumping dependencies in order to mitigate vulnerabilities), it is highly recommended maintainers update to the latest package version and test thoroughly.


Minor Changes

Patches

Credits

Huge thanks to @DanielRuf, @EirikBirkeland, @KyleStay, @Qix-, @abenhamdine, @alexey-pelykh, @DiegoRBaquero, @febbraro, @kwolfy, and @TooTallNate for their help!

Commits

The new version differs by 25 commits.

There are 25 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

Version 4.18.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.17.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci Your tests failed on CircleCI Details
  • coverage/coveralls First build on greenkeeper/eslint-4.18.0 at 84.672% Details

Commits

The new version differs by 14 commits.

  • 883a2a2 4.18.0
  • 89d55ca Build: changelog update for 4.18.0
  • 70f22f3 Chore: Apply memoization to config creation within glob utils (#9944)
  • 0e4ae22 Update: fix indent bug with binary operators/ignoredNodes (fixes #9882) (#9951)
  • 47ac478 Update: add named imports and exports for object-curly-newline (#9876)
  • e8efdd0 Fix: support Rest/Spread Properties (fixes #9885) (#9943)
  • f012b8c Fix: support Async iteration (fixes #9891) (#9957)
  • 74fa253 Docs: Clarify no-mixed-operators options (fixes #9962) (#9964)
  • 426868f Docs: clean up key-spacing docs (fixes #9900) (#9963)
  • 4a6f22e Update: support eslint-disable-* block comments (fixes #8781) (#9745)
  • 777283b Docs: Propose fix typo for function (#9965)
  • bf3d494 Docs: Fix typo in max-len ignorePattern example. (#9956)
  • d64fbb4 Docs: fix typo in prefer-destructuring.md example (#9930)
  • f8d343f Chore: Fix default issue template (#9946)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of coveralls is breaking the build 🚨

The devDependency coveralls was updated from 3.0.2 to 3.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ci/circleci: Your tests failed on CircleCI (Details).

Release Notes for Dependency security updates

As suggested by NPM and Snyk.

Commits

The new version differs by 1 commits.

  • aa2519c dependency security audit fixes from npm & snyk (#210)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.