iamport 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 48851587820d368b22b195dbea63ae700e43b8ee
4
+ data.tar.gz: f2e4b51589d1af0ed6d4709f107d5a4260d2329a
5
+ SHA512:
6
+ metadata.gz: 9009da81c94325631a3846ff6c87fc991d1d3cf06fdcc1f2f5f4945324c2796ad79d2d8c6be124270bb1675851b82541ce2ce9823693ea6e970a9599098219f1
7
+ data.tar.gz: d91445bd068ca76b25d60d891f4537cdf2d7746b4a371516208cb1efcabf8fe3562955cb8f1d0f6dc319ab012fd7f79f9ed8c820f26dfa31c879f12498ca2522
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ # Ignore RubyMine setting files
11
+ .idea/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iamport.gemspec
4
+ gemspec
5
+
6
+ gem 'httparty'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 jangbora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,140 @@
1
+ # Iamport
2
+
3
+ Ruby 사용자를 위한 아임포트 REST API 연동 모듈입니다.
4
+
5
+ # 세팅하는 방법
6
+
7
+ ```ruby
8
+ Iamport.configure do |config|
9
+ config.api_key = "API_KEY"
10
+ config.api_secret = "API_SECRET"
11
+ end
12
+ ```
13
+
14
+ # 사용법
15
+ ## token API
16
+
17
+ ```ruby
18
+ Iamport.token
19
+ ```
20
+
21
+ ## payment API
22
+
23
+ ```ruby
24
+ Iamport.payment("IMP_UID")
25
+ ```
26
+
27
+ ## payments API
28
+
29
+ ```ruby
30
+ Iamport.payments
31
+ Iamport.payments(status: "paid")
32
+ Iamport.payments(status: "paid", page: 2)
33
+ ```
34
+
35
+ ## cancel API
36
+ body의 값은 [API 문서 - cancel](https://api.iamport.kr/#!/payments/cancelPayment)에 있는 사용하는 것을 추가하여 진행하면 됩니다.​
37
+
38
+ ```ruby
39
+ body = {
40
+ imp_uid: "IMP_UID",
41
+ merchant_uid: "M00001",
42
+ amount: ""
43
+ }
44
+ Iamport.cancel(body)
45
+ ```
46
+
47
+ ## find API
48
+ 가맹점지정 고유번호를 이용하여 결제정보를 찾는 API
49
+
50
+ ```ruby
51
+ Iamport.find("M00001")
52
+ ```
53
+
54
+ ## subscribe_customer API
55
+ 카드정보를 카드사에 요청하여 빌링키를 발급하는 API
56
+
57
+ ##### 빌링키 발급/변경 요청 예시
58
+
59
+ ```ruby
60
+ Iamport.create_subscribe_customer("your_customer_1234", {
61
+ card_number: "1234-1234-1234-1234",
62
+ expiry: "2019-07",
63
+ birth: "801234",
64
+ pwd_2digit: "00",
65
+ customer_email: "user@your_customer.com",
66
+ customer_name: "홍길동",
67
+ customer_tel: "010-1234-5678"
68
+ })
69
+ ```
70
+
71
+ &#8251; *필수 항목 : `card_number`, `expiry`, `birth`, `pwd_2digit`*<br />
72
+ &#8251; *법인카드의 경우 `pwd_2digit` 항목 생략가능*
73
+
74
+ ##### 빌링키 발급/변경 성공시 Response
75
+
76
+ ```ruby
77
+ {"code"=>0,
78
+ "message"=>nil,
79
+ "response"=>
80
+ {"card_name"=>"현대카드",
81
+ "customer_addr"=>nil,
82
+ "customer_email"=>"user@your_customer.com",
83
+ "customer_name"=>"홍길동",
84
+ "customer_postcode"=>nil,
85
+ "customer_tel"=>"010-1234-5678",
86
+ "customer_uid"=>"your_customer_1234",
87
+ "inserted"=>1487921135,
88
+ "updated"=>1487921513}}
89
+ ```
90
+
91
+ &#8251; *`inserted`의 값과 `updated`의 값이 같은 경우 신규 발급, 다른 경우 변경을 의미함.*
92
+
93
+ ##### 빌링키 발급/변경 실패시 Response
94
+
95
+ ```ruby
96
+ {"code"=>-1,
97
+ "message"=>"카드정보 인증 및 빌키 발급에 실패하였습니다. [F112]유효하지않은 카드번호를 입력하셨습니다. (card_bin 없음)",
98
+ "response"=>nil}
99
+ ```
100
+
101
+ ## Installation
102
+
103
+ Add this line to your application's Gemfile:
104
+
105
+ ```ruby
106
+ gem 'httparty'
107
+ gem 'iamport'
108
+ ```
109
+
110
+ And then execute:
111
+
112
+ ```shell
113
+ $ bundle
114
+ ```
115
+
116
+ Or install it yourself as:
117
+
118
+ ```shell
119
+ $ gem install iamport
120
+ ```
121
+
122
+ ## Usage
123
+
124
+ TODO: Write usage instructions here
125
+
126
+ ## Development
127
+
128
+ 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.
129
+
130
+ 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](https://rubygems.org).
131
+
132
+ ## Contributing
133
+
134
+ 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](contributor-covenant.org) code of conduct.
135
+
136
+
137
+ ## License
138
+
139
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
140
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "iamport"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iamport/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iamport"
8
+ spec.version = Iamport::VERSION
9
+ spec.authors = ["Sell it"]
10
+ spec.email = ["webdeveloper@withsellit.com"]
11
+
12
+ spec.summary = "Ruby gem for Iamport"
13
+ spec.description = "Ruby gem for Iamport"
14
+ spec.homepage = "https://github.com/iamport/iamport-rest-client-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_runtime_dependency "httparty"
27
+ end
@@ -0,0 +1,123 @@
1
+ require 'httparty'
2
+ require 'iamport/version'
3
+
4
+ module Iamport
5
+ IAMPORT_HOST = "https://api.iamport.kr"
6
+
7
+ class Config
8
+ attr_accessor :api_key
9
+ attr_accessor :api_secret
10
+ end
11
+
12
+ class << self
13
+ def configure
14
+ yield(config) if block_given?
15
+ end
16
+
17
+ def config
18
+ @config ||= Config.new
19
+ end
20
+
21
+ # Get Token
22
+ # https://api.iamport.kr/#!/authenticate/getToken
23
+ def token
24
+ url = "#{IAMPORT_HOST}/users/getToken"
25
+ body = {
26
+ imp_key: config.api_key,
27
+ imp_secret: config.api_secret
28
+ }
29
+
30
+ result = HTTParty.post url, body: body
31
+ result["response"]["access_token"]
32
+ end
33
+
34
+ # Get payment information using imp_uid
35
+ # https://api.iamport.kr/#!/payments/getPaymentByImpUid
36
+ def payment(imp_uid)
37
+ uri = "payments/#{imp_uid}"
38
+
39
+ _get(uri)
40
+ end
41
+
42
+ # Search payment information using status.
43
+ # default items per page: 20
44
+ # https://api.iamport.kr/#!/payments/getPaymentsByStatus
45
+ def payments(options = {})
46
+ status = options[:status] || "all"
47
+ page = options[:page] || 1
48
+
49
+ uri = "payments/status/#{status}?page=#{page}"
50
+
51
+ _get(uri)
52
+ end
53
+
54
+ # Find payment information using merchant uid
55
+ # https://api.iamport.kr/#!/payments/getPaymentByMerchantUid
56
+ def find(merchant_uid)
57
+ uri = "payments/find/#{merchant_uid}"
58
+
59
+ _get(uri)
60
+ end
61
+
62
+ # Canceled payments
63
+ # https://api.iamport.kr/#!/payments/cancelPayment
64
+ def cancel(body)
65
+ uri = "payments/cancel"
66
+
67
+ _post(uri, body)
68
+ end
69
+
70
+ # Get a billing key by customer_uid
71
+ # GET https://api.iamport.kr/#!/subscribe/customers/:customer_uid
72
+ def find_subscribe_customer(customer_uid)
73
+ uri = "subscribe/customers/#{customer_uid}"
74
+
75
+ _get(uri)
76
+ end
77
+
78
+ # Create (or update if exists) a billing key by customer_uid
79
+ # POST https://api.iamport.kr/#!/subscribe/customers/:customer_uid
80
+ def create_subscribe_customer(customer_uid, body)
81
+ uri = "subscribe/customers/#{customer_uid}"
82
+
83
+ _post(uri, body)
84
+ end
85
+
86
+ # Delete a billing key by customer_uid
87
+ # DELETE https://api.iamport.kr/#!/subscribe/customers/:customer_uid
88
+ def delete_subscribe_customer(customer_uid)
89
+ uri = "subscribe/customers/#{customer_uid}"
90
+
91
+ _delete(uri)
92
+ end
93
+
94
+ private
95
+
96
+ # Get header data
97
+ def get_headers
98
+ { "Authorization" => token }
99
+ end
100
+
101
+ # GET
102
+ def _get(uri, payload = {})
103
+ url = "#{IAMPORT_HOST}/#{uri}"
104
+
105
+ HTTParty.get url, headers: get_headers, body: payload
106
+ end
107
+
108
+ # POST
109
+ def _post(uri, payload = {})
110
+ url = "#{IAMPORT_HOST}/#{uri}"
111
+
112
+ HTTParty.post url, headers: get_headers, body: payload
113
+ end
114
+
115
+ # DELETE
116
+ def _delete(uri, payload = {})
117
+ url = "#{IAMPORT_HOST}/#{uri}"
118
+
119
+ HTTParty.delete url, headers: get_headers, body: payload
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,3 @@
1
+ module Iamport
2
+ VERSION = "0.2.2"
3
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iamport
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Sell it
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby gem for Iamport
70
+ email:
71
+ - webdeveloper@withsellit.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CODE_OF_CONDUCT.md
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - iamport.gemspec
85
+ - lib/iamport.rb
86
+ - lib/iamport/version.rb
87
+ homepage: https://github.com/iamport/iamport-rest-client-ruby
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.5
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Ruby gem for Iamport
111
+ test_files: []