alpha_card 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 695a1b4fb47438c189a87716ef13134d85c35854
4
- data.tar.gz: 03c59165370cf209278b655d21ba57b72613cece
3
+ metadata.gz: 1ca151fb5ff57a0e885ee58031cc037b36bff410
4
+ data.tar.gz: a2c4814fd862a98e1cc26b0b0bdac870368e5e15
5
5
  SHA512:
6
- metadata.gz: 3d3f0ed869a45715977c53e7569493837832df23306cd15d3182f288b2b471595063dfbe6f1b41bdd2397ba9700668b77298c2c9f8f6d4e18037a27c0bd9921f
7
- data.tar.gz: 190c4f5d74a67085a3e4cf248a90ee5454b681065f505d95871af554356c004c8dc92d92f029190c7f7741a88751854194d7634804d8fcab8ff5e7e7680bcd65
6
+ metadata.gz: 5c36aeb545f3ee57bb5477d6bc09669edda527e5335da16e6c3a5ba09a631be81502694c0906d6270e860375ac1228dac145947f42544e54a2a50abb5517af85
7
+ data.tar.gz: 516c6219c3ca1ad01646f3052f0bcb7b8849f00e77f68a7aefd2931d69b99703a80fce250e2686c3fbbdd10275b069c807c4e36a3f34dceedee8edf9e95660de
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'virtus'
6
- gem 'curb'
6
+ gem 'rest_client'
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Ruby lib for creating payments with AlphaCard DirectPost API
2
2
  [![Gem Version](https://badge.fury.io/rb/alpha_card.png)](http://badge.fury.io/rb/alpha_card)
3
+ [![Dependency Status](https://gemnasium.com/budev/alpha_card.png)](https://gemnasium.com/budev/alpha_card)
3
4
 
4
5
  This gem can help your ruby/rails application to integrate with AlphaCard service.
5
6
 
6
- AlphaCard:
7
+ AlphaCard Services:
7
8
  http://www.alphacardservices.com/
8
9
 
9
10
  Payment Gateway Integration Portal:
@@ -33,7 +34,7 @@ gem install alpha_card
33
34
  Dependencies required:
34
35
 
35
36
  * ruby >= 1.9.3
36
- * curb (for Curl)
37
+ * rest_client
37
38
  * virtus (for nice OOP objects of AlphaCard)
38
39
 
39
40
  ## Objects
@@ -161,7 +162,7 @@ sale = AlphaCard::Sale.new({})
161
162
  sale.create(order, account)
162
163
  ```
163
164
 
164
- Method _create_ returns _true_ if sale was created successfully and raise an AlphaCardError
165
+ Method `create` returns _true_ if sale was created successfully and raise an `AlphaCardError`
165
166
  exception if some of the fields is invalid.
166
167
 
167
168
  ## Example of usage
@@ -169,6 +170,8 @@ exception if some of the fields is invalid.
169
170
  Create AlphaCard sale:
170
171
 
171
172
  ```ruby
173
+ require 'alpha_card'
174
+
172
175
  def create_payment
173
176
  account = AlphaCard::Account.new('demo', 'password')
174
177
 
@@ -187,13 +190,28 @@ rescue AlphaCard::AlphaCardError => e
187
190
  end
188
191
  ```
189
192
 
190
- Billing and shipping is an _optional_ parameters and can be not specified.
193
+ `Billing` and `shipping` is an _optional_ parameters and can be not specified.
191
194
 
192
- Format of parameters can be found on _Alpha Card Payment Gateway Integration Portal_ ->
193
- _Direct Post API_ -> _Documentation_ -> _Transaction Variables_
195
+ _Note_: take a look to the `amount` of the Order. It's format must be 'xx.xx'. All information about formats
196
+ can be found on _Alpha Card Payment Gateway Integration Portal_ -> _Direct Post API_ -> _Documentation_ -> _Transaction Variables_
194
197
 
195
198
  Naming convention of attributes (such as "ccexp" or "orderid") was saved due to compatibility with AlphaCard API.
196
199
 
200
+ To raise some exceptions do the next:
201
+
202
+ * to cause a declined message, pass an amount less than 1.00;
203
+ * to trigger a fatal error message, pass an invalid card number;
204
+ * to simulate an AVS match, pass 888 in the address1 field, 77777 for zip;
205
+ * to simulate a CVV match, pass 999 in the cvv field.
206
+
207
+ Example of exception:
208
+
209
+ ```ruby
210
+ ...
211
+ 2.1.1 :019 > sale.create(order, account)
212
+ AlphaCard::AlphaCardError: Invalid Credit Card Number REFID:127145481
213
+ ```
214
+
197
215
  ## Copyright
198
216
 
199
217
  Copyright (c) 2014 Nikita Bulaj (bulajnikita@gmail.com).
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'alpha_card'
3
- gem.version = '0.1.1'
3
+ gem.version = '0.1.3'
4
4
  gem.date = '2014-06-25'
5
- gem.summary = "Alpha Card DirectPost API for Ruby"
6
- gem.description = "Gem for creates sales with Alpha Card DirectPost API"
7
- gem.authors = ["Nikita Bulaj"]
5
+ gem.summary = 'Alpha Card Services DirectPost API for Ruby'
6
+ gem.description = 'Gem for creating sales with Alpha Card Services DirectPost API'
7
+ gem.authors = ['Nikita Bulaj']
8
8
  gem.email = 'bulajnikita@gmail.com'
9
9
  gem.require_paths = ["lib"]
10
10
  gem.files = `git ls-files`.split($/)
@@ -1,19 +1,18 @@
1
- require 'curb'
2
1
  require 'yaml'
3
2
  require 'virtus'
4
3
  require 'rack'
4
+ require 'rest_client'
5
5
 
6
6
  require 'alpha_card/object'
7
-
7
+ require 'alpha_card/alpha_card_object'
8
8
  require 'alpha_card/alpha_card_response'
9
9
  require 'alpha_card/alpha_card_error'
10
- require 'alpha_card/alpha_card_object'
11
10
 
12
11
  require 'alpha_card/account'
12
+ require 'alpha_card/shipping'
13
13
  require 'alpha_card/billing'
14
14
  require 'alpha_card/order'
15
15
  require 'alpha_card/sale'
16
- require 'alpha_card/shipping'
17
16
 
18
17
  module AlphaCard
19
18
  @api_base = 'https://secure.alphacardgateway.com/api/transact.php'
@@ -24,25 +23,17 @@ module AlphaCard
24
23
  attr_accessor :api_base
25
24
  end
26
25
 
27
- def self.request(params, account)
26
+ def self.request(params = {}, account)
28
27
  unless account.filled?
29
28
  raise AlphaCardError.new('You must set credentials to create the sale!')
30
29
  end
31
30
 
32
- auth_params = account.to_query
33
-
34
- curl = Curl::Easy.new(@api_base)
35
- curl.connect_timeout = 15
36
- curl.timeout = 15
37
- curl.header_in_body = false
38
- curl.ssl_verify_peer = false
39
- curl.post_body = [auth_params, params].join('&')
40
- curl.perform
31
+ response = RestClient.post(@api_base, params.merge(account.attributes))
41
32
 
42
- response = AlphaCardResponse.new(curl.body_str)
43
- handle_errors(response)
33
+ alpha_card_response = AlphaCardResponse.new(response.to_str)
34
+ handle_errors(alpha_card_response)
44
35
 
45
- response
36
+ alpha_card_response
46
37
  end
47
38
 
48
39
  private
@@ -4,6 +4,7 @@ module AlphaCard
4
4
  attribute :orderdescription, String
5
5
  attribute :ponumber, String
6
6
 
7
- attr_accessor :billing, :shipping
7
+ attribute :billing, AlphaCard::Billing
8
+ attribute :shipping, AlphaCard::Shipping
8
9
  end
9
10
  end
@@ -12,12 +12,8 @@ module AlphaCard
12
12
  raise Exception.new("No #{attr.to_s} information provided") if self.send(attr.to_s).blank?
13
13
  end
14
14
 
15
- sale_query = self.to_query
16
- order_query = order.to_query
17
- billing_query = order.billing.try(:to_query)
18
- shipping_query = order.shipping.try(:to_query)
19
-
20
- params = [order_query, billing_query, sale_query, shipping_query].reject(&:blank?).join('&')
15
+ params = self.filled_attributes || {}
16
+ [order, order.billing, order.shipping].compact.each { |obj| params.merge!(obj.try(:filled_attributes)) }
21
17
 
22
18
  AlphaCard.request(params, account).success?
23
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alpha_card
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulaj
@@ -10,7 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Gem for creates sales with Alpha Card DirectPost API
13
+ description: Gem for creating sales with Alpha Card Services DirectPost API
14
14
  email: bulajnikita@gmail.com
15
15
  executables: []
16
16
  extensions: []
@@ -54,5 +54,5 @@ rubyforge_project:
54
54
  rubygems_version: 2.2.2
55
55
  signing_key:
56
56
  specification_version: 4
57
- summary: Alpha Card DirectPost API for Ruby
57
+ summary: Alpha Card Services DirectPost API for Ruby
58
58
  test_files: []