Project

iamport

0.03
No commit activity in last 3 years
No release in over 3 years
Ruby gem for Iamport
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
>= 0
~> 10.0
>= 0

Runtime

 Project Readme

Iamport

Ruby 사용자를 위한 아임포트 REST API 연동 모듈입니다.

Code Status

Build Status

세팅하는 방법

Iamport.configure do |config|
  config.api_key = "API_KEY"
  config.api_secret = "API_SECRET"
end

사용법

token API

Iamport.token

payment API

Iamport.payment("IMP_UID")

payments API

Iamport.payments
Iamport.payments(status: "paid")
Iamport.payments(status: "paid", page: 2)

payments.validation API

결제예정금액을 사전등록
Iamport.prepare(merchant_uid: "M00001", amount: 10000)
사전등록된 결제정보를 조회
Iamport.prepared(merchant_uid: "M00001")

cancel API

body의 값은 API 문서 - cancel에 있는 사용하는 것을 추가하여 진행하면 됩니다.​

body = {
  imp_uid: "IMP_UID",
  merchant_uid: "M00001",
  amount: ""
}
Iamport.cancel(body)

find API

가맹점지정 고유번호를 이용하여 결제정보를 찾는 API

Iamport.find("M00001")

subscribe_customer API

카드정보를 카드사에 요청하여 빌링키를 발급하는 API

빌링키 발급/변경 요청 예시
Iamport.create_subscribe_customer("your_customer_1234", {
  card_number: "1234-1234-1234-1234",
  expiry: "2019-07",
  birth: "801234",
  pwd_2digit: "00",
  customer_email: "user@your_customer.com",
  customer_name: "홍길동",
  customer_tel: "010-1234-5678"
})

필수 항목 : card_number, expiry, birth, pwd_2digit
법인카드의 경우 pwd_2digit 항목 생략가능

빌링키 발급/변경 성공시 Response
{"code"=>0,
 "message"=>nil,
 "response"=>
  {"card_name"=>"현대카드",
   "customer_addr"=>nil,
   "customer_email"=>"user@your_customer.com",
   "customer_name"=>"홍길동",
   "customer_postcode"=>nil,
   "customer_tel"=>"010-1234-5678",
   "customer_uid"=>"your_customer_1234",
   "inserted"=>1487921135,
   "updated"=>1487921513}}

inserted의 값과 updated의 값이 같은 경우 신규 발급, 다른 경우 변경을 의미함.

빌링키 발급/변경 실패시 Response
{"code"=>-1,
 "message"=>"카드정보 인증 및 빌키 발급에 실패하였습니다. [F112]유효하지않은 카드번호를 입력하셨습니다. (card_bin 없음)",
 "response"=>nil}

Installation

Add this line to your application's Gemfile:

gem 'httparty'
gem 'iamport'

And then execute:

$ bundle

Or install it yourself as:

$ gem install iamport

Usage

TODO: Write usage instructions here

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/iamport. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.