zipMoney 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ad78c78f322c8dade68c53ec46eccc251faaa24
4
+ data.tar.gz: 90152e28e1ac974c1ed611707f69a9da4792319c
5
+ SHA512:
6
+ metadata.gz: 27beafd615ca969f1f7b862788db2962732636f1c11380878955b73b72aea4a0a5166ed8663aa23668e7f8f0e2d4f7071950bcf2a84e46cfa018d7769d60dec4
7
+ data.tar.gz: dbd5620d958312b9e82759be6211b4501028a57df5b6ea09c3475780baca7d8ea9b93480561e9c3dce6601026f1cff3c0ebdda471288677f56a78b60f65f10fd
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ before_install: gem install bundler -v 1.10.6
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zipMoney.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sagar Bhandari
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,287 @@
1
+ # Ruby SDK for zipMoney
2
+
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'zipMoney'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install zipMoney
19
+
20
+ ## Usage
21
+ ### Configuration
22
+ ```ruby
23
+ require 'zipMoney'
24
+ # Configure the api credentials
25
+ ZipMoney::Configuration.merchant_id = merchant_id
26
+ ZipMoney::Configuration.merchant_key = "merchant_key here"
27
+ ZipMoney::Configuration.environment = 'sandbox|live'
28
+ ```
29
+
30
+ ### Api Operations
31
+ ##### Checkout
32
+ Order should be created before payment
33
+
34
+ ```ruby
35
+ # Initialize the checkout
36
+ checkout = ZipMoney::Checkout.new
37
+
38
+ checkout.params.charge = false
39
+ checkout.params.currency_code = "AUD"
40
+ checkout.params.txn_id = "12345"
41
+ checkout.params.return_url = "https://your-domain/zipmoney/standard/success/"
42
+ checkout.params.cancel_url = "https://your-domain/zipmoney/standard/cancel/"
43
+ checkout.params.notify_url = "https://your-domain/zipmoney/standard/success/"
44
+ checkout.params.error_url = "https://your-domain/zipmoney/standard/error/",
45
+ checkout.params.order_id = "91005500"
46
+
47
+ # Order Info
48
+ checkout.params.order.id = "91005500"
49
+ checkout.params.order.tax = 0
50
+ checkout.params.order.shipping_value = 0
51
+ checkout.params.order.total = 339.95
52
+
53
+ # Initialize the new Order Detail Object
54
+ checkout.params.order.detail[0] = Struct::Detail.new
55
+ checkout.params.order.detail[0].quantity = 1
56
+ checkout.params.order.detail[0].name = "GoPro Hero3+ Silver Edition - Silver"
57
+ checkout.params.order.detail[0].price = 339.95
58
+ checkout.params.order.detail[0].id = 10758
59
+
60
+ # Billing Address - Optional
61
+ checkout.params.billing_address.first_name = "firstname"
62
+ checkout.params.billing_address.last_name = "lastname"
63
+ checkout.params.billing_address.line1 = "address line 1"
64
+ checkout.params.billing_address.line2 = "address line 1"
65
+ checkout.params.billing_address.country = "Australia"
66
+ checkout.params.billing_address.zip = "postcode"
67
+ checkout.params.billing_address.city = "Sydney"
68
+ checkout.params.billing_address.state = "NSW"
69
+
70
+ # Shipping Address - Optional
71
+ checkout.params.shipping_address.first_name = "firstname"
72
+ checkout.params.shipping_address.last_name = "lastname"
73
+ checkout.params.shipping_address.line1 = "address line 1"
74
+ checkout.params.shipping_address.line2 = "address line 1"
75
+ checkout.params.shipping_address.country = "Australia"
76
+ checkout.params.shipping_address.zip = "postcode"
77
+ checkout.params.shipping_address.city = "Sydney"
78
+ checkout.params.shipping_address.state = "NSW"
79
+
80
+ # Consumer Details - Optional
81
+ checkout.params.consumer.first_name = "first_name"
82
+ checkout.params.consumer.last_name = "last_name"
83
+ checkout.params.consumer.phone = "1234567890"
84
+ checkout.params.consumer.gender = 1
85
+ checkout.params.consumer.email = "your-email@email.com"
86
+ checkout.params.consumer.dob = "0001-01-01T00:00:00"
87
+ checkout.params.consumer.title = "title"
88
+
89
+ # Perform the Checkout call
90
+ response = checkout.do()
91
+
92
+ if response.isSuccess
93
+ # do something
94
+ else
95
+ # do something
96
+ # response.getError
97
+ end
98
+ ```
99
+ ##### Quote
100
+ Order should be created after payment is complete, usually when the zipMoney api invokes the /confirmorder endpoint of the store or on the return journey
101
+ ```ruby
102
+ # Initialize the checkout
103
+ quote = ZipMoney::Quote.new
104
+
105
+ quote.params.currency_code = "AUD"
106
+ quote.params.txn_id = "12345"
107
+ quote.params.cart_url = "https://your-domain/checkout/cart/"
108
+ quote.params.success_url = "https://your-domain/zipmoney/express/success/"
109
+ quote.params.cancel_url = "https://your-domain/zipmoney/express/cancel/"
110
+ quote.params.error_url = "https://your-domain/zipmoney/express/error/"
111
+ quote.params.refer_url = "https://your-domain/zipmoney/express/refer/"
112
+ quote.params.decline_url = "https://your-domain/zipmoney/express/decline/"
113
+ quote.params.quote_id = "91005500"
114
+ quote.params.checkout_source = "cart"
115
+
116
+ # Order Info
117
+ quote.params.order.id = "91005500"
118
+ quote.params.order.tax = 0
119
+ quote.params.order.shipping_value = 0
120
+ quote.params.order.total = 339.95
121
+
122
+ # Initialize the new Order Detail Object
123
+ quote.params.order.detail[0] = Struct::Detail.new
124
+ quote.params.order.detail[0].quantity = 1
125
+ quote.params.order.detail[0].name = "GoPro Hero3+ Silver Edition - Silver"
126
+ quote.params.order.detail[0].price = 339.95
127
+ quote.params.order.detail[0].id = 10758
128
+
129
+ # Billing Address - Optional
130
+ quote.params.billing_address.first_name = "firstname"
131
+ quote.params.billing_address.last_name = "lastname"
132
+ quote.params.billing_address.line1 = "address line 1"
133
+ quote.params.billing_address.line2 = "address line 1"
134
+ quote.params.billing_address.country = "Australia"
135
+ quote.params.billing_address.zip = "postcode"
136
+ quote.params.billing_address.city = "Sydney"
137
+ quote.params.billing_address.state = "NSW"
138
+
139
+ # Shipping Address - Optional
140
+ quote.params.shipping_address.first_name = "firstname"
141
+ quote.params.shipping_address.last_name = "lastname"
142
+ quote.params.shipping_address.line1 = "address line 1"
143
+ quote.params.shipping_address.line2 = "address line 1"
144
+ quote.params.shipping_address.country = "Australia"
145
+ quote.params.shipping_address.zip = "postcode"
146
+ quote.params.shipping_address.city = "Sydney"
147
+ quote.params.shipping_address.state = "NSW"
148
+
149
+ # Consumer Details - Optional
150
+ quote.params.consumer.first_name = "first_name"
151
+ quote.params.consumer.last_name = "last_name"
152
+ quote.params.consumer.phone = "1234567890"
153
+ quote.params.consumer.gender = 1
154
+ quote.params.consumer.email = "your-email@email.com"
155
+ quote.params.consumer.dob = "0001-01-01T00:00:00"
156
+ quote.params.consumer.title = "title"
157
+
158
+ # Perform the Quote call
159
+ response = quote.do()
160
+
161
+ if response.isSuccess
162
+ # do something
163
+ else
164
+ # do something
165
+ # response.getError
166
+ end
167
+ ```
168
+
169
+ ##### Refund
170
+ Performs full or partial refund of the order
171
+ ```ruby
172
+ # Initialize the refund
173
+ refund = ZipMoney::Refund.new
174
+
175
+ refund.params.reason = "Refund Reason"
176
+ refund.params.txn_id = 12345
177
+ refund.params.order_id = 95001111
178
+
179
+ refund.params.order.id = 95001111
180
+ refund.params.order.tax = 0
181
+ refund.params.order.shipping_value = 0
182
+ refund.params.order.total = 339
183
+
184
+ refund.params.order.detail[0] = Struct::Detail.new
185
+ refund.params.order.detail[0].quantity = 1
186
+ refund.params.order.detail[0].name = "Item Name"
187
+ refund.params.order.detail[0].price = 339
188
+ refund.params.order.detail[0].id = 155
189
+
190
+ response = refund.do()
191
+
192
+ if response.isSuccess
193
+ # do something
194
+ else
195
+ # do something
196
+ # response.getError
197
+ end
198
+ ```
199
+
200
+
201
+ ##### Cancel
202
+ Performs cancellation of the order
203
+ ```ruby
204
+ # Initialize the cancel
205
+ cancel = ZipMoney::Cancel.new
206
+
207
+ cancel.params.txn_id = 12345
208
+ cancel.params.order_id = 95001111
209
+
210
+ cancel.params.order.id = 95001111
211
+ cancel.params.order.tax = 0
212
+ cancel.params.order.shipping_value = 0
213
+ cancel.params.order.total = 339
214
+
215
+ cancel.params.order.detail[0] = Struct::Detail.new
216
+ cancel.params.order.detail[0].quantity = 1
217
+ cancel.params.order.detail[0].name = "Item Name"
218
+ cancel.params.order.detail[0].price = 339
219
+ cancel.params.order.detail[0].id = 155
220
+
221
+ response = cancel.do()
222
+
223
+ if response.isSuccess
224
+ # do something
225
+ else
226
+ # do something
227
+ # response.getError
228
+ end
229
+ ```
230
+
231
+
232
+ ##### Query
233
+ Queries orders
234
+ ```ruby
235
+ # Initialize the query
236
+ query = ZipMoney::Query.new
237
+
238
+ query.params.orders[0] = Struct::QueryOrder.new
239
+ query.params.orders[0].id = 95000111
240
+
241
+ response = query.do()
242
+
243
+ if response.isSuccess
244
+ # do something
245
+ else
246
+ # do something
247
+ # response.getError
248
+ end
249
+ ```
250
+
251
+
252
+
253
+ ##### Capture
254
+ Captures the payment for the order
255
+ ```ruby
256
+ # Initialize the capture
257
+ capture = ZipMoney::Capture.new
258
+
259
+ capture.params.txn_id = 12345
260
+ capture.params.order_id = 95001111
261
+
262
+ capture.params.order.id = 95001111
263
+ capture.params.order.tax = 0
264
+ capture.params.order.shipping_value = 0
265
+ capture.params.order.total = 339
266
+
267
+ capture.params.order.detail[0] = Struct::Detail.new
268
+ capture.params.order.detail[0].quantity = 1
269
+ capture.params.order.detail[0].name = "Item Name"
270
+ capture.params.order.detail[0].price = 339
271
+ capture.params.order.detail[0].id = 155
272
+
273
+
274
+ response = capture.do()
275
+
276
+ if response.isSuccess
277
+ # do something
278
+ else
279
+ # do something
280
+ # response.getError
281
+ end
282
+ ```
283
+
284
+
285
+ ## License
286
+
287
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
9
+
10
+
11
+
12
+
13
+
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "zipMoney"
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,54 @@
1
+
2
+ require 'json'
3
+ require 'rest_client'
4
+
5
+ require_relative "zipMoney/configuration"
6
+ require_relative "zipMoney/errors"
7
+ require_relative "zipMoney/util"
8
+ require_relative "zipMoney/resources"
9
+ require_relative "zipMoney/request"
10
+ require_relative "zipMoney/response"
11
+ require_relative "zipMoney/api"
12
+ require_relative "zipMoney/webhook"
13
+ require_relative "zipMoney/express"
14
+ require_relative "zipMoney/api/checkout"
15
+ require_relative "zipMoney/api/quote"
16
+ require_relative "zipMoney/api/capture"
17
+ require_relative "zipMoney/api/refund"
18
+ require_relative "zipMoney/api/query"
19
+ require_relative "zipMoney/api/cancel"
20
+ require_relative "zipMoney/api/settings"
21
+ require_relative "zipMoney/api/configure"
22
+
23
+ module ZipMoney
24
+ extend self
25
+
26
+ attr_accessor :config, :_api, :_webhook, :_express
27
+
28
+ # Return the api instance
29
+ def api
30
+ @config = ZipMoney::Configuration
31
+ configure_api if @_api.nil?
32
+ @_api
33
+ end
34
+
35
+ # Configure the api
36
+ def configure_api
37
+ options = {:headers => {:content_type => :json}}
38
+ @_api = ZipMoney::Api.new(@config,options)
39
+ end
40
+
41
+ # Return the webhook class
42
+ def webhook
43
+ @config = ZipMoney::Configuration
44
+ @_webhook = ZipMoney::WebHook if @_webhook.nil?
45
+ @_webhook
46
+ end
47
+
48
+ # Return the express api class
49
+ def express
50
+ @config = ZipMoney::Configuration
51
+ @_express = ZipMoney::Express if @_express.nil?
52
+ @_express
53
+ end
54
+ end