diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 7054815fadac..ffd9e33e0b99 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -120,7 +120,7 @@ class CreateSingleAccount extends Command $company_token->company_id = $company->id; $company_token->account_id = $account->id; $company_token->name = 'test token'; - $company_token->token = Str::random(64); + $company_token->token = 'company-token-test'; $company_token->is_system = true; $company_token->save(); diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 4a0d69e5d98e..d2af14ba385c 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -100,11 +100,6 @@ class StripePaymentDriver extends BaseDriver // GatewayType::APPLE_PAY, // TODO:: Missing implementation ]; - // $this->invitation = false - // $this->client doesn't exist - // $this->client->country is relationship? - // Missing Slovenia for Alipay - if ($this->company_gateway->getSofortEnabled() && $this->client && isset($this->client->country) @@ -119,7 +114,7 @@ class StripePaymentDriver extends BaseDriver $types[] = GatewayType::BANK_TRANSFER; } - if ($this->company_gateway->getAchEnabled() + if ($this->company_gateway->getAlipayEnabled() && $this->client && isset($this->client->country) && in_array($this->client->country->iso_3166_3, ['AUS', 'DNK', 'DEU', 'ITA', 'LUX', 'NOR', 'SVN', 'GBR', 'AUT', 'EST', 'GRC', 'JPN', 'MYS', 'PRT', 'ESP', 'USA', 'BEL', 'FIN', 'HKG', 'LVA', 'NLD', 'SGP', 'SWE', 'CAN', 'FRA', 'IRL', 'LTU', 'NZL', 'SVK', 'CHE'])) { diff --git a/cypress.json b/cypress.json index f57c9ce64c18..9741c8963d7e 100644 --- a/cypress.json +++ b/cypress.json @@ -1,8 +1,8 @@ { "video": false, - "baseUrl": "https://localhost:8000/", + "baseUrl": "https://localhost:8080/", "chromeWebSecurity": false, "env": { - "runningEnvironment": "native" + "runningEnvironment": "docker" } } diff --git a/cypress/integration/gateways/authorize.net_credit_card.spec.js b/cypress/integration/gateways/authorize.net_credit_card.spec.js new file mode 100644 index 000000000000..b7d642656f42 --- /dev/null +++ b/cypress/integration/gateways/authorize.net_credit_card.spec.js @@ -0,0 +1,106 @@ +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://opensource.org/licenses/AAL + */ + +describe('Authorize.net: Credit card test', () => { + before(() => { + cy.artisan('migrate:fresh --seed'); + cy.artisan('ninja:create-single-account authorizenet'); + }); + + beforeEach(() => { + cy.viewport('macbook-13'); + cy.wait(5000); + cy.clientLogin(); + }); + + afterEach(() => { + cy.visit('/client/logout').visit('/client/login'); + }); + + it('should pay with new card', function () { + cy.visit('/client/invoices').then((contentWindow) => { + cy.get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); + + cy.get('#card_number').type('4007000000027') + .get('#cardholder_name').type('Invoice Ninja Rocks') + .get('[class=expiry]').type('12/28') + .get('[name=cvc]').type('100'); + + cy.get('#pay-now').click(); + }); + + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/VolejRejNm'); + }); + + it('should pay with new card & save credit card for future use', function () { + cy.visit('/client/invoices').then((contentWindow) => { + cy.get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); + + cy.get('#card_number').type('4007000000027') + .get('#cardholder_name').type('Invoice Ninja Rocks') + .get('[class=expiry]').type('12/28') + .get('[name=cvc]').type('100'); + + cy.get('[name=token-billing-checkbox]').first().check(); + + cy.get('#pay-now').click(); + }); + + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Wpmbk5ezJn'); + }); + + it('should pay with saved card (token)', function () { + cy.visit('/client/invoices') + .get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); + + cy.get('[name=payment-type]').first().check(); + + cy.get('#pay-now').click(); + + cy.wait(2000); + + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Opnel5aKBz'); + }); + + + it('should be able to remove payment method', function () { + cy.visit('/client/payment_methods') + .get('[data-cy=view-payment-method]').click(); + + cy.get('#open-delete-popup').click(); + + cy.get('[data-cy=confirm-payment-removal]').click(); + + cy.url().should('contain', '/client/payment_methods'); + + cy.get('body').contains('Payment method has been successfully removed.'); + }); + + it('should be able to add credit card (standalone)', function () { + cy.visit('/client/payment_methods') + .get('[data-cy=add-payment-method]').click() + .get('[data-cy=add-credit-card-link]').click(); + + cy.get('#card_number').type('4007000000027') + .get('#cardholder_name').type('Invoice Ninja Rocks') + .get('[class=expiry]').type('12/28') + .get('[name=cvc]').type('100'); + + cy.get('#card_button').click(); + + cy.location('pathname', {timeout: 60000}).should('include', '/client/payment_methods'); + }); +}); diff --git a/cypress/integration/client_portal/checkout_credit_card.spec.js b/cypress/integration/gateways/checkout_credit_card.spec.js similarity index 100% rename from cypress/integration/client_portal/checkout_credit_card.spec.js rename to cypress/integration/gateways/checkout_credit_card.spec.js diff --git a/cypress/integration/gateways/stripe_ach.spec.js b/cypress/integration/gateways/stripe_ach.spec.js new file mode 100644 index 000000000000..dc50e0450ffa --- /dev/null +++ b/cypress/integration/gateways/stripe_ach.spec.js @@ -0,0 +1,248 @@ +import axios from 'axios'; + +describe('Stripe: ACH testing', () => { + before(() => { + cy.artisan('migrate:fresh --seed'); + cy.artisan('ninja:create-single-account stripe'); + }); + + beforeEach(() => { + let headers = { + 'X-API-Token': 'company-token-test', + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json; charset=utf-8', + }; + + let gatewaysBody = { + "gateway_key": "d14dd26a37cecc30fdd65700bfb55b23", + "accepted_credit_cards": 0, + "require_shipping_address": true, + "require_billing_address": true, + "require_client_name": false, + "require_client_phone": false, + "require_contact_name": false, + "require_contact_email": false, + "require_cvv": true, + "update_details": true, + "fees_and_limits": { + "1": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "2": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "6": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + } + }, + "system_logs": [], + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"1\",\"enable_sofort\":\"1\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"0\"}", + "token_billing": "off", + "test_mode": true, + "label": "Stripe", + "created_at": 1612791181, + "updated_at": 1612792176, + "archived_at": 0, + "id": "VolejRejNm", + "loadedAt": 1612792176934, + "require_postal_code": false, + "is_deleted": false + }; + let clientBody = { + "group_settings_id": "", + "name": "Batz LLC", + "display_name": "Batz LLC", + "balance": 8323.7, + "credit_balance": 0, + "paid_to_date": 0, + "client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9", + "address1": "45804", + "address2": "47988 Rex Mall", + "city": "New Macberg", + "state": "Florida", + "postal_code": "43089-5809", + "country_id": "840", + "phone": "", + "private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.", + "public_notes": "", + "website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur", + "industry_id": "", + "size_id": "", + "vat_number": "157764830", + "id_number": "", + "number": "0001", + "shipping_address1": "5181", + "shipping_address2": "66797 Jedediah Isle Suite 479", + "shipping_city": "Lake Rosariomouth", + "shipping_state": "Nevada", + "shipping_postal_code": "31693", + "shipping_country_id": "4", + "settings": { + "currency_id": "1" + }, + "last_login": 0, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "contacts": [ + { + "first_name": "Rita", + "last_name": "Pouros", + "email": "user@example.com", + "password": "**********", + "phone": "+1-331-663-8498", + "contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "is_primary": true, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "VolejRejNm" + }, + { + "first_name": "Danika", + "last_name": "Hauck", + "email": "bbrakus@example.net", + "password": "**********", + "phone": "662-968-5275 x48146", + "contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "is_primary": false, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "Wpmbk5ezJn" + } + ], + "activities": [], + "ledger": [], + "gateway_tokens": [], + "documents": [], + "system_logs": [], + "created_at": 1612792539, + "updated_at": 1612792565, + "archived_at": 0, + "id": "VolejRejNm", + "isChanged": true, + "is_deleted": false, + "user_id": "VolejRejNm", + "assigned_user_id": "" + }; + + axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers}) + axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US. + + cy.viewport('macbook-13'); + cy.clientLogin(); + }); + + afterEach(() => { + cy.visit('/client/logout').visit('/client/login'); + }); + + it('should be able to add bank account & verify it', function () { + cy.visit('/client/payment_methods'); + + cy.get('[data-cy=add-payment-method]').click(); + cy.get('[data-cy=add-bank-account-link]').click(); + + cy.get('#account-holder-name').type('Invoice Ninja Rocks'); + cy.get('#country').select('US'); + cy.get('#currency').select('USD'); + cy.get('#routing-number').type('110000000'); + cy.get('#account-number').type('000123456789'); + cy.get('#accept-terms').check(); + + cy.get('#save-button').click(); + + cy.url().should('contain', 'method=2'); + + cy.get('[data-cy=verification-1st]').type('32'); + cy.get('[data-cy=verification-2nd]').type('45'); + + cy.get('#pay-now').click(); + + cy.get('body').contains('Verification completed successfully'); + }); + + it('should be able to pay the invoice', function () { + cy.visit('/client/invoices'); + + cy.get('[data-cy=pay-now]').first().click(); + cy.get('[data-cy=pay-now-dropdown]').click(); + cy.get('[data-cy=pay-with-2]').click(); + + cy.get('[name=payment-type]').first().check(); + + cy.get('#pay-now').click(); + + cy.url().should('contain', '/client/payments/'); + }); + + it('should be able to remove payment method', function () { + cy.visit('/client/payment_methods'); + + cy.get('[data-cy=view-payment-method]').click(); + + cy.get('#open-delete-popup').click(); + + cy.get('[data-cy=confirm-payment-removal]').click(); + + cy.url().should('contain', '/client/payment_methods'); + + cy.get('body').contains('Payment method has been successfully removed.'); + }); +}); diff --git a/cypress/integration/gateways/stripe_alipay.spec.js b/cypress/integration/gateways/stripe_alipay.spec.js new file mode 100644 index 000000000000..16e0d2653ec4 --- /dev/null +++ b/cypress/integration/gateways/stripe_alipay.spec.js @@ -0,0 +1,209 @@ +import axios from "axios"; + +describe('Stripe: Alipay testing', () => { + before(() => { + cy.artisan('migrate:fresh --seed'); + cy.artisan('ninja:create-single-account checkout'); + }); + + beforeEach(() => { + let headers = { + 'X-API-Token': 'company-token-test', + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json; charset=utf-8', + }; + + let gatewaysBody = { + "gateway_key": "d14dd26a37cecc30fdd65700bfb55b23", + "accepted_credit_cards": 0, + "require_shipping_address": true, + "require_billing_address": true, + "require_client_name": false, + "require_client_phone": false, + "require_contact_name": false, + "require_contact_email": false, + "require_cvv": true, + "update_details": true, + "fees_and_limits": { + "1": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "2": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "6": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + } + }, + "system_logs": [], + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"0\",\"enable_sofort\":\"0\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"1\"}", + "token_billing": "off", + "test_mode": true, + "label": "Stripe", + "created_at": 1612791181, + "updated_at": 1612792176, + "archived_at": 0, + "id": "VolejRejNm", + "loadedAt": 1612792176934, + "require_postal_code": false, + "is_deleted": false + }; + let clientBody = { + "group_settings_id": "", + "name": "Batz LLC", + "display_name": "Batz LLC", + "balance": 8323.7, + "credit_balance": 0, + "paid_to_date": 0, + "client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9", + "address1": "45804", + "address2": "47988 Rex Mall", + "city": "New Macberg", + "state": "Florida", + "postal_code": "43089-5809", + "country_id": "840", + "phone": "", + "private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.", + "public_notes": "", + "website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur", + "industry_id": "", + "size_id": "", + "vat_number": "157764830", + "id_number": "", + "number": "0001", + "shipping_address1": "5181", + "shipping_address2": "66797 Jedediah Isle Suite 479", + "shipping_city": "Lake Rosariomouth", + "shipping_state": "Nevada", + "shipping_postal_code": "31693", + "shipping_country_id": "4", + "settings": { + "currency_id": "1" + }, + "last_login": 0, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "contacts": [ + { + "first_name": "Rita", + "last_name": "Pouros", + "email": "user@example.com", + "password": "**********", + "phone": "+1-331-663-8498", + "contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "is_primary": true, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "VolejRejNm" + }, + { + "first_name": "Danika", + "last_name": "Hauck", + "email": "bbrakus@example.net", + "password": "**********", + "phone": "662-968-5275 x48146", + "contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "is_primary": false, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "Wpmbk5ezJn" + } + ], + "activities": [], + "ledger": [], + "gateway_tokens": [], + "documents": [], + "system_logs": [], + "created_at": 1612792539, + "updated_at": 1612792565, + "archived_at": 0, + "id": "VolejRejNm", + "isChanged": true, + "is_deleted": false, + "user_id": "VolejRejNm", + "assigned_user_id": "" + }; + + axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers}) + axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US. + + cy.viewport('macbook-13'); + cy.clientLogin(); + }); + + afterEach(() => { + cy.visit('/client/logout').visit('/client/login'); + }); + + it('should be able to pay using Alipay', function () { + cy.visit('/client/invoices'); + + cy.get('[data-cy=pay-now]').first().click(); + cy.get('[data-cy=pay-now-dropdown]').click(); + cy.get('[data-cy=pay-with-2]').click(); + + cy.get('#pay-now').click(); + + cy.get('.common-ButtonGroup > .common-Button--default').click(); + + cy.url().should('contain', '/client/payments/'); + }); +}); diff --git a/cypress/integration/client_portal/stripe_credit_card.spec.js b/cypress/integration/gateways/stripe_credit_card.spec.js similarity index 60% rename from cypress/integration/client_portal/stripe_credit_card.spec.js rename to cypress/integration/gateways/stripe_credit_card.spec.js index ce80b83becff..ff206248fdc0 100644 --- a/cypress/integration/client_portal/stripe_credit_card.spec.js +++ b/cypress/integration/gateways/stripe_credit_card.spec.js @@ -10,15 +10,14 @@ describe('Stripe: Credit card testing', () => { }); afterEach(() => { - cy.visit('/client/logout'); + cy.visit('/client/logout').visit('/client/login'); }); it('should pay with new card', function () { - cy.visit('/client/invoices'); - - cy.get('[data-cy=pay-now]').first().click(); - cy.get('[data-cy=pay-now-dropdown]').click(); - cy.get('[data-cy=pay-with-0]').click(); + cy.visit('/client/invoices') + .get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); cy.get('#cardholder-name').type('Invoice Ninja Rocks'); cy.getWithinIframe('[name=cardnumber]').type('4242424242424242'); @@ -28,15 +27,14 @@ describe('Stripe: Credit card testing', () => { cy.get('#pay-now').click(); - cy.url().should('contain', '/client/payments/VolejRejNm'); + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/VolejRejNm'); }); it('should pay with new card & save credit card for future use', function () { - cy.visit('/client/invoices'); - - cy.get('[data-cy=pay-now]').first().click(); - cy.get('[data-cy=pay-now-dropdown]').click(); - cy.get('[data-cy=pay-with-0]').click(); + cy.visit('/client/invoices') + .get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); cy.get('#cardholder-name').type('Invoice Ninja Rocks'); cy.getWithinIframe('[name=cardnumber]').type('4242424242424242'); @@ -48,27 +46,25 @@ describe('Stripe: Credit card testing', () => { cy.get('#pay-now').click(); - cy.url().should('contain', '/client/payments/Wpmbk5ezJn'); + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Wpmbk5ezJn'); }); it('should pay with saved card (token)', function () { - cy.visit('/client/invoices'); - - cy.get('[data-cy=pay-now]').first().click(); - cy.get('[data-cy=pay-now-dropdown]').click(); - cy.get('[data-cy=pay-with-0]').click(); + cy.visit('/client/invoices') + .get('[data-cy=pay-now]').first().click() + .get('[data-cy=pay-now-dropdown]').click() + .get('[data-cy=pay-with-0]').click(); cy.get('[name=payment-type]').first().check(); cy.get('#pay-now').click(); - cy.url().should('contain', '/client/payments/Opnel5aKBz'); + cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Opnel5aKBz'); }); it('should be able to remove payment method', function () { - cy.visit('/client/payment_methods'); - - cy.get('[data-cy=view-payment-method]').click(); + cy.visit('/client/payment_methods') + .get('[data-cy=view-payment-method]').click(); cy.get('#open-delete-popup').click(); @@ -80,10 +76,9 @@ describe('Stripe: Credit card testing', () => { }); it('should be able to add credit card (standalone)', function () { - cy.visit('/client/payment_methods'); - - cy.get('[data-cy=add-payment-method]').click(); - cy.get('[data-cy=add-credit-card-link]').click(); + cy.visit('/client/payment_methods') + .get('[data-cy=add-payment-method]').click() + .get('[data-cy=add-credit-card-link]').click(); cy.get('#cardholder-name').type('Invoice Ninja Rocks'); cy.getWithinIframe('[name=cardnumber]').type('4242424242424242'); @@ -93,6 +88,8 @@ describe('Stripe: Credit card testing', () => { cy.get('#authorize-card').click(); - cy.url().should('contain', '/client/payment_methods'); + cy.location('pathname', {timeout: 60000}) + .should('include', '/client/payment_methods') + .get('[data-cy=pm-last4]').contains('**** 4242'); }); }); diff --git a/cypress/integration/gateways/stripe_sofort.spec.js b/cypress/integration/gateways/stripe_sofort.spec.js new file mode 100644 index 000000000000..38073166b97f --- /dev/null +++ b/cypress/integration/gateways/stripe_sofort.spec.js @@ -0,0 +1,209 @@ +import axios from "axios"; + +describe('Stripe: SOFORT testing', () => { + before(() => { + cy.artisan('migrate:fresh --seed'); + cy.artisan('ninja:create-single-account checkout'); + }); + + beforeEach(() => { + let headers = { + 'X-API-Token': 'company-token-test', + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json; charset=utf-8', + }; + + let gatewaysBody = { + "gateway_key": "d14dd26a37cecc30fdd65700bfb55b23", + "accepted_credit_cards": 0, + "require_shipping_address": true, + "require_billing_address": true, + "require_client_name": false, + "require_client_phone": false, + "require_contact_name": false, + "require_contact_email": false, + "require_cvv": true, + "update_details": true, + "fees_and_limits": { + "1": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "2": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + }, + "6": { + "min_limit": -1, + "max_limit": -1, + "fee_amount": 0, + "fee_percent": 0, + "fee_cap": 0, + "fee_tax_rate1": 0, + "fee_tax_name1": "", + "fee_tax_rate2": 0, + "fee_tax_name2": "", + "fee_tax_rate3": 0, + "fee_tax_name3": "", + "adjust_fee_percent": false, + "is_enabled": true + } + }, + "system_logs": [], + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "config": "{\"apiKey\":\"sk_test_Yorqvz45sZWSSUmvCfoKF8e6\",\"publishableKey\":\"pk_test_P1riKDKD0pdNTkHwBWEZ8DR0\",\"enable_ach\":\"1\",\"enable_sofort\":\"1\",\"enable_apple_pay\":\"0\",\"enable_alipay\":\"0\"}", + "token_billing": "off", + "test_mode": true, + "label": "Stripe", + "created_at": 1612791181, + "updated_at": 1612792176, + "archived_at": 0, + "id": "VolejRejNm", + "loadedAt": 1612792176934, + "require_postal_code": false, + "is_deleted": false + }; + let clientBody = { + "group_settings_id": "", + "name": "Batz LLC", + "display_name": "Batz LLC", + "balance": 8323.7, + "credit_balance": 0, + "paid_to_date": 0, + "client_hash": "DxrMypcMdnYJvfebfeoXUi2Iyear6LkNq7Twi0H9", + "address1": "45804", + "address2": "47988 Rex Mall", + "city": "New Macberg", + "state": "Florida", + "postal_code": "43089-5809", + "country_id": "276", + "phone": "", + "private_notes": "Neque libero eos adipisci quae. Non voluptas quaerat ea nisi repudiandae in. Voluptatem error aut est distinctio perspiciatis quis.", + "public_notes": "", + "website": "https://www.wintheiser.com/non-velit-nisi-culpa-sit-optio-omnis-ipsum-pariatur", + "industry_id": "", + "size_id": "", + "vat_number": "157764830", + "id_number": "", + "number": "0001", + "shipping_address1": "5181", + "shipping_address2": "66797 Jedediah Isle Suite 479", + "shipping_city": "Lake Rosariomouth", + "shipping_state": "Nevada", + "shipping_postal_code": "31693", + "shipping_country_id": "4", + "settings": { + "currency_id": "1" + }, + "last_login": 0, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "contacts": [ + { + "first_name": "Rita", + "last_name": "Pouros", + "email": "user@example.com", + "password": "**********", + "phone": "+1-331-663-8498", + "contact_key": "hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "is_primary": true, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/hNQkBU6RM6tG2pwu4J7dCfuq2ZdH6Q8anEvKnyoL", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "VolejRejNm" + }, + { + "first_name": "Danika", + "last_name": "Hauck", + "email": "bbrakus@example.net", + "password": "**********", + "phone": "662-968-5275 x48146", + "contact_key": "4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "is_primary": false, + "send_email": true, + "custom_value1": "", + "custom_value2": "", + "custom_value3": "", + "custom_value4": "", + "last_login": 0, + "link": "https://localhost:8080/client/key_login/4hWqvVUv2bwYIOb25rWmQhbhadnl5yneTzglGZ32", + "created_at": 1612792539, + "updated_at": 1612792539, + "archived_at": 0, + "id": "Wpmbk5ezJn" + } + ], + "activities": [], + "ledger": [], + "gateway_tokens": [], + "documents": [], + "system_logs": [], + "created_at": 1612792539, + "updated_at": 1612792565, + "archived_at": 0, + "id": "VolejRejNm", + "isChanged": true, + "is_deleted": false, + "user_id": "VolejRejNm", + "assigned_user_id": "" + }; + + axios.put('https://localhost:8080/api/v1/company_gateways/VolejRejNm', gatewaysBody, {headers}) + axios.put('https://localhost:8080/api/v1/clients/VolejRejNm', clientBody, {headers}); // Set country to US. + + cy.viewport('macbook-13'); + cy.clientLogin(); + }); + + afterEach(() => { + cy.visit('/client/logout').visit('/client/login'); + }); + + it('should be able to pay using SOFORT', function () { + cy.visit('/client/invoices'); + + cy.get('[data-cy=pay-now]').first().click(); + cy.get('[data-cy=pay-now-dropdown]').click(); + cy.get('[data-cy=pay-with-2]').click(); + + cy.get('#pay-now').click(); + + cy.get('.common-ButtonGroup > .common-Button--default').click(); + + cy.url().should('contain', '/client/payments/'); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 93673ec6ca38..909d7beb0984 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -47,7 +47,7 @@ Cypress.Commands.add('clientLogin', () => { }); }); -Cypress.Commands.add('iframeLoaded', { prevSubject: 'element' }, ($iframe) => { +Cypress.Commands.add('iframeLoaded', {prevSubject: 'element'}, ($iframe) => { const contentWindow = $iframe.prop('contentWindow'); return new Promise((resolve) => { if (contentWindow) { diff --git a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php index f132f9f3dd46..c6216e448402 100644 --- a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php @@ -77,7 +77,7 @@ {{ $payment_method->meta->exp_month}} / {{ $payment_method->meta->exp_year }} @endif - + @isset($payment_method->meta->last4) **** {{ $payment_method->meta->last4 }} @endisset diff --git a/resources/views/portal/ninja2020/gateways/stripe/ach/verify.blade.php b/resources/views/portal/ninja2020/gateways/stripe/ach/verify.blade.php index 380b98584fc7..9cdcf2803c4e 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/ach/verify.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/ach/verify.blade.php @@ -11,15 +11,15 @@ @component('portal.ninja2020.components.general.card-element', ['title' => '#1 ' . ctrans('texts.amount')]) - + @endcomponent @component('portal.ninja2020.components.general.card-element', ['title' => '#2 ' . ctrans('texts.amount')]) - + @endcomponent - + @component('portal.ninja2020.gateways.includes.pay_now', ['type' => 'submit']) {{ ctrans('texts.complete_verification')}} @endcomponent -@endsection \ No newline at end of file +@endsection