Skip to content

Commit

Permalink
PayU Latam: Add Cabal card
Browse files Browse the repository at this point in the history
Adds the Cabal card to the PayU Latam gateway, including adding new
remote and unit tests.

CE-94 / CE-101

Unit:
31 tests, 117 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed

Remote:
33 tests, 80 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions,
0 notifications
100% passed
  • Loading branch information
leila-alderman committed Sep 4, 2019
1 parent 487399b commit 5e46ebd
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Global Collect: Add Cabal card [leila-alderman] #3310
* WorldPay: Add Cabal card [leila-alderman] #3316
* Decidir: Add Cabal card [leila-alderman] #3322
* PayU Latam: Add Cabal card [leila-alderman] #3324

== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
Expand Down
5 changes: 3 additions & 2 deletions lib/active_merchant/billing/gateways/payu_latam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ class PayuLatamGateway < Gateway
self.supported_countries = ['AR', 'BR', 'CL', 'CO', 'MX', 'PA', 'PE']
self.default_currency = 'USD'
self.money_format = :dollars
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja]
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :naranja, :cabal]

BRAND_MAP = {
'visa' => 'VISA',
'master' => 'MASTERCARD',
'american_express' => 'AMEX',
'diners_club' => 'DINERS',
'naranja' => 'NARANJA'
'naranja' => 'NARANJA',
'cabal' => 'CABAL'
}

MINIMUMS = {
Expand Down
22 changes: 22 additions & 0 deletions test/remote/gateways/remote_payu_latam_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def setup
@declined_card = credit_card('4097440000000004', verification_value: '444', first_name: 'REJECTED', last_name: '')
@pending_card = credit_card('4097440000000004', verification_value: '444', first_name: 'PENDING', last_name: '')
@naranja_credit_card = credit_card('5895620000000002', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'naranja')
@cabal_credit_card = credit_card('5896570000000004', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')
@invalid_cabal_card = credit_card('6271700000000000', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')

@options = {
dni_number: '5415668464654',
Expand Down Expand Up @@ -58,6 +60,13 @@ def test_successful_purchase_with_naranja_card
assert response.test?
end

def test_successful_purchase_with_cabal_card
response = @gateway.purchase(@amount, @cabal_credit_card, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert response.test?
end

def test_successful_purchase_with_specified_language
response = @gateway.purchase(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
Expand Down Expand Up @@ -221,6 +230,12 @@ def test_failed_purchase
assert_equal 'DECLINED', response.params['transactionResponse']['state']
end

def test_failed_purchase_with_cabal_card
response = @gateway.purchase(@amount, @invalid_cabal_card, @options)
assert_failure response
assert_equal 'DECLINED', response.params['transactionResponse']['state']
end

def test_failed_purchase_with_no_options
response = @gateway.purchase(@amount, @declined_card, {})
assert_failure response
Expand Down Expand Up @@ -248,6 +263,13 @@ def test_successful_authorize_with_naranja_card
assert_match %r(^\d+\|(\w|-)+$), response.authorization
end

def test_successful_authorize_with_cabal_card
response = @gateway.authorize(@amount, @cabal_credit_card, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert_match %r(^\d+\|(\w|-)+$), response.authorization
end

def test_successful_authorize_with_specified_language
response = @gateway.authorize(@amount, @credit_card, @options.merge(language: 'es'))
assert_success response
Expand Down
82 changes: 82 additions & 0 deletions test/unit/gateways/payu_latam_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def setup
@pending_card = credit_card('4097440000000004', verification_value: '222', first_name: 'PENDING', last_name: '')
@no_cvv_visa_card = credit_card('4097440000000004', verification_value: ' ')
@no_cvv_amex_card = credit_card('4097440000000004', verification_value: ' ', brand: 'american_express')
@cabal_credit_card = credit_card('5896570000000004', :verification_value => '123', :first_name => 'APPROVED', :last_name => '', :brand => 'cabal')

@options = {
dni_number: '5415668464654',
Expand Down Expand Up @@ -57,6 +58,15 @@ def test_successful_purchase_with_specified_language
end.respond_with(successful_purchase_response)
end

def test_successful_purchase_with_cabal_card
@gateway.expects(:ssl_post).returns(successful_purchase_with_cabal_response)

response = @gateway.purchase(@amount, @cabal_credit_card, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert response.test?
end

def test_failed_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)

Expand All @@ -83,6 +93,15 @@ def test_successful_authorize_with_specified_language
end.respond_with(successful_purchase_response)
end

def test_successful_authorize_with_cabal_card
@gateway.expects(:ssl_post).returns(successful_authorize_with_cabal_response)

response = @gateway.authorize(@amount, @cabal_credit_card, @options)
assert_success response
assert_equal 'APPROVED', response.message
assert_match %r(^\d+\|(\w|-)+$), response.authorization
end

def test_failed_authorize
@gateway.expects(:ssl_post).returns(pending_authorize_response)

Expand Down Expand Up @@ -461,6 +480,37 @@ def successful_purchase_response
RESPONSE
end

def successful_purchase_with_cabal_response
<<-RESPONSE
{
"code":"SUCCESS",
"error":null,
"transactionResponse": {
"orderId":846449068,
"transactionId":"34fa1616-f16c-4474-98dc-6163cb05f6d1",
"state":"APPROVED",
"paymentNetworkResponseCode":null,
"paymentNetworkResponseErrorMessage":null,
"trazabilityCode":"00000000",
"authorizationCode":"00000000",
"pendingReason":null,
"responseCode":"APPROVED",
"errorCode":null,
"responseMessage":null,
"transactionDate":null,
"transactionTime":null,
"operationDate":1567524354749,
"referenceQuestionnaire":null,
"extraParameters": {
"PAYMENT_WAY_ID":"28",
"BANK_REFERENCED_CODE":"DEBIT"
},
"additionalInfo":null
}
}
RESPONSE
end

def failed_purchase_response
<<-RESPONSE
{
Expand Down Expand Up @@ -514,6 +564,38 @@ def successful_authorize_response
RESPONSE
end

def successful_authorize_with_cabal_response
<<-RESPONSE
{
"code":"SUCCESS",
"error":null,
"transactionResponse": {
"orderId":846449155,
"transactionId":"c15e6015-87c2-4db9-9100-894bf5564330",
"state":"APPROVED",
"paymentNetworkResponseCode":null,
"paymentNetworkResponseErrorMessage":null,
"trazabilityCode":"00000000",
"authorizationCode":"00000000",
"pendingReason":null,
"responseCode":"APPROVED",
"errorCode":null,
"responseMessage":null,
"transactionDate":null,
"transactionTime":null,
"operationDate":1567524806987,
"referenceQuestionnaire":null,
"extraParameters": {
"PAYMENT_WAY_ID":"28",
"BANK_REFERENCED_CODE":"DEBIT"
},
"additionalInfo":null
}
}
RESPONSE
end

def pending_authorize_response
<<-RESPONSE
{
Expand Down

0 comments on commit 5e46ebd

Please sign in to comment.