Class: Vtweb::Client
Constant Summary
Constants included
from Config
Vtweb::Config::BILLING_DIFFERENT_WITH_SHIPPING, Vtweb::Config::GET_TOKENS_URL, Vtweb::Config::PAYMENT_TYPE, Vtweb::Config::REDIRECTION_URL, Vtweb::Config::VTWEB_SERVER
Instance Method Summary
collapse
Methods included from Config
included
Constructor Details
#initialize(&block) ⇒ Client
Returns a new instance of Client.
Instance Method Details
#billing_different_with_shipping ⇒ Object
153
154
155
|
# File 'lib/vtweb.rb', line 153
def billing_different_with_shipping
@billing_different_with_shipping
end
|
#billing_different_with_shipping=(flag) ⇒ Object
157
158
159
|
# File 'lib/vtweb.rb', line 157
def billing_different_with_shipping=(flag)
@billing_different_with_shipping = billing_different_with_shipping
end
|
#error_payment_return_url ⇒ Object
137
138
139
|
# File 'lib/vtweb.rb', line 137
def error_payment_return_url
return Client.config["error_payment_return_url"]
end
|
#finish_payment_return_url ⇒ Object
141
142
143
|
# File 'lib/vtweb.rb', line 141
def finish_payment_return_url
return Client.config["finish_payment_return_url"]
end
|
#get_keys ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/vtweb.rb', line 30
def get_keys
init_instance
if billing_different_with_shipping == "0" && required_shipping_address == "0"
raise "required_shipping_address must be '1'"
end
params = prepare_params(PostParams::ServerParams,PostParams::AllParam)
if !params[:promo_bins].blank?
params.merge!({ "promo_bins[]" => params[:promo_bins]})
params.delete :promo_bins
end
if !params[:point_banks].blank?
params.merge!({ "point_banks[]" => params[:point_banks]})
params.delete :point_banks
end
if !params[:installment_banks].blank?
params.merge!({ "installment_banks[]" => params[:installment_banks]})
params.delete :installment_banks
end
if !params[:installment_terms].blank?
params.merge!({ "installment_terms" => params[:installment_terms].to_json })
params.delete :installment_terms
end
if !params[:payment_methods].blank?
params.merge!({ "payment_methods[]" => params[:payment_methods]})
params.delete :payment_methods
end
item = @item.collect do |data|
data.keys.map do |key|
if key.downcase == "item_id"
data["item_id[]"] = data[key]
end
if key.downcase == "price"
data["price[]"] = data[key]
end
if key.downcase == "quantity"
data["quantity[]"] = data[key]
end
if key.downcase == "item_name1"
data["item_name1[]"] = data[key]
end
if key.downcase == "item_name2"
data["item_name2[]"] = data[key]
end
data.delete key
end
orders_uri = Addressable::URI.new
orders_uri.query_values = data
orders_uri.query
end
uri = Addressable::URI.new
uri.query_values = params
query_string = "#{uri.query}&repeat_line=#{item.length}&#{item.join('&')}"
conn = Faraday.new(:url => vtweb_server)
@resp = conn.post do |req|
req.url(Config::GET_TOKENS_URL)
req.body = query_string
end.env
delete_keys
@resp[:url] = @resp[:url].to_s
@token = parse_body(@resp[:body])
end
|
#merchant_hash_key ⇒ Object
129
130
131
|
# File 'lib/vtweb.rb', line 129
def merchant_hash_key
return Client.config["merchant_hash_key"]
end
|
#merchant_hash_key=(new_merchant_hash_key) ⇒ Object
133
134
135
|
# File 'lib/vtweb.rb', line 133
def merchant_hash_key= new_merchant_hash_key
Client.config["merchant_hash_key"] = new_merchant_hash_key
end
|
#merchant_id ⇒ Object
121
122
123
|
# File 'lib/vtweb.rb', line 121
def merchant_id
return Client.config["merchant_id"]
end
|
#merchant_id=(new_merchant_id) ⇒ Object
125
126
127
|
# File 'lib/vtweb.rb', line 125
def merchant_id= new_merchant_id
Client.config["merchant_id"] = new_merchant_id
end
|
#new_api ⇒ Object
169
170
171
|
# File 'lib/vtweb.rb', line 169
def new_api
return true
end
|
#redirection_url ⇒ Object
117
118
119
|
# File 'lib/vtweb.rb', line 117
def redirection_url
"#{vtweb_server}#{Config::REDIRECTION_URL}"
end
|
#required_shipping_address ⇒ Object
161
162
163
|
# File 'lib/vtweb.rb', line 161
def required_shipping_address
@required_shipping_address
end
|
#required_shipping_address=(flag) ⇒ Object
165
166
167
|
# File 'lib/vtweb.rb', line 165
def required_shipping_address=(flag)
@required_shipping_address = flag
end
|
#token ⇒ Object
149
150
151
|
# File 'lib/vtweb.rb', line 149
def token
return @token
end
|
#unfinish_payment_return_url ⇒ Object
145
146
147
|
# File 'lib/vtweb.rb', line 145
def unfinish_payment_return_url
return Client.config["unfinish_payment_return_url"]
end
|
#vtweb_server ⇒ Object
113
114
115
|
# File 'lib/vtweb.rb', line 113
def vtweb_server
return Client.config["vtweb_server"] ? Client.config["vtweb_server"] : Config::VTWEB_SERVER
end
|