veritrans 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,14 +8,29 @@
8
8
 
9
9
  desc <<DESC
10
10
  Description:
11
+ Copy veritrans.yml template need for veritrans weblinktype payment:
12
+ - config/veritrans.yml
13
+ DESC
14
+
15
+ def create_or_update_config_files
16
+ path = __FILE__.sub(__FILE__.split('/').pop,'templates/config/')
17
+ create_file("config/veritrans.yml",IO.read("#{path}veritrans.yml"))
18
+ end
19
+
20
+ end
21
+
22
+ class SampleGenerator < ::Rails::Generators::Base
23
+
24
+ desc <<DESC
25
+ Description:
11
26
  Copy templates need for veritrans weblinktype payment:
12
- 0. app/controllers/merchant_controller.rb + views
13
- 1. app/controllers/veritrans_controller.rb + views
14
- 2. config/veritrans.yml
15
- 3. config/routes.rb
27
+ - app/controllers/merchant_controller.rb + views
28
+ - app/controllers/veritrans_controller.rb + views
29
+ - config/veritrans.yml
30
+ - config/routes.rb
16
31
  DESC
17
32
  def create_controller_file
18
- acts = "app/controllers/"
33
+ acts = "app/controllers/vtlink/"
19
34
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
20
35
  create_file("#{acts}merchant_controller.rb", IO.read("#{path}merchant_controller.rb"))
21
36
  create_file("#{acts}veritrans_controller.rb",IO.read("#{path}veritrans_controller.rb"))
@@ -26,11 +41,11 @@ DESC
26
41
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
27
42
  create_file("#{acts}layout_auto_post.html.erb",IO.read("#{path}layout_auto_post.html.erb" ))
28
43
 
29
- acts = "app/views/merchant/"
44
+ acts = "app/views/vtlink/merchant/"
30
45
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
31
46
  create_file("#{acts}checkout.html.erb",IO.read("#{path}checkout.html.erb" ))
32
47
 
33
- acts = "app/views/veritrans/"
48
+ acts = "app/views/vtlink/veritrans/"
34
49
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
35
50
  create_file("#{acts}confirm.html.erb", IO.read("#{path}confirm.html.erb"))
36
51
  create_file("#{acts}cancel.html.erb", IO.read("#{path}cancel.html.erb" ))
@@ -45,12 +60,14 @@ DESC
45
60
  end
46
61
 
47
62
  def update_routes
48
- route("match 'checkout' => 'merchant#checkout', :via => :get # show checkout form")
49
- route("match 'confirm' => 'veritrans#confirm', :via => :post # pay-confirmation autosubmit to veritrans server")
50
- route("match 'cancel' => 'veritrans#cancel', :via => :post # canceling transaction redirect back to merchant-web")
51
- route("match 'pay' => 'veritrans#pay', :via => :post # server to server pay-notification to merchant-web")
52
- route("match 'finish' => 'veritrans#finish', :via => :post # successfull transaction redirect back to merchant-web")
53
- route("match 'error' => 'veritrans#error', :via => :post # error transaction redirect back to merchant-web")
63
+ route("end")
64
+ route(" match '/' => 'merchant#checkout', :via => :get # show checkout form")
65
+ route(" match 'confirm' => 'veritrans#confirm', :via => :post # pay-confirmation autosubmit to veritrans server")
66
+ route(" match 'cancel' => 'veritrans#cancel', :via => :post # canceling transaction redirect back to merchant-web")
67
+ route(" match 'pay' => 'veritrans#pay', :via => :post # server to server pay-notification to merchant-web")
68
+ route(" match 'finish' => 'veritrans#finish', :via => :post # successfull transaction redirect back to merchant-web")
69
+ route(" match 'error' => 'veritrans#error', :via => :post # error transaction redirect back to merchant-web")
70
+ route("namespace :vtlink do")
54
71
  end
55
72
 
56
73
  hook_for :test_framework
@@ -0,0 +1,7 @@
1
+ class Vtlink::MerchantController < ApplicationController
2
+
3
+ # show checkout-form
4
+ def checkout
5
+ end
6
+
7
+ end
@@ -1,4 +1,4 @@
1
- class VeritransController < ApplicationController
1
+ class Vtlink::VeritransController < ApplicationController
2
2
 
3
3
  # post action after user submit checkout-form
4
4
  # Ex POST:
@@ -6,14 +6,14 @@ class VeritransController < ApplicationController
6
6
  # "commodity"=>[
7
7
  # {
8
8
  # "COMMODITY_ID" => "Espirit",
9
- # "COMMODITY_UNIT" => "500000",
10
- # "COMMODITY_NUM" => "4",
9
+ # "COMMODITY_QTY" => "4",
10
+ # "COMMODITY_PRICE" => "500000",
11
11
  # "COMMODITY_NAME1" => "Espirit"
12
12
  # },
13
13
  # {
14
14
  # "COMMODITY_ID" => "Tablet",
15
- # "COMMODITY_UNIT" => "2500000",
16
- # "COMMODITY_NUM" => "2",
15
+ # "COMMODITY_QTY" => "2",
16
+ # "COMMODITY_PRICE" => "2500000",
17
17
  # "COMMODITY_NAME1" => "Tablet"
18
18
  # }]}
19
19
  # Return from get_keys:
@@ -27,19 +27,20 @@ class VeritransController < ApplicationController
27
27
  client.gross_amount = params["gross_amount"]
28
28
  client.commodity = params["commodity"]
29
29
 
30
- client.customer_specification_flag = "1" #'1':Different Address with shipping
31
- client.shipping_flag = "0" #'0':Not required shipping address
32
-
33
- client.first_name = "Sam"
34
- client.last_name = "Anthony"
35
- client.address1 = "Buaran I"
36
- client.address2 = "Pulogadung"
37
- client.city = "Jakarta"
38
- client.country_code = "IDN"
39
- client.postal_code = "16954"
40
- client.phone = "0123456789123"
41
- client.email = "sam.anthony@gmail.com" # pay-notification email
42
- # client.promo_id = "PROMO_MERCHANT_NAME" #if there is a join-promo w/ CC issuer
30
+ client.billing_address_different_with_shipping_address = "1" #'1':Different Address with shipping
31
+ client.required_shipping_address = "1" #'0':Not required shipping address
32
+
33
+ client.shipping_first_name = "Sam"
34
+ client.shipping_last_name = "Anthony"
35
+ client.shipping_address1 = "Buaran I"
36
+ client.shipping_address2 = "Pulogadung"
37
+ client.shipping_city = "Jakarta"
38
+ client.shipping_country_code = "IDN"
39
+ client.shipping_postal_code = "16954"
40
+ client.shipping_phone = "0123456789123"
41
+
42
+ client.email = "sam.anthony@gmail.com" # pay-notification email
43
+ # client.promo_id = "PROMO_MERCHANT_NAME" #if there is a join-promo w/ CC issuer
43
44
 
44
45
  client.get_keys
45
46
  @client = client
@@ -0,0 +1,43 @@
1
+ <%= form_tag('/vtlink/confirm', :id =>"cart_form") do -%>
2
+ <table border=1>
3
+ <tbody>
4
+ <tr>
5
+ <th>Product Info</th>
6
+ <th>Price</th>
7
+ <th align="center">Qty</th>
8
+ <th>Total Price</th>
9
+ </tr>
10
+ <tr>
11
+ <td>Red Esprint</td>
12
+ <td align="right">Rp 500,000</td>
13
+ <td align="center">4</td>
14
+ <td align="right">Rp 2,000,000</td>
15
+ </tr>
16
+ <tr>
17
+ <td>Android Tablet</td>
18
+ <td align="right">Rp 2,500,000</td>
19
+ <td align="center">2</td>
20
+ <td align="right">Rp 5,000,000</td>
21
+ </tr>
22
+ <tr class="subtotal">
23
+ <td colspan="2">
24
+ <input class="checkout" name="commit" type="submit" value="Checkout">
25
+ </td>
26
+ <td><strong>Subtotal:</strong></td>
27
+ <td align="right"><strong>Rp 7,000,000</strong></td>
28
+ </tr>
29
+ </tbody>
30
+ </table>
31
+
32
+ <input type="hidden" name="commodity[][COMMODITY_ID]" value="Espirit"/>
33
+ <input type="hidden" name="commodity[][COMMODITY_QTY]" value="1"/>
34
+ <input type="hidden" name="commodity[][COMMODITY_PRICE]" value="5000"/>
35
+ <input type="hidden" name="commodity[][COMMODITY_NAME1]" value="Espirit"/>
36
+
37
+ <input type="hidden" name="commodity[][COMMODITY_ID]" value="Tablet"/>
38
+ <input type="hidden" name="commodity[][COMMODITY_QTY]" value="2"/>
39
+ <input type="hidden" name="commodity[][COMMODITY_PRICE]" value="2500"/>
40
+ <input type="hidden" name="commodity[][COMMODITY_NAME1]" value="Tablet"/>
41
+
42
+ <input type="hidden" name="gross_amount" value="10000"/>
43
+ <% end %>
@@ -1,15 +1,13 @@
1
1
  development:
2
2
  merchant_id: "test_id"
3
3
  merchant_hash_key: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789012345678901"
4
- unfinish_payment_return_url: "http://localhost/cancel"
5
- finish_payment_return_url: "http://localhost/finish"
6
- error_payment_return_url: "http://localhost/error"
7
- # server_host: "http://192.168.10.250:80"
4
+ unfinish_payment_return_url: "http://path/to/cancel"
5
+ finish_payment_return_url: "http://path/to/finish"
6
+ error_payment_return_url: "http://path/to/error"
8
7
 
9
8
  production:
10
9
  merchant_id: "production_id"
11
10
  merchant_hash_key: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789012345678901"
12
- unfinish_payment_return_url: "http://mydomain/cancel"
13
- finish_payment_return_url: "http://mydomain/finish"
14
- error_payment_return_url: "http://mydomain/error"
15
- # server_host: "http://192.168.10.250:80"
11
+ unfinish_payment_return_url: "http://path/to/cancel"
12
+ finish_payment_return_url: "http://path/to/finish"
13
+ error_payment_return_url: "http://path/to/error"
@@ -41,10 +41,22 @@ module Veritrans
41
41
  def get_keys
42
42
  init_instance
43
43
 
44
+ if customer_specification_flag == "0" && shipping_flag == "0"
45
+ raise "required_shipping_address must be '1'"
46
+ end
47
+
44
48
  params = prepare_params(PostData::ServerParam,PostData::PostParam)
45
49
 
46
50
  if @commodity.class == Array
47
51
  commodity = @commodity.collect do |data|
52
+ if data.keys.index "COMMODITY_QTY"
53
+ data["COMMODITY_NUM"] = data["COMMODITY_QTY"]
54
+ data.delete "COMMODITY_QTY"
55
+ end
56
+ if data.keys.index "COMMODITY_PRICE"
57
+ data["COMMODITY_UNIT"] = data["COMMODITY_PRICE"]
58
+ data.delete "COMMODITY_PRICE"
59
+ end
48
60
  uri = Addressable::URI.new
49
61
  uri.query_values = data
50
62
  uri.query
@@ -117,6 +129,26 @@ module Veritrans
117
129
  return @token
118
130
  end
119
131
 
132
+ # :nodoc:
133
+ def billing_address_different_with_shipping_address
134
+ @customer_specification_flag
135
+ end
136
+
137
+ # :nodoc:
138
+ def billing_address_different_with_shipping_address=(flag)
139
+ @customer_specification_flag = customer_specification_flag
140
+ end
141
+
142
+ # :nodoc:
143
+ def required_shipping_address
144
+ @shipping_flag
145
+ end
146
+
147
+ # :nodoc:
148
+ def required_shipping_address=(flag)
149
+ @shipping_flag = flag
150
+ end
151
+
120
152
  private
121
153
 
122
154
  def merchanthash
@@ -55,7 +55,7 @@ module Veritrans
55
55
  :postal_code,
56
56
  :phone,
57
57
  :email,
58
- :customer_specification_flag
58
+ :customer_specification_flag # billing_address_different_with_shipping_address
59
59
  ]
60
60
 
61
61
  # +:shipping_flag,
@@ -69,7 +69,7 @@ module Veritrans
69
69
  # +:shipping_phone,
70
70
  # +:shipping_method,
71
71
  Shipping =[
72
- :shipping_flag,
72
+ :shipping_flag, # required_shipping_address
73
73
  :shipping_first_name,
74
74
  :shipping_last_name,
75
75
  :shipping_address1,
@@ -102,12 +102,17 @@ module Veritrans
102
102
  # +:commodity_name2+
103
103
  PurchaseParam =[
104
104
  :commodity_id,
105
- :commodity_unit,
106
- :commodity_num,
105
+ :commodity_unit, # commodity_qty
106
+ :commodity_num, # commodity_price
107
107
  :commodity_name1,
108
108
  :commodity_name2
109
109
  ]
110
110
 
111
+ # AliasesParam = {
112
+ # :commodity_unit => :commodity_qty,
113
+ # :commodity_num => :commodity_price
114
+ # }
115
+
111
116
  # +:order_id,+
112
117
  # +:session_id,+
113
118
  # +:merchanthash,+
@@ -19,12 +19,12 @@ module Veritrans
19
19
 
20
20
  # :nodoc:
21
21
  def minor
22
- 1
22
+ 2
23
23
  end
24
24
 
25
25
  # :nodoc:
26
26
  def patch
27
- 3
27
+ 0
28
28
  end
29
29
 
30
30
  # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veritrans
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -77,15 +77,15 @@ files:
77
77
  - lib/veritrans/post_data.rb
78
78
  - lib/veritrans/version.rb
79
79
  - lib/generators/install_generator.rb
80
- - lib/generators/templates/app/controllers/merchant_controller.rb
81
- - lib/generators/templates/app/controllers/veritrans_controller.rb
80
+ - lib/generators/templates/app/controllers/vtlink/merchant_controller.rb
81
+ - lib/generators/templates/app/controllers/vtlink/veritrans_controller.rb
82
82
  - lib/generators/templates/app/views/layouts/layout_auto_post.html.erb
83
- - lib/generators/templates/app/views/merchant/checkout.html.erb
84
- - lib/generators/templates/app/views/veritrans/confirm.html.erb
85
- - lib/generators/templates/app/views/veritrans/error.html.erb
86
- - lib/generators/templates/app/views/veritrans/finish.html.erb
87
- - lib/generators/templates/app/views/veritrans/pay.html.erb
88
- - lib/generators/templates/app/views/veritrans/cancel.html.erb
83
+ - lib/generators/templates/app/views/vtlink/merchant/checkout.html.erb
84
+ - lib/generators/templates/app/views/vtlink/veritrans/confirm.html.erb
85
+ - lib/generators/templates/app/views/vtlink/veritrans/error.html.erb
86
+ - lib/generators/templates/app/views/vtlink/veritrans/finish.html.erb
87
+ - lib/generators/templates/app/views/vtlink/veritrans/pay.html.erb
88
+ - lib/generators/templates/app/views/vtlink/veritrans/cancel.html.erb
89
89
  - lib/generators/templates/config/veritrans.yml
90
90
  homepage: http://veritrans.co.id
91
91
  licenses: []
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project: veritrans
110
- rubygems_version: 1.8.24
110
+ rubygems_version: 1.8.23
111
111
  signing_key:
112
112
  specification_version: 3
113
113
  summary: Veritrans Webclient wrapper
@@ -1,7 +0,0 @@
1
- class MerchantController < ApplicationController
2
-
3
- # show checkout-form
4
- def checkout
5
- end
6
-
7
- end
@@ -1,46 +0,0 @@
1
- <%= form_tag('/confirm', :id =>"cart_form") do -%>
2
- <table border=1>
3
- <tbody>
4
- <tr>
5
- <th>Product Image</th>
6
- <th>Product Info</th>
7
- <th>Price</th>
8
- <th align="center">Qty</th>
9
- <th>Total Price</th>
10
- </tr>
11
- <tr>
12
- <td><img src="/assets/esprit.png" title="Esprit"></td>
13
- <td>Red Esprint</td>
14
- <td align="right">Rp 500,000</td>
15
- <td align="center">4</td>
16
- <td align="right">Rp 2,000,000</td>
17
- </tr>
18
- <tr>
19
- <td><img src="/assets/tablet.jpg" title="Tablet"></td>
20
- <td>Android Tablet</td>
21
- <td align="right">Rp 2,500,000</td>
22
- <td align="center">2</td>
23
- <td align="right">Rp 5,000,000</td>
24
- </tr>
25
- <tr class="subtotal">
26
- <td colspan="3">
27
- <input class="checkout" name="commit" type="submit" value="Checkout">
28
- </td>
29
- <td><strong>Subtotal:</strong></td>
30
- <td align="right"><strong>Rp 7,000,000</strong></td>
31
- </tr>
32
- </tbody>
33
- </table>
34
-
35
- <input type="hidden" name="commodity[][COMMODITY_ID]" value="Espirit"/>
36
- <input type="hidden" name="commodity[][COMMODITY_UNIT]" value="500000"/>
37
- <input type="hidden" name="commodity[][COMMODITY_NUM]" value="4"/>
38
- <input type="hidden" name="commodity[][COMMODITY_NAME1]" value="Espirit"/>
39
-
40
- <input type="hidden" name="commodity[][COMMODITY_ID]" value="Tablet"/>
41
- <input type="hidden" name="commodity[][COMMODITY_UNIT]" value="2500000"/>
42
- <input type="hidden" name="commodity[][COMMODITY_NUM]" value="2"/>
43
- <input type="hidden" name="commodity[][COMMODITY_NAME1]" value="Tablet"/>
44
-
45
- <input type="hidden" name="gross_amount" value="7000000"/>
46
- <% end %>