flowcommerce-activemerchant 0.3.1 → 0.3.2

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
- SHA1:
3
- metadata.gz: b885901c7ae47d0208ce990fcf1390df32a69666
4
- data.tar.gz: 33e5b7d10d7b233ecef59b1d6bc80e43f205810d
2
+ SHA256:
3
+ metadata.gz: f8c050459bb5e3d462ec740f49de89e85bc1d6face8a91a4a62caa3f432e491e
4
+ data.tar.gz: 2fe18804b6874c53adb20b904ab7fcebd2d41215de0fb4eff4bee06c258eff06
5
5
  SHA512:
6
- metadata.gz: 46d3b8e598ef86a504405edb05d6b8242f495fcb86130ea6563fcc902f2d4415f5b1bc313a0fded8d9fc90cf2743c9376d1dee83136d8cfa293fb551700afa3a
7
- data.tar.gz: 41bc3698c7e97e29d78049e47994444e7ca3d673fd033afadc609fcdc75126e5b677c4308932f10c51ca151b64aa46bf389237e485e894884e86df3907b7f710
6
+ metadata.gz: f4cd06bb6ccebf634edccf1c83d277294749ced7e6d0543427bf08a9e6126fff1328b1f7d6110fd0cf1db602b8d0a35f4f7b364671a385ae9c3f14483c444d4d
7
+ data.tar.gz: 2005e3cfa3073ef522b8da892c16ce1d0095e7a8d451ecaa21f8b77a8a31012b9b31fe2519fcd5b31065ab8b539647583869ffe333b1b93f58829792f6498193
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -98,8 +98,15 @@ module ActiveMerchant
98
98
  end
99
99
 
100
100
  def purchase credit_card, order_number, options={}
101
- response = authorize credit_card, order_number, options
102
- capture options[:amount], response.authorization, options
101
+ auth_response = flow_get_authorization order_number: order_number
102
+
103
+ if auth_response
104
+ capture options[:amount], auth_response.key, options
105
+ else
106
+ error_response 'No authorization for order: %s' % order_number
107
+ end
108
+ rescue Io::Flow::V0::HttpClient::ServerError => exception
109
+ error_response exception
103
110
  end
104
111
 
105
112
  # https://docs.flow.io/module/payment/resource/reversals#post-organization-reversals
@@ -148,10 +155,16 @@ module ActiveMerchant
148
155
  credit_card =
149
156
  case input
150
157
  when Hash
158
+ # ActiveMerchant::Billing::CreditCard does not support "address" field
159
+ # so we have to capture it manualy
160
+ # format - https://docs.flow.io/type/billing-address
161
+ @address = credit_card.delete(:address)
162
+
151
163
  ActiveMerchant::Billing::CreditCard.new input
152
164
  when ActiveMerchant::Billing::CreditCard
153
165
  input
154
166
  when String
167
+ # if it is a String then it allready is a token
155
168
  return input
156
169
  else
157
170
  raise 'Unsuported store method input type [%s]' % input.class
@@ -162,13 +175,14 @@ module ActiveMerchant
162
175
  cvv: credit_card.verification_value,
163
176
  expiration_year: credit_card.year.to_i,
164
177
  expiration_month: credit_card.month.to_i
165
- address: credit_card.address
166
178
  }
167
179
 
180
+ data[:address] = @address if @address
181
+
168
182
  response = flow_instance.cards.post @flow_organization, data
169
183
 
170
184
  if response.respond_to?(:token)
171
- Response.new true, 'Flow refund - Success', { response: response }
185
+ response.token
172
186
  else
173
187
  Response.new false, 'Flow POST /:organization/cards - Failure', { response: response }
174
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowcommerce-activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.5.2.3
86
+ rubygems_version: 2.7.5
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Adapter for Flow.io global payment gateway