active_merchant_webpay 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Sebastián Gamboa"]
11
11
  s.email = [Base64.decode64("c2ViYUB3ZWxjdS5jb20=\n")]
12
- s.homepage = ""
12
+ s.homepage = "https://github.com/welcu/active_merchant_webpay"
13
13
  s.summary = %q{ActiveMerchant integration for Transbank's Webpay service}
14
14
  s.description = %q{ActiveMerchant integration for Transbank's Webpay service}
15
15
 
@@ -13,7 +13,7 @@ class BuyController < ApplicationController
13
13
  if true # check everything else (price order etc)
14
14
 
15
15
  else
16
- notify.cancel!
16
+ notify.fail!
17
17
  end
18
18
  end
19
19
 
@@ -5,8 +5,10 @@ module ActiveMerchant #:nodoc:
5
5
  module Integrations #:nodoc:
6
6
  module Webpay
7
7
  class Helper < ActiveMerchant::Billing::Integrations::Helper
8
- def initialize(*args)
8
+ def initialize(order, account, options={})
9
9
  super
10
+ # Webpay expects the amount in "cents"
11
+ self.amount = (options[:amount]*100).to_i
10
12
  add_field('TBK_TIPO_TRANSACCION', 'TR_NORMAL')
11
13
  end
12
14
 
@@ -16,8 +18,6 @@ module ActiveMerchant #:nodoc:
16
18
  mapping :order, 'TBK_ORDEN_COMPRA'
17
19
  mapping :return_url, 'TBK_URL_EXITO'
18
20
  mapping :cancel_return_url, 'TBK_URL_FRACASO'
19
-
20
-
21
21
  end
22
22
  end
23
23
  end
@@ -42,6 +42,11 @@ module ActiveMerchant #:nodoc:
42
42
  params['TBK_MONTO'][0..-3] + '.' + params['TBK_MONTO'][-2..-1]
43
43
  end
44
44
 
45
+ # The money in float format
46
+ def amount
47
+ params['TBK_MONTO'].to_f / 100
48
+ end
49
+
45
50
  # Was this a test transaction?
46
51
  def test?
47
52
  params[''] == 'test'
@@ -63,8 +68,20 @@ module ActiveMerchant #:nodoc:
63
68
  params['TBK_ORDEN_COMPRA']
64
69
  end
65
70
 
66
- def cancel!
67
- @valid = false
71
+ def fail!
72
+ @error = true
73
+ end
74
+
75
+ def success?
76
+ valid? && !@error
77
+ end
78
+
79
+ def authorization
80
+ params['TBK_CODIGO_AUTORIZACION']
81
+ end
82
+
83
+ def message
84
+ params['TBK_RESPUESTA']
68
85
  end
69
86
 
70
87
  # Check the transaction's validity. This method has to be called after a new
@@ -97,7 +114,7 @@ module ActiveMerchant #:nodoc:
97
114
  end
98
115
 
99
116
  def acknowledge
100
- valid? ? SUCCESS_RESPONSE : FAILURE_RESPONSE
117
+ success? ? SUCCESS_RESPONSE : FAILURE_RESPONSE
101
118
  end
102
119
 
103
120
  private
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  module Integrations #:nodoc:
4
4
  module Webpay
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Sebasti\xC3\xA1n Gamboa"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-25 00:00:00 -03:00
17
+ date: 2011-02-04 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,7 @@ files:
104
104
  - lib/active_merchant/billing/integrations/webpay/version.rb
105
105
  - lib/active_merchant_webpay.rb
106
106
  has_rdoc: true
107
- homepage: ""
107
+ homepage: https://github.com/welcu/active_merchant_webpay
108
108
  licenses: []
109
109
 
110
110
  post_install_message: