diff --git a/cypress.json b/cypress.json index 92e52adf8c0c..e959015b2688 100644 --- a/cypress.json +++ b/cypress.json @@ -1,5 +1,5 @@ { "video": false, - "baseUrl": "http://ninja.test:8000/", + "baseUrl": "http://localhost:8000/", "chromeWebSecurity": false } diff --git a/cypress/integration/client_portal/stripe_credit_card_spec.js b/cypress/integration/client_portal/stripe_credit_card_spec.js new file mode 100644 index 000000000000..0cacbb1bfad4 --- /dev/null +++ b/cypress/integration/client_portal/stripe_credit_card_spec.js @@ -0,0 +1,45 @@ +describe('Stripe Credit Card Payments', () => { + beforeEach(() => cy.clientLogin()); + + it('should be able to add credit card using Stripe', () => { + cy.visit('/client/payment_methods'); + + cy.get('[data-cy=add-payment-method]').click(); + cy.get('[data-cy=add-credit-card-link]').click(); + + cy.get('#cardholder-name').type('Invoice Ninja'); + + cy.getWithinIframe('[name="cardnumber"]').type('4242424242424242'); + cy.getWithinIframe('[name="exp-date"]').type('1230'); + cy.getWithinIframe('[name="cvc"]').type('100'); + cy.getWithinIframe('[name="postal"]').type('12345'); + + cy.get('#card-button').click(); + + cy.get('#errors').should('be.empty'); + + cy.location('pathname').should('eq', '/client/payment_methods'); + }); + + it('should be able to complete payment with added credit card', () => { + cy.visit('/client/invoices'); + + cy.get('#unpaid-checkbox').click(); + + cy.get('[data-cy=pay-now') + .first() + .click(); + + cy.location('pathname').should('eq', '/client/invoices/payment'); + + cy.get('[data-cy=payment-methods-dropdown').click(); + + cy.get('[data-cy=payment-method') + .first() + .click(); + + cy.get('#pay-now-with-token').click(); + + cy.url().should('contain', '/client/payments'); + }); +}); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 67b07104f176..6c784fa9d14c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -28,10 +28,10 @@ Cypress.Commands.add('clientLogin', () => { cy.visit('/client/login'); cy.get('#test_email') .invoke('val') - .then(emailValue => { + .then((emailValue) => { cy.get('#test_password') .invoke('val') - .then(passwordValue => { + .then((passwordValue) => { cy.get('#email') .type(emailValue) .should('have.value', emailValue); @@ -45,32 +45,32 @@ Cypress.Commands.add('clientLogin', () => { }); }); -Cypress.Commands.add( - 'iframeLoaded', - {prevSubject: 'element'}, - ($iframe) => { - const contentWindow = $iframe.prop('contentWindow'); - return new Promise(resolve => { - if ( - contentWindow - ) { - resolve(contentWindow) - } else { - $iframe.on('load', () => { - resolve(contentWindow) - }) - } - }) +Cypress.Commands.add('iframeLoaded', { prevSubject: 'element' }, ($iframe) => { + const contentWindow = $iframe.prop('contentWindow'); + return new Promise((resolve) => { + if (contentWindow) { + resolve(contentWindow); + } else { + $iframe.on('load', () => { + resolve(contentWindow); + }); + } }); - +}); Cypress.Commands.add( 'getInDocument', - {prevSubject: 'Permission denied to access property "document" on cross-origin object'}, + { + prevSubject: + 'Permission denied to access property "document" on cross-origin object', + }, (document, selector) => Cypress.$(selector, document) ); -Cypress.Commands.add( - 'getWithinIframe', - (targetElement) => cy.get('iframe').iframeLoaded().its('document').getInDocument(targetElement) +Cypress.Commands.add('getWithinIframe', (targetElement) => + cy + .get('iframe') + .iframeLoaded() + .its('document') + .getInDocument(targetElement) ); diff --git a/public/js/clients/payment_methods/authorize-stripe-card.js b/public/js/clients/payment_methods/authorize-stripe-card.js index d63edd7f58de..4a187bb1dec6 100644 --- a/public/js/clients/payment_methods/authorize-stripe-card.js +++ b/public/js/clients/payment_methods/authorize-stripe-card.js @@ -1,2 +1,2 @@ /*! For license information please see authorize-stripe-card.js.LICENSE.txt */ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}({1:function(e,t,n){e.exports=n("jzun")},jzun:function(e,t){function n(e,t){for(var n=0;n - 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 32809625b4c7..e0f7704ec53f 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 @@ -12,16 +12,16 @@
@if($client->getCreditCardGateway() || $client->getBankTransferGateway()) - +
@else diff --git a/resources/views/portal/ninja2020/invoices/payment.blade.php b/resources/views/portal/ninja2020/invoices/payment.blade.php index a72d67c72e0f..3295cbd72bbc 100644 --- a/resources/views/portal/ninja2020/invoices/payment.blade.php +++ b/resources/views/portal/ninja2020/invoices/payment.blade.php @@ -21,7 +21,7 @@