tbk-sdk 1.5.0.pre.ruby2.3
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.
- checksums.yaml +7 -0
- data/.built +0 -0
- data/.bundled +0 -0
- data/.github/ISSUE_TEMPLATE/reporte-de-error.md +40 -0
- data/.gitignore +16 -0
- data/.rakeTasks +7 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +63 -0
- data/Dockerfile +5 -0
- data/Gemfile +6 -0
- data/LICENSE.md +11 -0
- data/Makefile +24 -0
- data/README.md +87 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +20 -0
- data/lib/transbank/sdk/oneclick/base.rb +64 -0
- data/lib/transbank/sdk/oneclick/errors/oneclick_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/inscription/errors/mall_inscription_delete_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/inscription/errors/mall_inscription_finish_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/inscription/errors/mall_inscription_start_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/inscription/errors/oneclick_mall_inscription_errors.rb +3 -0
- data/lib/transbank/sdk/oneclick/inscription/inscription.rb +3 -0
- data/lib/transbank/sdk/oneclick/inscription/responses/mall_inscription_delete_response.rb +18 -0
- data/lib/transbank/sdk/oneclick/inscription/responses/mall_inscription_finish_response.rb +15 -0
- data/lib/transbank/sdk/oneclick/inscription/responses/mall_inscription_start_response.rb +14 -0
- data/lib/transbank/sdk/oneclick/inscription/responses/oneclick_mall_inscription_responses.rb +3 -0
- data/lib/transbank/sdk/oneclick/mall/errors/mall_transaction_authorize_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall/errors/mall_transaction_refund_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall/errors/mall_transaction_status_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall/errors/oneclick_mall_errors.rb +4 -0
- data/lib/transbank/sdk/oneclick/mall/mall_inscription.rb +73 -0
- data/lib/transbank/sdk/oneclick/mall/mall_transaction.rb +97 -0
- data/lib/transbank/sdk/oneclick/mall/oneclick_mall.rb +4 -0
- data/lib/transbank/sdk/oneclick/mall/responses/mall_transaction_authorize_response.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall/responses/mall_transaction_refund_response.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall/responses/mall_transaction_status_response.rb +15 -0
- data/lib/transbank/sdk/oneclick/mall/responses/oneclick_mall_responses.rb +4 -0
- data/lib/transbank/sdk/oneclick/mall_deferred/errors/mall_deferred_transaction_capture_error.rb +16 -0
- data/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription.rb +20 -0
- data/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb +42 -0
- data/lib/transbank/sdk/oneclick/mall_deferred/responses/mall_deferred_transaction_capture_response.rb +16 -0
- data/lib/transbank/sdk/oneclick/oneclick.rb +12 -0
- data/lib/transbank/sdk/onepay/base.rb +125 -0
- data/lib/transbank/sdk/onepay/errors/errors.rb +17 -0
- data/lib/transbank/sdk/onepay/errors/integration_type_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/invalid_options_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/item_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/refund_create_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/response_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/shopping_cart_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/signature_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/transaction_commit_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/transaction_create_error.rb +8 -0
- data/lib/transbank/sdk/onepay/errors/transbank_error.rb +9 -0
- data/lib/transbank/sdk/onepay/models/channels.rb +15 -0
- data/lib/transbank/sdk/onepay/models/item.rb +103 -0
- data/lib/transbank/sdk/onepay/models/models.rb +10 -0
- data/lib/transbank/sdk/onepay/models/refund.rb +50 -0
- data/lib/transbank/sdk/onepay/models/shopping_cart.rb +65 -0
- data/lib/transbank/sdk/onepay/models/transaction.rb +143 -0
- data/lib/transbank/sdk/onepay/requests/refund_create_request.rb +45 -0
- data/lib/transbank/sdk/onepay/requests/request.rb +18 -0
- data/lib/transbank/sdk/onepay/requests/requests.rb +9 -0
- data/lib/transbank/sdk/onepay/requests/transaction_commit_request.rb +48 -0
- data/lib/transbank/sdk/onepay/requests/transaction_create_request.rb +85 -0
- data/lib/transbank/sdk/onepay/responses/refund_create_response.rb +24 -0
- data/lib/transbank/sdk/onepay/responses/response.rb +18 -0
- data/lib/transbank/sdk/onepay/responses/responses.rb +9 -0
- data/lib/transbank/sdk/onepay/responses/transaction_commit_response.rb +39 -0
- data/lib/transbank/sdk/onepay/responses/transaction_create_response.rb +32 -0
- data/lib/transbank/sdk/patpass/errors/integration_type_error.rb +8 -0
- data/lib/transbank/sdk/patpass/errors/patpass_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/base.rb +47 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/errors/patpass_by_webpay_errors.rb +12 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/errors/transaction_commit_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/errors/transaction_create_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/errors/transaction_status_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/options.rb +9 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/patpass_by_webpay.rb +16 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/responses/patpass_by_webpay_responses.rb +3 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/responses/transaction_commit_response.rb +20 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/responses/transaction_create_response.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/responses/transaction_status_response.rb +21 -0
- data/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb +93 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/base.rb +47 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/errors/inscription_start_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/errors/inscription_status_error.rb +15 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/errors/patpass_comercio_errors.rb +2 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb +79 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/options.rb +9 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/patpass_comercio.rb +5 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/responses/inscription_start_response.rb +13 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/responses/inscription_status_response.rb +13 -0
- data/lib/transbank/sdk/patpass/patpass_comercio/responses/patpass_comercio_responses.rb +2 -0
- data/lib/transbank/sdk/transaccion_completa/base.rb +51 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaccion_completa_error.rb +16 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaccion_completa_errors.rb +7 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_capture_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_commit_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_create_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_installments_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_refund_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/errors/transaction_status_error.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/mall/mall_transaction.rb +197 -0
- data/lib/transbank/sdk/transaccion_completa/mall/responses/mall_transaction_capture_response.rb +12 -0
- data/lib/transbank/sdk/transaccion_completa/mall/responses/mall_transaction_commit_response.rb +15 -0
- data/lib/transbank/sdk/transaccion_completa/mall/responses/mall_transaction_installments_response.rb +11 -0
- data/lib/transbank/sdk/transaccion_completa/mall/responses/mall_transaction_responses.rb +4 -0
- data/lib/transbank/sdk/transaccion_completa/mall/responses/mall_transaction_status_response.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/options.rb +7 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaccion_completa_responses.rb +6 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_capture_response.rb +12 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_commit_response.rb +16 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_create_response.rb +10 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_installments_response.rb +13 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_refund_response.rb +14 -0
- data/lib/transbank/sdk/transaccion_completa/responses/transaction_status_response.rb +16 -0
- data/lib/transbank/sdk/transaccion_completa/transaccion_completa.rb +7 -0
- data/lib/transbank/sdk/transaccion_completa/transaction.rb +144 -0
- data/lib/transbank/sdk/transbank_error.rb +6 -0
- data/lib/transbank/sdk/utils/json_utils.rb +75 -0
- data/lib/transbank/sdk/utils/net_helper.rb +82 -0
- data/lib/transbank/sdk/utils/request_builder.rb +96 -0
- data/lib/transbank/sdk/utils/signature_utils.rb +49 -0
- data/lib/transbank/sdk/utils/utils.rb +9 -0
- data/lib/transbank/sdk/version.rb +5 -0
- data/lib/transbank/sdk/webpay/errors/integration_type_error.rb +8 -0
- data/lib/transbank/sdk/webpay/errors/webpay_error.rb +14 -0
- data/lib/transbank/sdk/webpay/webpay_plus/base.rb +74 -0
- data/lib/transbank/sdk/webpay/webpay_plus/deferred/deferred_transaction.rb +108 -0
- data/lib/transbank/sdk/webpay/webpay_plus/deferred/errors/transaction_capture_error.rb +16 -0
- data/lib/transbank/sdk/webpay/webpay_plus/deferred/errors/webpay_plus_deferred_errors.rb +1 -0
- data/lib/transbank/sdk/webpay/webpay_plus/deferred/responses/transaction_capture_response.rb +22 -0
- data/lib/transbank/sdk/webpay/webpay_plus/deferred/responses/webpay_plus_deferred_responses.rb +1 -0
- data/lib/transbank/sdk/webpay/webpay_plus/errors/transaction_commit_error.rb +17 -0
- data/lib/transbank/sdk/webpay/webpay_plus/errors/transaction_create_error.rb +16 -0
- data/lib/transbank/sdk/webpay/webpay_plus/errors/transaction_refund_error.rb +16 -0
- data/lib/transbank/sdk/webpay/webpay_plus/errors/transaction_status_error.rb +16 -0
- data/lib/transbank/sdk/webpay/webpay_plus/errors/webpay_plus_errors.rb +13 -0
- data/lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb +88 -0
- data/lib/transbank/sdk/webpay/webpay_plus/mall/responses/mall_transaction_commit_response.rb +23 -0
- data/lib/transbank/sdk/webpay/webpay_plus/mall/responses/mall_transaction_status_response.rb +21 -0
- data/lib/transbank/sdk/webpay/webpay_plus/mall/responses/webpay_plus_mall_responses.rb +2 -0
- data/lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb +109 -0
- data/lib/transbank/sdk/webpay/webpay_plus/options.rb +9 -0
- data/lib/transbank/sdk/webpay/webpay_plus/responses/transaction_commit_response.rb +20 -0
- data/lib/transbank/sdk/webpay/webpay_plus/responses/transaction_create_response.rb +15 -0
- data/lib/transbank/sdk/webpay/webpay_plus/responses/transaction_refund_response.rb +19 -0
- data/lib/transbank/sdk/webpay/webpay_plus/responses/transaction_status_response.rb +21 -0
- data/lib/transbank/sdk/webpay/webpay_plus/responses/webpay_plus_responses.rb +4 -0
- data/lib/transbank/sdk/webpay/webpay_plus/transaction.rb +89 -0
- data/lib/transbank/sdk/webpay/webpay_plus/webpay_plus.rb +24 -0
- data/lib/transbank/sdk.rb +27 -0
- data/sdk_test.sh +2 -0
- data/transbank-sdk.gemspec +35 -0
- metadata +340 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Utils
|
|
3
|
+
module JSONUtils
|
|
4
|
+
def self.included(mod)
|
|
5
|
+
# Implement #to_h if the class that includes this module doesn't have it
|
|
6
|
+
# implemented. Used in several model classes to make them easier to
|
|
7
|
+
# transform to hashes so they can be transformed to JSON afterwards
|
|
8
|
+
unless mod.respond_to? :to_h
|
|
9
|
+
mod.send(:define_method, :to_h) do
|
|
10
|
+
JSON.parse(self.jsonify)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
# Get all instance variables of an instance of a class,
|
|
15
|
+
# then for all of these variables,
|
|
16
|
+
# if the instance of the class' respond_to? returns true,
|
|
17
|
+
# #send the variable name (so, you'll get the value of the instance variable's
|
|
18
|
+
# getter), then save that to a Hash where [key] is the instance variable's name
|
|
19
|
+
# and [value] is its value
|
|
20
|
+
#
|
|
21
|
+
# Finally, generate a JSON string from this hash
|
|
22
|
+
# @return [String] a JSON string created from the Hash resulting from the
|
|
23
|
+
# above operation
|
|
24
|
+
def jsonify
|
|
25
|
+
instance_vars = instance_variables.map! { |var| var.to_s.gsub!(/^@/, '') }
|
|
26
|
+
instance_as_hash =
|
|
27
|
+
instance_vars.reduce({}) do |resulting_hash, instance_variable|
|
|
28
|
+
if respond_to? instance_variable
|
|
29
|
+
value = send(instance_variable)
|
|
30
|
+
# Safe navigation operator is Ruby 2.3+
|
|
31
|
+
value = value.to_h if value && value.respond_to?(:to_h) unless value.is_a? Array
|
|
32
|
+
value = value.to_a if value && value.respond_to?(:to_a) unless value.is_a? Hash
|
|
33
|
+
if value.is_a? Array
|
|
34
|
+
value = value.map {|x| x.respond_to?(:jsonify) ? JSON.parse(x.jsonify) : x }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
value = value.jsonify if value.respond_to? :jsonify
|
|
38
|
+
resulting_hash[instance_variable] = value
|
|
39
|
+
end
|
|
40
|
+
resulting_hash
|
|
41
|
+
end
|
|
42
|
+
# Some values can't be null and must be removed if they are
|
|
43
|
+
instance_as_hash.reject! do |key, value|
|
|
44
|
+
%w[commerce_logo_url width_height].include?(key) && value.nil?
|
|
45
|
+
end
|
|
46
|
+
JSON.generate instance_as_hash
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Receive a Hash and return a new hash same as the one we received,
|
|
50
|
+
# but all keys that were strings or camelCase'd are snake_case'd and
|
|
51
|
+
# turned into symbols.
|
|
52
|
+
# Example: {'camelCaseKey': "somevalue"}
|
|
53
|
+
# Would return: {camel_case_key: "somevalue"}
|
|
54
|
+
def transform_hash_keys(hash)
|
|
55
|
+
hash.reduce({}) do |new_hsh, (key, val)|
|
|
56
|
+
new_key = underscore(key).to_sym
|
|
57
|
+
new_hsh[new_key] = val
|
|
58
|
+
new_hsh
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# FROM https://stackoverflow.com/a/1509957
|
|
63
|
+
# Transforms camelCaseWords to snake_case_words
|
|
64
|
+
def underscore(camel_cased_word)
|
|
65
|
+
camel_cased_word.to_s.gsub(/::/, '/')
|
|
66
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
|
67
|
+
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
|
68
|
+
.tr("-", "_")
|
|
69
|
+
.downcase
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Utils
|
|
3
|
+
module NetHelper
|
|
4
|
+
def http_get(uri_string:, headers:nil)
|
|
5
|
+
uri = URI.parse(uri_string)
|
|
6
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
7
|
+
http.use_ssl = uri.scheme == 'https'
|
|
8
|
+
request_headers = {'Content-Type' => 'application/json'}.merge(headers || {})
|
|
9
|
+
request = Net::HTTP::Get.new(uri.path, request_headers)
|
|
10
|
+
http.request(request)
|
|
11
|
+
end
|
|
12
|
+
# POST a request to Transbank's servers, and return the parsed response
|
|
13
|
+
# @param uri_string [String] an URI to post to
|
|
14
|
+
# @param body [Hash] the body of your POST request
|
|
15
|
+
# @return [Hash] the JSON.parse'd response body
|
|
16
|
+
def http_post(uri_string:, body: nil, headers: nil, camel_case_keys: true)
|
|
17
|
+
uri = URI.parse(uri_string)
|
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
19
|
+
http.use_ssl = uri.scheme == 'https'
|
|
20
|
+
|
|
21
|
+
request_headers = {'Content-Type' => 'application/json'}.merge(headers || {})
|
|
22
|
+
request = Net::HTTP::Post.new(uri.path, request_headers)
|
|
23
|
+
sendable_body = camel_case_keys ? keys_to_camel_case(body) : body
|
|
24
|
+
request.body = sendable_body.to_json
|
|
25
|
+
http.request(request)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def http_put(uri_string:, body: nil, headers: nil)
|
|
29
|
+
uri = URI.parse(uri_string)
|
|
30
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
31
|
+
http.use_ssl = uri.scheme == 'https'
|
|
32
|
+
|
|
33
|
+
request_headers = {'Content-Type' => 'application/json'}.merge(headers || {})
|
|
34
|
+
request = Net::HTTP::Put.new(uri.path, request_headers)
|
|
35
|
+
request.body = JSON.generate(body)
|
|
36
|
+
http.request(request)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def http_delete(uri_string:, body: nil, headers: nil)
|
|
40
|
+
uri = URI.parse(uri_string)
|
|
41
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
42
|
+
http.use_ssl = uri.scheme == 'https'
|
|
43
|
+
|
|
44
|
+
request_headers = {'Content-Type' => 'application/json'}.merge(headers || {})
|
|
45
|
+
request = Net::HTTP::Delete.new(uri.path, request_headers)
|
|
46
|
+
request.body = JSON.generate(body)
|
|
47
|
+
http.request(request)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Required for sending data to Transbank on Onepay.
|
|
51
|
+
def keys_to_camel_case(hash)
|
|
52
|
+
hash.reduce({}) do |new_hash, (key, val)|
|
|
53
|
+
if val.is_a? Array
|
|
54
|
+
val = val.map {|value| value.is_a?(Hash) ? keys_to_camel_case(value) : value }
|
|
55
|
+
end
|
|
56
|
+
new_key = snake_to_camel_case(key.to_s)
|
|
57
|
+
new_hash[new_key] = val
|
|
58
|
+
new_hash
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def snake_to_camel_case(str)
|
|
63
|
+
str.split('_').reduce { |string, current_word| string + current_word.capitalize }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def webpay_headers(commerce_code:, api_key:)
|
|
67
|
+
{
|
|
68
|
+
"Tbk-Api-Key-Id" => commerce_code,
|
|
69
|
+
"Tbk-Api-Key-Secret" => api_key
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def patpass_comercio_headers(commerce_code:, api_key:)
|
|
74
|
+
{
|
|
75
|
+
"commercecode" => commerce_code,
|
|
76
|
+
"Authorization" => api_key
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Onepay
|
|
3
|
+
module Utils
|
|
4
|
+
module RequestBuilder
|
|
5
|
+
# Create a [Transaction] request. Used internally by [Transaction]#create
|
|
6
|
+
# @param shopping_cart [ShoppingCart] the user's ShoppingCart, with [Item]s
|
|
7
|
+
# he/she intends to purchase
|
|
8
|
+
# @param channel [String] The channel the operation is made on. Valid values
|
|
9
|
+
# are on the [Channel] class
|
|
10
|
+
# @param external_unique_number [String, nil] a unique value (per Merchant, not global) that is used to identify a Transaction
|
|
11
|
+
# @param options [Hash, nil] a hash with config overrides
|
|
12
|
+
def create_transaction(shopping_cart:, channel:, external_unique_number: nil, options: nil)
|
|
13
|
+
channel = Base.default_channel if channel.nil?
|
|
14
|
+
external_unique_number = time_as_number if external_unique_number.nil?
|
|
15
|
+
options = complete_options(options)
|
|
16
|
+
issued_at = Time.now.to_i
|
|
17
|
+
|
|
18
|
+
request = TransactionCreateRequest.new(
|
|
19
|
+
external_unique_number: external_unique_number,
|
|
20
|
+
total: shopping_cart.total,
|
|
21
|
+
items_quantity: shopping_cart.items_quantity,
|
|
22
|
+
issued_at: issued_at,
|
|
23
|
+
items: shopping_cart.items,
|
|
24
|
+
callback_url: Base.callback_url,
|
|
25
|
+
channel: channel,
|
|
26
|
+
app_scheme: Base.app_scheme,
|
|
27
|
+
commerce_logo_url: options[:commerce_logo_url],
|
|
28
|
+
width_height: options[:qr_width_height]
|
|
29
|
+
)
|
|
30
|
+
request.set_keys_from_options(options)
|
|
31
|
+
request.app_key = Base::current_integration_type_app_key
|
|
32
|
+
request.sign(options.fetch(:shared_secret))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Used internally by [Transaction]#commit
|
|
36
|
+
# @param occ [String] Merchant purchase order
|
|
37
|
+
# @param external_unique_number [String] a unique value (per Merchant, not global) that is used to identify a Transaction
|
|
38
|
+
# @param options [Hash, nil] a hash with config overrides
|
|
39
|
+
def commit_transaction(occ:, external_unique_number:, options: nil)
|
|
40
|
+
options = complete_options(options)
|
|
41
|
+
issued_at = Time.now.to_i
|
|
42
|
+
request = TransactionCommitRequest.new(occ, external_unique_number, issued_at)
|
|
43
|
+
request.set_keys_from_options(options)
|
|
44
|
+
request.app_key = Base::current_integration_type_app_key
|
|
45
|
+
request.sign(options.fetch(:shared_secret))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Used internally by [Refund]#create
|
|
49
|
+
# @param refund_amount [Integer] the full amount of the [Transaction] to refund. No partial refunds allowed.
|
|
50
|
+
# @param occ [String] Merchant purchase order of the order to refund
|
|
51
|
+
# @param external_unique_number [String] external unique number of the [Transaction] to refund
|
|
52
|
+
# @param authorization_code [String] authorization code for the [Transaction] to refund.
|
|
53
|
+
# This is given when you successfully #commit a [Transaction]
|
|
54
|
+
# @param options [Hash, nil] a hash with config overrides
|
|
55
|
+
def refund_transaction(refund_amount:, occ:, external_unique_number:, authorization_code:, options: nil)
|
|
56
|
+
options = complete_options(options)
|
|
57
|
+
issued_at = Time.now.to_i
|
|
58
|
+
request = RefundCreateRequest.new(nullify_amount: refund_amount,
|
|
59
|
+
occ: occ,
|
|
60
|
+
external_unique_number: external_unique_number,
|
|
61
|
+
authorization_code: authorization_code,
|
|
62
|
+
issued_at: issued_at)
|
|
63
|
+
request.set_keys_from_options(options)
|
|
64
|
+
request.app_key = Base::current_integration_type_app_key
|
|
65
|
+
request.sign(options.fetch(:shared_secret))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def time_as_number
|
|
69
|
+
# Float#truncate(number_of_digits_to_leave) is from Ruby 2.4 onwards
|
|
70
|
+
number, decimals = Time.now.to_f.to_s.split('.')
|
|
71
|
+
(number + decimals[0..2]).to_i
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Fill options with default values
|
|
75
|
+
def complete_options(options = {})
|
|
76
|
+
options = {} if options.nil?
|
|
77
|
+
default_options.merge(options)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Return the default options values:
|
|
81
|
+
# api_key: Base::api_key
|
|
82
|
+
# app_key: Base::current_integration_type_app_key
|
|
83
|
+
# shared_secret: Base::shared_secret
|
|
84
|
+
# @return [Hash] a hash with the aforementioned keys/values
|
|
85
|
+
def default_options
|
|
86
|
+
{
|
|
87
|
+
api_key: Base::api_key,
|
|
88
|
+
shared_secret: Base::shared_secret,
|
|
89
|
+
commerce_logo_url: Base::commerce_logo_url,
|
|
90
|
+
qr_width_height: Base::qr_width_height
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Onepay
|
|
3
|
+
module Utils
|
|
4
|
+
# Utils for creating signatures, included on classes that need to be signed
|
|
5
|
+
module SignatureUtils
|
|
6
|
+
# Transform the instance of the class that calls this method into a
|
|
7
|
+
# string in the format required for the signature, using the params defined
|
|
8
|
+
# in the class' SIGNATURE_PARAMS array constant
|
|
9
|
+
# @raise [RuntimeError] if self.class::SIGNATURE_PARAMS is nil or empty
|
|
10
|
+
def to_data
|
|
11
|
+
if self.class::SIGNATURE_PARAMS.nil? || self.class::SIGNATURE_PARAMS.empty?
|
|
12
|
+
raise RuntimeError, 'SIGNATURE_PARAMS is empty or nil!'
|
|
13
|
+
end
|
|
14
|
+
self.class::SIGNATURE_PARAMS.reduce('') do |data_string, current_value|
|
|
15
|
+
value_of_getter = send(current_value)
|
|
16
|
+
# Integer#digits is ruby 2.4 upwards :(
|
|
17
|
+
data_string + value_of_getter.to_s.length.to_s + value_of_getter.to_s
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Digest data and secret, creating a hashed string
|
|
22
|
+
# @param data [String] a string created from the signable, created using #to_data
|
|
23
|
+
# @param secret [String] the string to hash the data with.
|
|
24
|
+
# @return [String] the result of the hashing of data with secret.
|
|
25
|
+
def hmac_sha256(data, secret)
|
|
26
|
+
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), secret, data)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Return the base64 of the hmac_sha256'd data & secret
|
|
30
|
+
# @param data [String] a string created from the signable, created using #to_data
|
|
31
|
+
# @param secret [String] the string to hash the data with.
|
|
32
|
+
# @return [String] Base64 representation of the hmac_sha256 hashing of data & secret
|
|
33
|
+
def signature_for(data, secret)
|
|
34
|
+
Base64.encode64(hmac_sha256(data, secret)).strip
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Compare the @signature of self with the one recreated from self using
|
|
38
|
+
# the secret param. Return true if equal
|
|
39
|
+
# @param secret [String] the secret used to create the signature with.
|
|
40
|
+
# @return [boolean] return true if signatures match, false otherwise
|
|
41
|
+
def valid_signature?(secret)
|
|
42
|
+
# We should be able to recreate the same signature from the signable's data
|
|
43
|
+
# and the secret
|
|
44
|
+
self.signature == signature_for(self.to_data, secret)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module Errors
|
|
4
|
+
class WebpayError < ::Transbank::Errors::TransbankError
|
|
5
|
+
attr_accessor :message, :code
|
|
6
|
+
def initialize(message, code = nil)
|
|
7
|
+
self.message = message
|
|
8
|
+
self.code = code
|
|
9
|
+
super(message)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
class Base
|
|
5
|
+
|
|
6
|
+
DEFAULT_API_KEY = '579B532A7440BB0C9079DED94D31EA1615BACEB56610332264630D42D0A36B1C'.freeze
|
|
7
|
+
DEFAULT_COMMERCE_CODE = '597055555532'.freeze
|
|
8
|
+
DEFAULT_DEFERRED_COMMERCE_CODE = '597055555540'.freeze
|
|
9
|
+
|
|
10
|
+
DEFAULT_MALL_COMMERCE_CODE = '597055555535'.freeze
|
|
11
|
+
DEFAULT_MALL_CHILD_COMMERCE_CODES = ['597055555536'.freeze,'597055555537'.freeze].freeze;
|
|
12
|
+
DEFAULT_MALL_DEFERRED_COMMERCE_CODE = '597055555544 '.freeze
|
|
13
|
+
DEFAULT_MALL_DEFERRED_CHILD_COMMERCE_CODES = ['597055555545'.freeze,
|
|
14
|
+
'597055555546'.freeze].freeze
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@api_key = DEFAULT_API_KEY
|
|
18
|
+
@commerce_code = DEFAULT_COMMERCE_CODE
|
|
19
|
+
@integration_type = :TEST
|
|
20
|
+
@integration_types = {
|
|
21
|
+
LIVE: "https://webpay3g.transbank.cl/",
|
|
22
|
+
TEST: "https://webpay3gint.transbank.cl/"
|
|
23
|
+
}
|
|
24
|
+
class << self
|
|
25
|
+
attr_reader :integration_types
|
|
26
|
+
attr_accessor :api_key, :integration_type, :commerce_code
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def integration_type_url(integration_type)
|
|
30
|
+
type = integration_type.upcase.to_sym
|
|
31
|
+
return @integration_types[type] unless @integration_types[type].nil?
|
|
32
|
+
valid_values = @integration_types.keys.join(', ')
|
|
33
|
+
raise Transbank::Webpay::Errors::IntegrationTypeError, "Invalid integration type, valid values are #{valid_values}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def current_integration_type_url
|
|
37
|
+
@integration_types[@integration_type]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def integration_type=(integration_type)
|
|
41
|
+
type = integration_type.upcase.to_sym
|
|
42
|
+
return @integration_type = type unless @integration_types[type].nil?
|
|
43
|
+
valid_values = @integration_types.keys.join(', ')
|
|
44
|
+
raise Transbank::Webpay::Errors::IntegrationTypeError, "Invalid integration type, valid values are #{valid_values}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def configure_for_testing
|
|
48
|
+
@api_key = DEFAULT_API_KEY
|
|
49
|
+
@commerce_code = DEFAULT_COMMERCE_CODE
|
|
50
|
+
self.integration_type = :TEST
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def configure_mall_for_testing
|
|
54
|
+
@api_key = DEFAULT_API_KEY
|
|
55
|
+
@commerce_code = DEFAULT_MALL_COMMERCE_CODE
|
|
56
|
+
self.integration_type = :TEST
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def configure_deferred_for_testing
|
|
60
|
+
@api_key = DEFAULT_API_KEY
|
|
61
|
+
@commerce_code = DEFAULT_DEFERRED_COMMERCE_CODE
|
|
62
|
+
self.integration_type = :TEST
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def configure_mall_deferred_for_testing
|
|
66
|
+
@api_key = DEFAULT_API_KEY
|
|
67
|
+
@commerce_code = DEFAULT_MALL_DEFERRED_COMMERCE_CODE
|
|
68
|
+
self.integration_type = :TEST
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
class DeferredTransaction
|
|
5
|
+
extend Transbank::Utils::NetHelper
|
|
6
|
+
CREATE_TRANSACTION_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.0/transactions'
|
|
7
|
+
COMMIT_TRANSACTION_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.0/transactions'
|
|
8
|
+
TRANSACTION_STATUS_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.0/transactions'
|
|
9
|
+
REFUND_TRANSACTION_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.0/transactions/:token/refunds'
|
|
10
|
+
TRANSACTION_CAPTURE_ENDPOINT = 'rswebpaytransaction/api/webpay/v1.0/transactions/:token/capture'
|
|
11
|
+
class << self
|
|
12
|
+
|
|
13
|
+
def create(buy_order:, session_id:, amount:, return_url:, options: nil)
|
|
14
|
+
api_key = options&.api_key || default_integration_params[:api_key]
|
|
15
|
+
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
|
|
16
|
+
integration_type = options&.integration_type || default_integration_params[:integration_type]
|
|
17
|
+
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
|
|
18
|
+
|
|
19
|
+
body = {
|
|
20
|
+
buy_order: buy_order, session_id: session_id,
|
|
21
|
+
amount: amount, return_url: return_url
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
url = base_url + CREATE_TRANSACTION_ENDPOINT
|
|
25
|
+
headers = webpay_headers(commerce_code: commerce_code, api_key: api_key)
|
|
26
|
+
resp = http_post(uri_string: url, body: body, headers: headers, camel_case_keys: false)
|
|
27
|
+
body = JSON.parse(resp.body)
|
|
28
|
+
return ::Transbank::Webpay::WebpayPlus::TransactionCreateResponse.new(body) if resp.kind_of? Net::HTTPSuccess
|
|
29
|
+
raise Errors::TransactionCreateError.new(body['error_message'], resp.code)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def commit(token:, options: nil)
|
|
33
|
+
api_key = options&.api_key || default_integration_params[:api_key]
|
|
34
|
+
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
|
|
35
|
+
integration_type = options&.integration_type || default_integration_params[:integration_type]
|
|
36
|
+
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
|
|
37
|
+
|
|
38
|
+
url = base_url + COMMIT_TRANSACTION_ENDPOINT + "/#{token}"
|
|
39
|
+
headers = webpay_headers(commerce_code: commerce_code, api_key: api_key)
|
|
40
|
+
|
|
41
|
+
resp = http_put(uri_string: url, body: nil, headers: headers)
|
|
42
|
+
body = JSON.parse(resp.body)
|
|
43
|
+
return ::Transbank::Webpay::WebpayPlus::TransactionCommitResponse.new(body) if resp.kind_of? Net::HTTPSuccess
|
|
44
|
+
raise Errors::TransactionCommitError.new(body['error_message'], resp.code)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def refund(token:, amount:, options: nil)
|
|
48
|
+
api_key = options&.api_key || default_integration_params[:api_key]
|
|
49
|
+
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
|
|
50
|
+
integration_type = options&.integration_type || default_integration_params[:integration_type]
|
|
51
|
+
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
|
|
52
|
+
|
|
53
|
+
url = base_url + REFUND_TRANSACTION_ENDPOINT.gsub(':token', token)
|
|
54
|
+
headers = webpay_headers(commerce_code: commerce_code, api_key: api_key)
|
|
55
|
+
body = {amount: amount}
|
|
56
|
+
resp = http_post(uri_string: url, body: body, headers: headers)
|
|
57
|
+
body = JSON.parse(resp.body)
|
|
58
|
+
return ::Transbank::Webpay::WebpayPlus::TransactionRefundResponse.new(body) if resp.kind_of? Net::HTTPSuccess
|
|
59
|
+
raise Errors::TransactionRefundError.new(body['error_message'], resp.code)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def status(token:, options: nil)
|
|
63
|
+
api_key = options&.api_key || default_integration_params[:api_key]
|
|
64
|
+
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
|
|
65
|
+
integration_type = options&.integration_type || default_integration_params[:integration_type]
|
|
66
|
+
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
|
|
67
|
+
|
|
68
|
+
url = base_url + "#{TRANSACTION_STATUS_ENDPOINT}/#{token}"
|
|
69
|
+
headers = webpay_headers(commerce_code: commerce_code, api_key: api_key)
|
|
70
|
+
resp = http_get(uri_string: url, headers: headers)
|
|
71
|
+
body = JSON.parse(resp.body)
|
|
72
|
+
return ::Transbank::Webpay::WebpayPlus::TransactionStatusResponse.new(body) if resp.kind_of? Net::HTTPSuccess
|
|
73
|
+
raise Errors::TransactionStatusError.new(body['error_message'], resp.code)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def capture(token:, buy_order:, authorization_code:, capture_amount:, options: nil)
|
|
77
|
+
api_key = options&.api_key || default_integration_params[:api_key]
|
|
78
|
+
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
|
|
79
|
+
integration_type = options&.integration_type || default_integration_params[:integration_type]
|
|
80
|
+
base_url = integration_type.nil? ? WebpayPlus::Base::integration_type[:TEST] : WebpayPlus::Base.integration_type_url(integration_type)
|
|
81
|
+
|
|
82
|
+
url = base_url + TRANSACTION_CAPTURE_ENDPOINT.gsub(':token', token)
|
|
83
|
+
headers = webpay_headers(commerce_code: commerce_code, api_key: api_key)
|
|
84
|
+
body = {
|
|
85
|
+
buy_order: buy_order,
|
|
86
|
+
authorization_code: authorization_code,
|
|
87
|
+
capture_amount: capture_amount
|
|
88
|
+
}
|
|
89
|
+
resp = http_put(uri_string: url, body: body, headers: headers)
|
|
90
|
+
body = JSON.parse(resp.body)
|
|
91
|
+
return ::Transbank::Webpay::WebpayPlus::TransactionCaptureResponse.new(body) if resp.kind_of? Net::HTTPSuccess
|
|
92
|
+
raise Errors::TransactionCaptureError.new(body['error_message'], resp.code)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def default_integration_params
|
|
96
|
+
{
|
|
97
|
+
api_key: WebpayPlus::Base.api_key,
|
|
98
|
+
commerce_code: WebpayPlus::Base::commerce_code,
|
|
99
|
+
integration_type: WebpayPlus::Base::integration_type,
|
|
100
|
+
base_url: WebpayPlus::Base::current_integration_type_url
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
module Errors
|
|
5
|
+
class TransactionCaptureError < ::Transbank::Webpay::Errors::WebpayError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(message, code)
|
|
8
|
+
@code = code
|
|
9
|
+
super(message, code)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'transbank/sdk/webpay/webpay_plus/deferred/errors/transaction_capture_error'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
class TransactionCaptureResponse
|
|
5
|
+
|
|
6
|
+
FIELDS =
|
|
7
|
+
[:token,
|
|
8
|
+
:authorization_code,
|
|
9
|
+
:authorization_date,
|
|
10
|
+
:captured_amount,
|
|
11
|
+
:response_code]
|
|
12
|
+
|
|
13
|
+
attr_accessor *FIELDS
|
|
14
|
+
|
|
15
|
+
def initialize(json)
|
|
16
|
+
FIELDS.each {|field| send("#{field}=", json["#{field}"]) }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
data/lib/transbank/sdk/webpay/webpay_plus/deferred/responses/webpay_plus_deferred_responses.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'transbank/sdk/webpay/webpay_plus/deferred/responses/transaction_capture_response'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
module Errors
|
|
5
|
+
class TransactionCommitError < ::Transbank::Webpay::Errors::WebpayError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(message, code)
|
|
8
|
+
@code = code
|
|
9
|
+
super(message, code)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
module Errors
|
|
5
|
+
class TransactionCreateError < ::Transbank::Webpay::Errors::WebpayError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(message, code)
|
|
8
|
+
@code = code
|
|
9
|
+
super(message, code)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
module Errors
|
|
5
|
+
class TransactionRefundError < ::Transbank::Webpay::Errors::WebpayError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(message, code)
|
|
8
|
+
@code = code
|
|
9
|
+
super(message, code)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Transbank
|
|
2
|
+
module Webpay
|
|
3
|
+
module WebpayPlus
|
|
4
|
+
module Errors
|
|
5
|
+
class TransactionStatusError < ::Transbank::Webpay::Errors::WebpayError
|
|
6
|
+
attr_reader :code
|
|
7
|
+
def initialize(message, code)
|
|
8
|
+
@code = code
|
|
9
|
+
super(message, code)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'transbank/sdk/webpay/webpay_plus/errors/transaction_create_error'
|
|
2
|
+
require 'transbank/sdk/webpay/webpay_plus/errors/transaction_commit_error'
|
|
3
|
+
require 'transbank/sdk/webpay/webpay_plus/errors/transaction_status_error'
|
|
4
|
+
require 'transbank/sdk/webpay/webpay_plus/errors/transaction_refund_error'
|
|
5
|
+
|
|
6
|
+
module Transbank
|
|
7
|
+
module Webpay
|
|
8
|
+
module WebpayPlus
|
|
9
|
+
module Errors
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|