From 777ab2721f740950b8db97f23dd096af1c507017 Mon Sep 17 00:00:00 2001 From: "Hector E. Gomez Morales" Date: Wed, 4 May 2016 18:33:42 -0500 Subject: [PATCH] Add test for unsuccesssful verification and fraud. --- .../fraudulent_purchase/fails.yml | 105 +++++++++++++++++ .../unsuccessful_card_verification/fails.yml | 106 ++++++++++++++++++ .../solidus/gateway/braintree_gateway_spec.rb | 20 ++++ 3 files changed, 231 insertions(+) create mode 100644 spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/fraudulent_purchase/fails.yml create mode 100644 spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/unsuccessful_card_verification/fails.yml diff --git a/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/fraudulent_purchase/fails.yml b/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/fraudulent_purchase/fails.yml new file mode 100644 index 00000000..7b2a8752 --- /dev/null +++ b/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/fraudulent_purchase/fails.yml @@ -0,0 +1,105 @@ +--- +http_interactions: +- request: + method: post + uri: https://ym9djwqpkxbv3xzt:4ghghkyp2yy6yqc8@api.sandbox.braintreegateway.com/merchants/zbn5yzq9t7wmwx42/customers + body: + encoding: UTF-8 + string: | + + + Card + Holder + mohamed_moore@mayert.us + + Card Holder + + John + Doe + 10 Lovely Street + Northwest + Herndon + AL + US + 66086-5882 + + fake-gateway-rejected-fraud-nonce + + true + + + + + headers: + Accept-Encoding: + - gzip + Accept: + - application/xml + User-Agent: + - Braintree Ruby Gem 2.60.0 + X-Apiversion: + - '4' + Content-Type: + - application/xml + response: + status: + code: 422 + message: Unprocessable Entity + headers: + Date: + - Wed, 04 May 2016 23:13:23 GMT + Content-Type: + - application/xml; charset=utf-8 + Transfer-Encoding: + - chunked + X-Frame-Options: + - SAMEORIGIN + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Authentication: + - basic_auth + X-User: + - s8282g6qcjgm2dfk + Vary: + - Accept-Encoding + Content-Encoding: + - gzip + Cache-Control: + - no-cache + X-Request-Id: + - 059ed4fc-ee3b-4088-94a8-9a6ec84044c7 + X-Runtime: + - '0.252607' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIABOCKlcAA5xWS3PbNhC++1dwdGoPCEm9rHpoJpl20kwn00MT99BLZkWs + RMQkwACgHPbXdwk+JVKNnRvx7bfYxT4Zvf6WZ94JtRFK3i/CV8HCQ5koLuTx + fvHw6R3bLV7HNxEUgqHWSjONplDSYHzjeZGDTP3ZHzxbFXi/AK2hWviO5Q+0 + qAANeaeRlMaqHHVzJOAgtLFMQo7xr6B55I+AjpNBh7xXGUcd+QPScTAHkcW5 + Sgnkn3OlNL7JoUJtX5WG/HHijpxo5MKyhAx2WI3SMXUGBn+8zuKlcFDbiyyj + 2DHgnCJlBsn56/5QqZx73cULf1M48zxHMlYj2t5OGHgf1AmzyvvoBJF/QRjr + 4jeLkiPvhX8qbdMnNKQ2kZ15phLIhK3i96glV/SEHhnTNB6pnOK3HyK//RxL + E1VKqytGVYYMsiKFZfzwkYI6g4/1CmUsZE4cb7fBbss2u90y8sf4kAj/aiao + BqscpWU52lRxJpVMMD7AI7IjWHyCior8CyaWgnDQULYMMjSnN1yrCktPPQ8Y + dZY4VE1tWV3SJWNk5O1EOeJ4EgkyQ76ThAnuSZHdL+pbmr7qqsq5SF2UpEDO + zfMoupdVTtCo/erXdZ0Z5WQTjhj/3oTD+6sNx53njEV+R7jpnigSsH2eqTbB + liZuo/m5i2Zdk07Qdv/p1E8Tl72p4xGczMXc+T/mqBKexT9vke+qnFdHnRSN + YOjVbVSuyhv1PkWQuFKnVMWmIA/qeE5FjVKhVUK+PSMAM0xLzRw/yEepnqT3 + 08+U4yuc5gYyuvqXb/PbyO/tt100N6GvzbDvzi+aAHkBspot1B+caz80054x + z67PspfMo37muTA8SEHdQA+iejGeOnhvKf/UQcMIHKLVz7GuaabLKrLqEeVs + MPdCxusgCMKwvkeeZ2gdh5ta0B56V+lqVi/x+G9hoNl1zXkIdSG063eWK2nT + OFzWMb4AZ9gVgo6XwTI4ozu0t97OJFYnwo0Utxom6Njbl67pqJTia4lMlvme + RILTUKcRRoMQ1/tlsNvwcLVdJcntOrz9Zb8/bMPwkECy3hwi/6pqXxUaC6D2 + aduu7rkG6AgpQmZTcg0HzgjraBz3wg6M5tgLS03ppCY+lhkV0cjaRDLquXrK + CMgG8gjr3YdKq2zE6YCOIIwp67W6B/k4sM7Qy6JXB1bLoV6XI9tT4RBDxcvE + TcFRGHusW1+TjUZI/WYGtv0L5XS0IscFVV24ZcGGBetPy9VduLpbrv5xV7QK + 7Q1lwV92w6DQbNHzbRj5cz/O/wEAAP//AwAANc9xdQsAAA== + http_version: + recorded_at: Wed, 04 May 2016 23:13:23 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/unsuccessful_card_verification/fails.yml b/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/unsuccessful_card_verification/fails.yml new file mode 100644 index 00000000..d96d247e --- /dev/null +++ b/spec/cassettes/Solidus_Gateway_BraintreeGateway/a_customer_profile/unsuccessful_card_verification/fails.yml @@ -0,0 +1,106 @@ +--- +http_interactions: +- request: + method: post + uri: https://ym9djwqpkxbv3xzt:4ghghkyp2yy6yqc8@api.sandbox.braintreegateway.com/merchants/zbn5yzq9t7wmwx42/customers + body: + encoding: UTF-8 + string: | + + + Card + Holder + alfredo@carroll.com + + Card Holder + + John + Doe + 10 Lovely Street + Northwest + Herndon + AL + US + 31456 + + fake-processor-declined-visa-nonce + + true + + + + + headers: + Accept-Encoding: + - gzip + Accept: + - application/xml + User-Agent: + - Braintree Ruby Gem 2.60.0 + X-Apiversion: + - '4' + Content-Type: + - application/xml + response: + status: + code: 422 + message: Unprocessable Entity + headers: + Date: + - Wed, 04 May 2016 23:01:13 GMT + Content-Type: + - application/xml; charset=utf-8 + Transfer-Encoding: + - chunked + X-Frame-Options: + - SAMEORIGIN + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + X-Authentication: + - basic_auth + X-User: + - s8282g6qcjgm2dfk + Vary: + - Accept-Encoding + Content-Encoding: + - gzip + Cache-Control: + - no-cache + X-Request-Id: + - 259c91af-a8c8-408d-b7a8-5c1e74982de7 + X-Runtime: + - '1.130491' + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIADl/KlcAA5xWbW/bNhD+nl8h+DtrSXGctFDUFS22YOuCAm06YF8Gmjzb + nCVSIymn+vc7Ui+ULbnL+k28e+54rw+Vvf1WFtERtBFK3i+SV/EiAskUF3J3 + v3j68jO5W7zNrzJaCQJaK000mEpJA/lVFGVeZNzncIhsU8H9gmpNm8XSo5YB + llVU07K3YLWxqgTdHlGwFdpYImkJ+XuqebYcCXpMQXvJgyo46GwZJD0GSiqK + nBZbDVz9xDAYVRSvmCoxFq/qgQwBwhJE8F7mpHjce+chlqi/7VwZzDaiKLBu + hHKOVTJBc5rZr2ov5zI7y+6DgpnUPMhYDWCHe5I4+qiOUDTRZ6/IlmeAsS18 + syA58EH5qLTdP4NBs4nuJDLFaCFskz+AllxhCoNkDNOww1HK333Mlt3nWMtU + La1uCE4YEFpUe5rmT5+xqDPysV2ljKWFV+fXyepmnS3HotCD5cUm4Og1JUhL + SrB7xYlUkkG+pQcglVYMsTjdHBhaYwWOwtAWgjfNGQa/qrKY5mmxcKPEtmnn + yuoanYwlo3AnxhmHo2BADAaEGiJ4JEVxv3Be2n3qJ0rTmmNMmu0pBjePw8qe + TziKRmvnsus3MivxTrpzoxc9KosTLxUOfC+96vMSjNqhsTiM1NYmH2r4V19D + N4Ze1S378TiQR9u13zGUibAF06M54xuvnabokaNRmF7xfUBwcroz836+i2ld + 7aiFZ9qg7m9grkz4RY2SM6EPvaPMzz/2MDcV3uBqPlW1RmFWT29P4zjGZl7Q + XrS1uPNn/b6Ean1gIK93/O75NlsOMXU7N0fjl8juP4kOqaKsqGxmp/oHCfCH + yO8FxHeZ9F5IXAMv+go8SWGBYy44SiZS2+gdjgMuXaDJUKiB8Potmz5omVUH + mJk/3ziZr3BwksT5kafNWeVJktx0rVmFUNE1cY98/hU5sn0P23OociW0pwhS + Kmn3eZK68p4JZ9ANUI2DnMYncC8dbu+4i7geeBbyz8dEOo72/z7lWS3FPzUQ + WZcbVAmO5I+sh4TJ6ZrdAkvXt3cbvl3fpenreI3nOOV8m6yQ8i6aDgOhoaK4 + OU/yINWzdOvWCnrAHmhh9xgaBMxI1sM4bIQNiPY4KGuN7cT93dUFDtHotolm + tG6OdAQtAngkG8KnjfuXGoXfCXqAMKZ27++GykNAnUjPh15tidNT96yO7p4q + Qw0Vr5knxVEZB1n/zE1ePpS4nAm13V8qx6MVJSxw6pI1iW9IvPqSXr+JkzdJ + +qd30Rl0HuqKv9zDNXoIBp0HLcyBoIyGivH80+OnD/H1H799fXj/S+BV32Um + jKeWChM8gmt0J+myPPHX/WYMDzS+WjM/7v8CAAD//wMANaxU+fULAAA= + http_version: + recorded_at: Wed, 04 May 2016 23:01:12 GMT +recorded_with: VCR 3.0.1 diff --git a/spec/solidus/gateway/braintree_gateway_spec.rb b/spec/solidus/gateway/braintree_gateway_spec.rb index 5b5c332e..5fc3c3ef 100644 --- a/spec/solidus/gateway/braintree_gateway_spec.rb +++ b/spec/solidus/gateway/braintree_gateway_spec.rb @@ -40,6 +40,26 @@ end end + context 'unsuccessful card verification' do + let(:nonce) { Braintree::Test::Nonce::ProcessorDeclinedVisa } + + it 'fails' do + expect{ + payment_method.create_profile(payment) + }.to raise_error(Spree::Core::GatewayError, 'Do Not Honor') + end + end + + context 'fraudulent purchase' do + let(:nonce) { Braintree::Test::Nonce::GatewayRejectedFraud } + + it 'fails' do + expect{ + payment_method.create_profile(payment) + }.to raise_error(Spree::Core::GatewayError, 'Gateway Rejected: fraud') + end + end + context 'payment has associated device_data' do it 'sends it to Braintree' do payment = FactoryGirl.build(:payment,