vtweb 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +117 -2
  3. data/lib/vtweb/version.rb +1 -1
  4. data/vtweb.gemspec +3 -3
  5. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c54682e7d1d6ad85e42f1c48b2c66e4fbdb34a49
4
- data.tar.gz: 98b15da1c8d4495effea493ec59021f649542d1e
3
+ metadata.gz: 52bb961fae18ed6751a94b5a4c0317f062ac26e4
4
+ data.tar.gz: 03b1c53165e2794626fb4d9025807f47a40bde49
5
5
  SHA512:
6
- metadata.gz: 2287cda64af0090f513e4f0cbfb38380a85a044211226cbaff1672ba7c2af952161e473287a9079e6b0222a2fed58f5ea38d574babc8260f635e3f056205b2c4
7
- data.tar.gz: c264c3064cf3540c98c0b4c01a90ff24d3cf94e08b3e334c92cf377f0617c76e690a51c469dc9eef5b8b0e6d77f53970928997b69bf4813538a8fe915c2eb966
6
+ metadata.gz: ae311ca550269d2f55e8eb984cf739e5da9947cdb821a4bcc5e7b564eba73648398170485b3a88c9396a54e4b1f261acc88965a37287f6bf8c9e28e963b08dbe
7
+ data.tar.gz: e4bbcece800ea22277f7fb4a477fa37f595258c7ccb291b8b3e4db1522dc81954c8af75f08a152a9b0db84eef800c826d0638efe01e6514c2681637fa15edde7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Veritrans VT-Web Ruby Wrapper
2
2
 
3
- Ruby Wrapper for Veritrans VT-Web. Visit https://www.veritrans.co.id for more information.
3
+ Ruby Wrapper for Veritrans VT-Web. Visit https://www.veritrans.co.id for more information about the product and see documentation at http://veritrans.github.io/vtweb/index.html for more technical details.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,122 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ In your Rails app, create 'vtweb.yml' at config directory (config/vtweb.yml) with this code:
22
+
23
+ development:
24
+ merchant_id: "T100000000000001XXXXXX"
25
+ merchant_hash_key: "yourmerchanthashkey"
26
+ unfinish_payment_return_url: "http://localhost:3000/cancel_pay"
27
+ finish_payment_return_url: "http://localhost:3000/finish"
28
+ error_payment_return_url: "http://localhost:3000/error"
29
+ vtweb_server: "http://127.0.0.1:4000"
30
+
31
+ production:
32
+ merchant_id: "A100000000000001XXXXXX"
33
+ merchant_hash_key: "yourmerchanthashkey"
34
+ unfinish_payment_return_url: "http://yourweb.com/"
35
+ finish_payment_return_url: "http://yourweb.com/thank_you"
36
+ error_payment_return_url: "http://yourweb.com/shop_again"
37
+
38
+ Create a file in 'config/initializers' to set config to vtweb.yml, for example 'store_config.rb':
39
+
40
+ raw_config = File.read("#{Rails.root}/config/vtweb.yml")
41
+ CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys
42
+
43
+
44
+ In your controller, create a method to use the gem. I took the code from https://github.com/veritrans/veritrans-rails-sample-cart for the example with some modification:
45
+
46
+ def confirm
47
+ client = ::Vtweb::Client.new
48
+ client.order_id = SecureRandom.hex(5)
49
+ client.merchant_hash_key = CONFIG[:merchant_hash_key]
50
+
51
+ # Example
52
+ @carts = Cart.all
53
+ @total = Cart.select(:sub_total).sum(:sub_total)
54
+
55
+ params["item"] = []
56
+
57
+ @carts.each do |item|
58
+ params["item"] << { "item_id" => item.product_id, "price" => item.product.price.to_s, "quantity" => item.quantity.to_s,
59
+ "item_name1" => item.product.name, "item_name2" => item.product.name }
60
+ end
61
+
62
+ # client.gross_amount = Cart.select(:sub_total).sum(:sub_total).to_s
63
+ client.item = params["item"]
64
+
65
+ client.billing_different_with_shipping = 1
66
+ client.required_shipping_address = 1
67
+
68
+ client.first_name = params[:shipping_first_name]
69
+ client.last_name = params[:shipping_last_name]
70
+ client.address1 = params[:shipping_address1]
71
+ client.address2 = params[:shipping_address2]
72
+ client.city = params[:shipping_city]
73
+ client.country_code = "IDN"
74
+ client.postal_code = params[:shipping_postal_code]
75
+ client.phone = params[:shipping_phone]
76
+
77
+ client.shipping_first_name = params[:shipping_first_name]
78
+ client.shipping_last_name = params[:shipping_last_name]
79
+ client.shipping_address1 = params[:shipping_address1]
80
+ client.shipping_address2 = params[:shipping_address2]
81
+ client.shipping_city = params[:shipping_city]
82
+ client.shipping_country_code = "IDN"
83
+ client.shipping_postal_code = params[:shipping_postal_code]
84
+ client.shipping_phone = params[:shipping_phone]
85
+
86
+ client.email = params[:email]
87
+
88
+ client.promo_bins = ["4"]
89
+ client.payment_type = '01'
90
+ client.enable_3d_secure = 1
91
+ client.installment_banks = ["bni","cimb","mandiri"]
92
+ client.installment_terms = { bni: ['3','12','2'], cimb: ['3', '6', '12'] }
93
+ client.point_banks = ["cimb","bni", "miun"]
94
+ client.bank = 'bni'
95
+ client.payment_methods = ["credit_card","mandiri_clickpay"]
96
+
97
+ client.get_keys
98
+ @client = client
99
+ render :layout => 'application'
100
+ end
101
+
102
+ After you get TOKEN_BROWSER and TOKEN_MERCHANT, post merchant_id, order_id and TOKEN_BROWSER to redirection url of vtweb. This code is also taken from https://github.com/veritrans/veritrans-rails-sample-cart :
103
+
104
+ <h1 align="center">Confirm Purchase Items</h1>
105
+
106
+ <%= form_tag(@client.redirection_url, :name => "form_auto_post") do -%>
107
+ <input type="hidden" name="merchant_id" value="<%= @client.merchant_id %>">
108
+ <input type="hidden" name="order_id" value="<%= @client.order_id %>">
109
+ <input type="hidden" name="token_browser" value="<%= @client.token["TOKEN_BROWSER"] %>">
110
+ <table border="1" align="center" width="80%" cellpadding="10" bgcolor="#FFFFCC">
111
+ <tr>
112
+ <th>Name</th>
113
+ <th>Price</th>
114
+ <th>Quantity</th>
115
+ <th>Sub Total</th>
116
+ </tr>
117
+
118
+ <% for cart in @carts %>
119
+ <tr>
120
+ <td><%= cart.product.name %></td>
121
+ <td><%= cart.product.price %></td>
122
+ <td><%= cart.quantity %></td>
123
+ <td><%= cart.sub_total %></td>
124
+ </tr>
125
+ <% end %>
126
+ <tr>
127
+ <td colspan="2"></td>
128
+ <td style="text-align=right"><strong>Total</strong></td>
129
+ <td style="text-align=right"><strong><%= @total %> </strong></td>
130
+ </tr>
131
+ </table>
132
+ <br><br>
133
+ <div align="center">
134
+ <input type="submit" value="Go to payment page">
135
+ </div>
136
+ <% end %>
22
137
 
23
138
  ## Contributing
24
139
 
@@ -1,3 +1,3 @@
1
1
  module Vtweb
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["panggi@me.com"]
11
11
  spec.summary = %q{Ruby wrapper for Veritrans VT-Web.}
12
12
  spec.description = %q{VT-Web makes accepting online payments simple because the whole payment process is handled by Veritrans, and we take care most of the information security compliance requirements from the bank (Veritrans is certified as a PCI-DSS Level 1 Service Provider). Merchants focus on their core business, while we take care of the rest.}
13
- spec.homepage = "http://panggi.com"
13
+ spec.homepage = "https://github.com/panggi/vtweb"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "addressable"
22
- spec.add_runtime_dependency "faraday"
21
+ spec.add_runtime_dependency "addressable", "2.3.5"
22
+ spec.add_runtime_dependency "faraday", "0.8.8"
23
23
  spec.add_runtime_dependency "rake"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.5"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Panggi Libersa Jasri Akadol
@@ -14,30 +14,30 @@ dependencies:
14
14
  name: addressable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.3.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.3.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.8.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.8.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +102,7 @@ files:
102
102
  - lib/vtweb/post_params.rb
103
103
  - lib/vtweb/version.rb
104
104
  - vtweb.gemspec
105
- homepage: http://panggi.com
105
+ homepage: https://github.com/panggi/vtweb
106
106
  licenses:
107
107
  - MIT
108
108
  metadata: {}