From 47ca031684ec111f304d5c24fc79b6ca2679bc56 Mon Sep 17 00:00:00 2001 From: Felipe Fiebig Date: Thu, 3 Dec 2020 15:33:56 -0300 Subject: [PATCH 1/2] Add configure for testing methods --- lib/transbank/sdk/oneclick/{mall => }/base.rb | 6 ++++++ lib/transbank/sdk/oneclick/mall/oneclick_mall.rb | 1 - lib/transbank/sdk/oneclick/oneclick.rb | 7 +++++++ lib/transbank/sdk/webpay/webpay_plus/base.rb | 12 ++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) rename lib/transbank/sdk/oneclick/{mall => }/base.rb (90%) diff --git a/lib/transbank/sdk/oneclick/mall/base.rb b/lib/transbank/sdk/oneclick/base.rb similarity index 90% rename from lib/transbank/sdk/oneclick/mall/base.rb rename to lib/transbank/sdk/oneclick/base.rb index 30dad96..8832967 100644 --- a/lib/transbank/sdk/oneclick/mall/base.rb +++ b/lib/transbank/sdk/oneclick/base.rb @@ -51,6 +51,12 @@ def configure_mall_for_testing @commerce_code = DEFAULT_ONECLICK_MALL_COMMERCE_CODE self.integration_type = :TEST end + + def configure_mall_deferred_for_testing + @api_key = DEFAULT_API_KEY + @commerce_code = DEFAULT_ONECLICK_MALL_DEFERRED_COMMERCE_CODE + self.integration_type = :TEST + end end end end diff --git a/lib/transbank/sdk/oneclick/mall/oneclick_mall.rb b/lib/transbank/sdk/oneclick/mall/oneclick_mall.rb index 7526b35..77732de 100644 --- a/lib/transbank/sdk/oneclick/mall/oneclick_mall.rb +++ b/lib/transbank/sdk/oneclick/mall/oneclick_mall.rb @@ -1,5 +1,4 @@ require 'transbank/sdk/oneclick/mall/errors/oneclick_mall_errors' require 'transbank/sdk/oneclick/mall/responses/oneclick_mall_responses' -require 'transbank/sdk/oneclick/mall/base' require 'transbank/sdk/oneclick/mall/mall_inscription' require 'transbank/sdk/oneclick/mall/mall_transaction' diff --git a/lib/transbank/sdk/oneclick/oneclick.rb b/lib/transbank/sdk/oneclick/oneclick.rb index a14a4eb..096b6b3 100644 --- a/lib/transbank/sdk/oneclick/oneclick.rb +++ b/lib/transbank/sdk/oneclick/oneclick.rb @@ -1,5 +1,12 @@ +require 'transbank/sdk/oneclick/base' require 'transbank/sdk/oneclick/errors/oneclick_error' require 'transbank/sdk/oneclick/inscription/inscription' require 'transbank/sdk/oneclick/mall/oneclick_mall' require 'transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction' require 'transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription' + +module Transbank + module Webpay + module Oneclick; end + end +end diff --git a/lib/transbank/sdk/webpay/webpay_plus/base.rb b/lib/transbank/sdk/webpay/webpay_plus/base.rb index b1d119c..d2eccb4 100644 --- a/lib/transbank/sdk/webpay/webpay_plus/base.rb +++ b/lib/transbank/sdk/webpay/webpay_plus/base.rb @@ -55,6 +55,18 @@ def configure_mall_for_testing @commerce_code = DEFAULT_MALL_COMMERCE_CODE self.integration_type = :TEST end + + def configure_deferred_for_testing + @api_key = DEFAULT_API_KEY + @commerce_code = DEFAULT_DEFERRED_COMMERCE_CODE + self.integration_type = :TEST + end + + def configure_mall_deferred_for_testing + @api_key = DEFAULT_API_KEY + @commerce_code = DEFAULT_MALL_DEFERRED_COMMERCE_CODE + self.integration_type = :TEST + end end end end From f092ef8c93066f2e8e4dfb7e79de218b1a246c2d Mon Sep 17 00:00:00 2001 From: Felipe Fiebig Date: Thu, 3 Dec 2020 15:34:14 -0300 Subject: [PATCH 2/2] Fix the way products get their configured options --- lib/transbank/sdk/oneclick/mall/mall_inscription.rb | 4 ++-- lib/transbank/sdk/oneclick/mall/mall_transaction.rb | 4 ++-- .../sdk/oneclick/mall_deferred/mall_deferred_inscription.rb | 4 ++-- .../sdk/oneclick/mall_deferred/mall_deferred_transaction.rb | 4 ++-- lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb | 4 ++-- lib/transbank/sdk/patpass/patpass_comercio/inscription.rb | 4 ++-- .../sdk/transaccion_completa/mall/mall_transaction.rb | 4 ++-- lib/transbank/sdk/transaccion_completa/transaction.rb | 4 ++-- .../sdk/webpay/webpay_plus/deferred/deferred_transaction.rb | 4 ++-- lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb | 4 ++-- .../webpay_plus/mall_deferred/mall_deferred_transaction.rb | 4 ++-- lib/transbank/sdk/webpay/webpay_plus/transaction.rb | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/transbank/sdk/oneclick/mall/mall_inscription.rb b/lib/transbank/sdk/oneclick/mall/mall_inscription.rb index 8b523a5..d8c6f4f 100644 --- a/lib/transbank/sdk/oneclick/mall/mall_inscription.rb +++ b/lib/transbank/sdk/oneclick/mall/mall_inscription.rb @@ -60,8 +60,8 @@ def delete(tbk_user:, user_name:, options: nil) def default_integration_params { - api_key: Oneclick::Base::DEFAULT_API_KEY, - commerce_code: Oneclick::Base::DEFAULT_ONECLICK_MALL_COMMERCE_CODE, + api_key: Oneclick::Base.api_key, + commerce_code: Oneclick::Base.commerce_code, integration_type: Oneclick::Base::integration_type, base_url: Oneclick::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/oneclick/mall/mall_transaction.rb b/lib/transbank/sdk/oneclick/mall/mall_transaction.rb index 9734cc4..e08207e 100644 --- a/lib/transbank/sdk/oneclick/mall/mall_transaction.rb +++ b/lib/transbank/sdk/oneclick/mall/mall_transaction.rb @@ -84,8 +84,8 @@ def refund(buy_order:, child_commerce_code:, child_buy_order:, amount:, def default_integration_params { - api_key: Oneclick::Base::DEFAULT_API_KEY, - commerce_code: Oneclick::Base::DEFAULT_ONECLICK_MALL_COMMERCE_CODE, + api_key: Oneclick::Base.api_key, + commerce_code: Oneclick::Base.commerce_code, integration_type: Oneclick::Base::integration_type, base_url: Oneclick::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription.rb b/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription.rb index 15785ab..ebaaa23 100644 --- a/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription.rb +++ b/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_inscription.rb @@ -7,8 +7,8 @@ class MallDeferredInscription < Transbank::Webpay::Oneclick::MallInscription class << self def default_integration_params { - api_key: Oneclick::Base::DEFAULT_API_KEY, - commerce_code: Oneclick::Base::DEFAULT_ONECLICK_MALL_DEFERRED_COMMERCE_CODE, + api_key: Oneclick::Base.api_key, + commerce_code: Oneclick::Base.commerce_code, integration_type: Oneclick::Base::integration_type, base_url: Oneclick::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb b/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb index 91e3a73..58d4601 100644 --- a/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb +++ b/lib/transbank/sdk/oneclick/mall_deferred/mall_deferred_transaction.rb @@ -29,8 +29,8 @@ def capture(child_commerce_code:, child_buy_order:, authorization_code:, amount: def default_integration_params { - api_key: Oneclick::Base::DEFAULT_API_KEY, - commerce_code: Oneclick::Base::DEFAULT_ONECLICK_MALL_DEFERRED_COMMERCE_CODE, + api_key: Oneclick::Base.api_key, + commerce_code: Oneclick::Base.commerce_code, integration_type: Oneclick::Base::integration_type, base_url: Oneclick::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb b/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb index 8b7a788..dad7ff5 100644 --- a/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb +++ b/lib/transbank/sdk/patpass/patpass_by_webpay/transaction.rb @@ -64,8 +64,8 @@ def status(token:, options: nil) def default_integration_params { - api_key: PatpassByWebpay::Base::DEFAULT_API_KEY, - commerce_code: PatpassByWebpay::Base::DEFAULT_COMMERCE_CODE, + api_key: PatpassByWebpay::Base.api_key, + commerce_code: PatpassByWebpay::Base.commerce_code, base_url: PatpassByWebpay::Base::current_integration_type_url } end diff --git a/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb b/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb index ff242b2..fc09439 100644 --- a/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb +++ b/lib/transbank/sdk/patpass/patpass_comercio/inscription.rb @@ -66,8 +66,8 @@ def status(token: ,options: nil) def default_integration_params { - api_key: Patpass::PatpassComercio::Base::DEFAULT_API_KEY, - commerce_code: Patpass::PatpassComercio::Base::DEFAULT_COMMERCE_CODE, + api_key: Patpass::PatpassComercio::Base.api_key, + commerce_code: Patpass::PatpassComercio::Base.commerce_code, integration_type: Patpass::PatpassComercio::Base::integration_type, base_url: Patpass::PatpassComercio::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/transaccion_completa/mall/mall_transaction.rb b/lib/transbank/sdk/transaccion_completa/mall/mall_transaction.rb index 9f9053f..4546145 100644 --- a/lib/transbank/sdk/transaccion_completa/mall/mall_transaction.rb +++ b/lib/transbank/sdk/transaccion_completa/mall/mall_transaction.rb @@ -116,8 +116,8 @@ def refund(token:, child_buy_order:, child_commerce_code:, amount:, options:nil) def default_integration_params { - api_key: TransaccionCompleta::Base::DEFAULT_API_KEY, - commerce_code: TransaccionCompleta::Base::DEFAULT_MALL_COMMERCE_CODE, + api_key: TransaccionCompleta::Base.api_key, + commerce_code: TransaccionCompleta::Base.commerce_code, integration_type: TransaccionCompleta::Base::integration_type, base_url: TransaccionCompleta::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/transaccion_completa/transaction.rb b/lib/transbank/sdk/transaccion_completa/transaction.rb index e98ec14..e5b5cfc 100644 --- a/lib/transbank/sdk/transaccion_completa/transaction.rb +++ b/lib/transbank/sdk/transaccion_completa/transaction.rb @@ -103,8 +103,8 @@ def refund(token:, amount:, options:nil) def default_integration_params { - api_key: TransaccionCompleta::Base::DEFAULT_API_KEY, - commerce_code: TransaccionCompleta::Base::DEFAULT_COMMERCE_CODE, + api_key: TransaccionCompleta::Base.api_key, + commerce_code: TransaccionCompleta::Base.commerce_code, integration_type: TransaccionCompleta::Base::integration_type, base_url: TransaccionCompleta::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/webpay/webpay_plus/deferred/deferred_transaction.rb b/lib/transbank/sdk/webpay/webpay_plus/deferred/deferred_transaction.rb index 7def109..324530d 100644 --- a/lib/transbank/sdk/webpay/webpay_plus/deferred/deferred_transaction.rb +++ b/lib/transbank/sdk/webpay/webpay_plus/deferred/deferred_transaction.rb @@ -94,8 +94,8 @@ def capture(token:, buy_order:, authorization_code:, capture_amount:, options: n def default_integration_params { - api_key: WebpayPlus::Base::DEFAULT_API_KEY, - commerce_code: WebpayPlus::Base::DEFAULT_DEFERRED_COMMERCE_CODE, + api_key: WebpayPlus::Base.api_key, + commerce_code: WebpayPlus::Base::commerce_code, integration_type: WebpayPlus::Base::integration_type, base_url: WebpayPlus::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb b/lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb index 07bd2b5..71e89b4 100644 --- a/lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb +++ b/lib/transbank/sdk/webpay/webpay_plus/mall/mall_transaction.rb @@ -75,8 +75,8 @@ def status(token:, options: nil) def default_integration_params { - api_key: WebpayPlus::Base::DEFAULT_API_KEY, - commerce_code: WebpayPlus::Base::DEFAULT_MALL_COMMERCE_CODE, + api_key: WebpayPlus::Base.api_key, + commerce_code: WebpayPlus::Base.commerce_code, integration_type: WebpayPlus::Base::integration_type, base_url: WebpayPlus::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb b/lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb index 641b59a..3e2374a 100644 --- a/lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb +++ b/lib/transbank/sdk/webpay/webpay_plus/mall_deferred/mall_deferred_transaction.rb @@ -96,8 +96,8 @@ def capture(token:, child_commerce_code:, buy_order:, authorization_code:, captu def default_integration_params { - api_key: WebpayPlus::Base::DEFAULT_API_KEY, - commerce_code: WebpayPlus::Base::DEFAULT_MALL_DEFERRED_COMMERCE_CODE, + api_key: WebpayPlus::Base.api_key, + commerce_code: WebpayPlus::Base.commerce_code, integration_type: WebpayPlus::Base::integration_type, base_url: WebpayPlus::Base::current_integration_type_url } diff --git a/lib/transbank/sdk/webpay/webpay_plus/transaction.rb b/lib/transbank/sdk/webpay/webpay_plus/transaction.rb index c3ec068..f93786d 100644 --- a/lib/transbank/sdk/webpay/webpay_plus/transaction.rb +++ b/lib/transbank/sdk/webpay/webpay_plus/transaction.rb @@ -75,8 +75,8 @@ def status(token:, options: nil) def default_integration_params { - api_key: WebpayPlus::Base::DEFAULT_API_KEY, - commerce_code: WebpayPlus::Base::DEFAULT_COMMERCE_CODE, + api_key: WebpayPlus::Base.api_key, + commerce_code: WebpayPlus::Base.commerce_code, integration_type: WebpayPlus::Base::integration_type, base_url: WebpayPlus::Base::current_integration_type_url }