veritrans 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/veritrans CHANGED
@@ -51,28 +51,6 @@ client.shipping_phone = "0123456789123"
51
51
  client.shipping_method = "N"
52
52
  client.get_keys
53
53
  client
54
-
55
- OR
56
-
57
- client = Veritrans::Client.new do |me|
58
- me.order_id = "dummy#{(0...12).map{65.+(rand(25))}.join}"
59
- me.session_id = "session#{(0...12).map{65.+(rand(25))}.join}"
60
- me.gross_amount = "10"
61
- me.commodity = [
62
- {"COMMODITY_ID" => "IDxx1", "COMMODITY_UNIT" => "10", "COMMODITY_NUM" => "1", "COMMODITY_NAME1" => "Waterbotle", "COMMODITY_NAME2" => "Waterbottle in Indonesian"}
63
- ]
64
- me.shipping_flag = "1"
65
- me.shipping_first_name = "Sam"
66
- me.shipping_last_name = "Anthony"
67
- me.shipping_address1 = "Buaran I"
68
- me.shipping_address2 = "Pulogadung"
69
- me.shipping_city = "Jakarta"
70
- me.shipping_country_code = "IDN"
71
- me.shipping_postal_code = "16954"
72
- me.shipping_phone = "0123456789123"
73
- me.shipping_method = "N"
74
- end
75
-
76
54
  EOF
77
55
 
78
56
  IRB.start
data/config/veritrans.yml CHANGED
@@ -4,7 +4,8 @@ development:
4
4
  finish_payment_return_url: "http://localhost/finish"
5
5
  unfinish_payment_return_url: "http://localhost/cancel"
6
6
  error_payment_return_url: "http://localhost/error"
7
- # server_host: "http://192.168.10.250:80"
7
+ server_key: "2a8f3674-71cf-42af-aa56-b872b8924f72"
8
+ server_host: "http://veritrans.dev"
8
9
 
9
10
  production:
10
11
  merchant_id: "production_id"
@@ -12,4 +13,6 @@ production:
12
13
  finish_payment_return_url: "http://mydomain/finish"
13
14
  unfinish_payment_return_url: "http://mydomain/cancel"
14
15
  error_payment_return_url: "http://mydomain/error"
16
+ server_key: "2a8f3674-71cf-42af-aa56-b872b8924f72"
17
+ server_host: "http://veritrans.dev"
15
18
  # server_host: "http://192.168.10.250:80"
@@ -39,6 +39,7 @@ class VeritransController < ApplicationController
39
39
  client.postal_code = "16954"
40
40
  client.phone = "0123456789123"
41
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
42
43
 
43
44
  client.get_keys
44
45
  @client = client
data/lib/veritrans.rb CHANGED
@@ -15,4 +15,5 @@ require 'veritrans/post_data'
15
15
  require 'veritrans/version'
16
16
  require 'veritrans/config'
17
17
  require 'veritrans/client'
18
+ require 'veritrans/v_t_direct'
18
19
  require 'generators/install_generator.rb'
@@ -54,7 +54,6 @@ module Veritrans
54
54
  uri = Addressable::URI.new
55
55
  uri.query_values = params
56
56
  query_string = "#{uri.query}&REPEAT_LINE=#{@commodity.length}&#{commodity.join('&')}"
57
- # puts query_string
58
57
 
59
58
  conn = Faraday.new(:url => server_host)
60
59
  @resp = conn.post do |req|
@@ -116,7 +116,8 @@ module Veritrans
116
116
  :order_id,
117
117
  :session_id,
118
118
  :merchanthash,
119
- :card_capture_flag
119
+ :card_capture_flag,
120
+ :promo_id
120
121
  ]
121
122
 
122
123
  # +:merchant_id,+
@@ -0,0 +1,105 @@
1
+ require 'base64'
2
+ require 'json'
3
+ # :nodoc:
4
+ module Veritrans
5
+
6
+ # :nodoc:
7
+ class VTDirect
8
+ include Config
9
+ @@attr = [:token_id, :order_id, :order_items, :gross_amount, :email, :shipping_address, :billing_address]
10
+
11
+ # constructor to create instance of Veritrans::Client
12
+ def initialize
13
+ class <<self
14
+ self
15
+ end.class_eval do
16
+ attr_accessor *@@attr
17
+ end
18
+ end
19
+
20
+ # Example:
21
+ #
22
+ # vt_direct = Veritrans::VTDirect.new
23
+ # vt_direct.token_id = "32eeeb9f-8ac3-b824-eb6d-faaa25240d27"
24
+ # vt_direct.order_id = "order_5"
25
+ # vt_direct.order_items = [
26
+ # {
27
+ # id: "10",
28
+ # price: 100,
29
+ # qty: 1,
30
+ # name1: "Mie",
31
+ # name2: "Goreng"
32
+ # },
33
+ # {
34
+ # id: "11",
35
+ # price: 100,
36
+ # qty: 1,
37
+ # name1: "Mie",
38
+ # name2: "Kuah"
39
+ # }
40
+ # ]
41
+ # vt_direct.gross_amount = 200
42
+ # vt_direct.email = "echo.khannedy@gmail.com"
43
+ # vt_direct.shipping_address = {
44
+ # first_name: "Sam",
45
+ # last_name: "Anthony",
46
+ # address1: "Buaran I",
47
+ # address2: "Pulogadung",
48
+ # city: "Jakarta",
49
+ # country_code: "IDN",
50
+ # postal_code: "16954",
51
+ # phone: "0123456789123"
52
+ # }
53
+ # vt_direct.billing_address = {
54
+ # first_name: "Sam",
55
+ # last_name: "Anthony",
56
+ # address1: "Buaran I",
57
+ # address2: "Pulogadung",
58
+ # city: "Jakarta",
59
+ # country_code: "IDN",
60
+ # postal_code: "16954",
61
+ # phone: "0123456789123"
62
+ # }
63
+ # vt_direct.charges
64
+ #
65
+ def charges
66
+ # conn = Faraday.new(:url => 'http://veritrans.dev/charges')
67
+ parms = prepare_params([:server_key]+@@attr).to_json
68
+ basic = Base64.encode64("#{server_key}:")
69
+ conn = Faraday.new(:url => server_host)
70
+ @resp = conn.post do |req|
71
+ req.url('/charges')
72
+ req.headers['Content-Type'] = 'application/json'
73
+ req.headers['Authorization'] = "Basic #{basic}"
74
+ req.body = parms
75
+ end.env
76
+ @data = @resp[:body]
77
+ end
78
+
79
+ # :nodoc:
80
+ def server_host
81
+ return VTDirect.config["server_host"] ? VTDirect.config["server_host"] : Config::SERVER_HOST
82
+ end
83
+
84
+ # :nodoc:
85
+ def server_key
86
+ return VTDirect.config["server_key"]
87
+ end
88
+
89
+ # :nodoc:
90
+ def server_key= new_server_key
91
+ VTDirect.config["server_key"] = new_server_key
92
+ end
93
+
94
+ private
95
+
96
+ def prepare_params(*arg)
97
+ params = {}
98
+ arg.flatten.each do |key|
99
+ value = self.send(key)
100
+ params[key.downcase] = value if value
101
+ end
102
+ return params
103
+ end
104
+ end
105
+ end
@@ -19,7 +19,7 @@ module Veritrans
19
19
 
20
20
  # :nodoc:
21
21
  def minor
22
- 0
22
+ 1
23
23
  end
24
24
 
25
25
  # :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.0.0
4
+ version: 1.1.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-09-10 00:00:00.000000000 Z
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -71,6 +71,7 @@ files:
71
71
  - bin/veritrans
72
72
  - lib/veritrans.rb
73
73
  - lib/veritrans/client.rb
74
+ - lib/veritrans/v_t_direct.rb
74
75
  - lib/veritrans/config.rb
75
76
  - lib/veritrans/hash_generator.rb
76
77
  - lib/veritrans/post_data.rb
@@ -98,9 +99,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
99
  - - ! '>='
99
100
  - !ruby/object:Gem::Version
100
101
  version: '0'
101
- segments:
102
- - 0
103
- hash: -1916124557783123575
104
102
  required_rubygems_version: !ruby/object:Gem::Requirement
105
103
  none: false
106
104
  requirements: