-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plexo: Add support to NetworkToken payments
SER-140 adding support to make purchase, authorize transaction using network tokens in plexo gateway Test summary: Local: 5910 tests, 79650 assertions, 0 failures, 17 errors, 0 pendings, 0 omissions, 0 notifications 99.7124% passed Unit: 25 tests, 134 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed Remote: 32 tests, 36 assertions, 21 failures, 3 errors, 0 pendings, 3 omissions, 0 notifications 17.2414% passed
- Loading branch information
Showing
4 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,15 @@ def setup | |
@amount = 100 | ||
@credit_card = credit_card('5555555555554444', month: '12', year: '2024', verification_value: '111', first_name: 'Santiago', last_name: 'Navatta') | ||
@declined_card = credit_card('5555555555554445') | ||
@network_token_credit_card = ActiveMerchant::Billing::NetworkTokenizationCreditCard.new({ | ||
first_name: 'Santiago', last_name: 'Navatta', | ||
brand: 'Mastercard', | ||
payment_cryptogram: 'UnVBR0RlYm42S2UzYWJKeWJBdWQ=', | ||
number: '5555555555554444', | ||
source: :network_token, | ||
month: '12', | ||
year: 2020 | ||
}) | ||
@options = { | ||
email: '[email protected]', | ||
ip: '127.0.0.1', | ||
|
@@ -329,6 +338,23 @@ def test_scrub | |
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed | ||
end | ||
|
||
def test_purchase_with_network_token | ||
purchase = stub_comms do | ||
@gateway.purchase(@amount, @network_token_credit_card, @options) | ||
end.check_request do |_endpoint, data, _headers| | ||
request = JSON.parse(data) | ||
assert_equal request['Amount']['Currency'], 'UYU' | ||
assert_equal request['Amount']['Details']['TipAmount'], '5' | ||
assert_equal request['Flow'], 'direct' | ||
assert_equal @network_token_credit_card.number, request['paymentMethod']['Card']['Number'] | ||
assert_equal @network_token_credit_card.payment_cryptogram, request['paymentMethod']['Card']['Cryptogram'] | ||
assert_equal @network_token_credit_card.first_name, request['paymentMethod']['Card']['Cardholder']['FirstName'] | ||
end.respond_with(successful_network_token_response) | ||
|
||
assert_success purchase | ||
assert_equal 'You have been mocked.', purchase.message | ||
end | ||
|
||
private | ||
|
||
def pre_scrubbed | ||
|
@@ -917,4 +943,132 @@ def failed_verify_response | |
} | ||
RESPONSE | ||
end | ||
|
||
def successful_network_token_response | ||
<<~RESPONSE | ||
{ | ||
"id": "71d4e94a30124a7ba00809c00b7b1149", | ||
"referenceId": "ecca673a4041317aec64e9e823b3c5d9", | ||
"invoiceNumber": "12345abcde", | ||
"status": "approved", | ||
"flow": "direct", | ||
"processingMethod": "api", | ||
"browserDetails": { | ||
"ipAddress": "127.0.0.1" | ||
}, | ||
"createdAt": "2024-05-21T20:18:33.072Z", | ||
"updatedAt": "2024-05-21T20:18:33.3896406Z", | ||
"processedAt": "2024-05-21T20:18:33.3896407Z", | ||
"merchant": { | ||
"id": 3243, | ||
"name": "spreedly", | ||
"settings": { | ||
"merchantIdentificationNumber": "98001456", | ||
"metadata": { | ||
"paymentProcessorId": "fiserv" | ||
}, | ||
"paymentProcessor": { | ||
"id": 4, | ||
"acquirer": "fiserv" | ||
} | ||
}, | ||
"clientId": 221 | ||
}, | ||
"client": { | ||
"id": 221, | ||
"name": "Spreedly", | ||
"owner": "PLEXO" | ||
}, | ||
"paymentMethod": { | ||
"id": "mastercard", | ||
"legacyId": 4, | ||
"name": "MASTERCARD", | ||
"type": "card", | ||
"card": { | ||
"name": "555555XXXXXX4444", | ||
"bin": "555555", | ||
"last4": "4444", | ||
"expMonth": 12, | ||
"expYear": 20, | ||
"cardholder": { | ||
"firstName": "Santiago", | ||
"lastName": "Navatta", | ||
"email": "[email protected]", | ||
"identification": { | ||
"type": 1, | ||
"value": "123456" | ||
}, | ||
"billingAddress": { | ||
"city": "Ottawa", | ||
"country": "CA", | ||
"line1": "456 My Street", | ||
"line2": "Apt 1", | ||
"postalCode": "K1C2N6", | ||
"state": "ON" | ||
} | ||
}, | ||
"type": "prepaid", | ||
"origin": "uruguay", | ||
"token": "116d03bef91f4e0e8531af47ed34f690", | ||
"issuer": { | ||
"id": 21289, | ||
"name": "", | ||
"shortName": "" | ||
}, | ||
"tokenization": { | ||
"type": "temporal" | ||
} | ||
}, | ||
"processor": { | ||
"id": 4, | ||
"acquirer": "fiserv" | ||
} | ||
}, | ||
"installments": 1, | ||
"amount": { | ||
"currency": "UYU", | ||
"total": 1, | ||
"details": { | ||
"tax": { | ||
"type": "none", | ||
"amount": 0 | ||
}, | ||
"taxedAmount": 0, | ||
"tipAmount": 5 | ||
} | ||
}, | ||
"items": [ | ||
{ | ||
"referenceId": "a6117dae92648552eb83a4ad0548833a", | ||
"name": "prueba", | ||
"description": "prueba desc", | ||
"quantity": 1, | ||
"price": 100, | ||
"discount": 0, | ||
"metadata": {} | ||
} | ||
], | ||
"metadata": {}, | ||
"transactions": [ | ||
{ | ||
"id": "664d019985707cbcfc11f0b2", | ||
"parentId": "71d4e94a30124a7ba00809c00b7b1149", | ||
"traceId": "c7b07c9c-d3c3-466b-8185-973321c6ab70", | ||
"referenceId": "ecca673a4041317aec64e9e823b3c5d9", | ||
"type": "purchase", | ||
"status": "approved", | ||
"createdAt": "2024-05-21T20:18:33.3896404Z", | ||
"processedAt": "2024-05-21T20:18:33.3896397Z", | ||
"resultCode": "0", | ||
"resultMessage": "You have been mocked.", | ||
"authorization": "123456", | ||
"ticket": "02bbae8109fd4ceca0838628692486c6", | ||
"metadata": {}, | ||
"amount": 1 | ||
} | ||
], | ||
"actions": [] | ||
} | ||
RESPONSE | ||
end | ||
end |