diff --git a/lib/active_merchant/billing/gateways/datatrans.rb b/lib/active_merchant/billing/gateways/datatrans.rb index c4b53a4586c..360bfbacedd 100644 --- a/lib/active_merchant/billing/gateways/datatrans.rb +++ b/lib/active_merchant/billing/gateways/datatrans.rb @@ -110,7 +110,7 @@ def scrub(transcript) def add_payment_method(post, payment_method) case payment_method when String - token, exp_month, exp_year = payment_method.split('|')[2].split('-') + token, exp_month, exp_year = payment_method.split('|')[2..4] card = { type: 'ALIAS', alias: token, @@ -250,9 +250,9 @@ def success_from(action, response) end def authorization_from(response, action, options) - string = [response.dig('responses', 0, 'alias'), options[:expiry_month], options[:expiry_year]].join('-') if action == 'tokenize' + token_array = [response.dig('responses', 0, 'alias'), options[:expiry_month], options[:expiry_year]].join('|') if action == 'tokenize' - auth = [response['transactionId'], response['acquirerAuthorizationCode'], string].join('|') + auth = [response['transactionId'], response['acquirerAuthorizationCode'], token_array].join('|') return auth unless auth == '||' end diff --git a/test/unit/gateways/datatrans_test.rb b/test/unit/gateways/datatrans_test.rb index e66f9cd6ccd..0c249bf6777 100644 --- a/test/unit/gateways/datatrans_test.rb +++ b/test/unit/gateways/datatrans_test.rb @@ -325,9 +325,9 @@ def test_authorization_from assert_equal '|9248|', @gateway.send(:authorization_from, { 'acquirerAuthorizationCode' => '9248' }, '', {}) assert_equal nil, @gateway.send(:authorization_from, {}, '', {}) # tes for store - assert_equal '||any_alias-any_month-any_year', @gateway.send(:authorization_from, { 'responses' => [{ 'alias' => 'any_alias' }] }, 'tokenize', { expiry_month: 'any_month', expiry_year: 'any_year' }) + assert_equal '||any_alias|any_month|any_year', @gateway.send(:authorization_from, { 'responses' => [{ 'alias' => 'any_alias' }] }, 'tokenize', { expiry_month: 'any_month', expiry_year: 'any_year' }) # handle nil responses or missing keys - assert_equal '||-any_month-any_year', @gateway.send(:authorization_from, {}, 'tokenize', { expiry_month: 'any_month', expiry_year: 'any_year' }) + assert_equal '|||any_month|any_year', @gateway.send(:authorization_from, {}, 'tokenize', { expiry_month: 'any_month', expiry_year: 'any_year' }) end def test_parse