2021-02-03 16:49:29 +01:00
|
|
|
describe('Stripe: Credit card testing', () => {
|
|
|
|
before(() => {
|
|
|
|
cy.artisan('migrate:fresh --seed');
|
|
|
|
cy.artisan('ninja:create-single-account stripe');
|
|
|
|
});
|
|
|
|
|
2020-10-13 15:46:11 +02:00
|
|
|
beforeEach(() => {
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.viewport('macbook-13');
|
2020-10-13 15:46:11 +02:00
|
|
|
cy.clientLogin();
|
|
|
|
});
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
afterEach(() => {
|
|
|
|
cy.visit('/client/logout');
|
|
|
|
});
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
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.get('#cardholder-name').type('Invoice Ninja Rocks');
|
|
|
|
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
|
|
|
cy.getWithinIframe('[name=exp-date]').type('04/24');
|
|
|
|
cy.getWithinIframe('[name=cvc]').type('242');
|
|
|
|
cy.getWithinIframe('[name=postal]').type('42424');
|
|
|
|
|
|
|
|
cy.get('#pay-now').click();
|
|
|
|
|
|
|
|
cy.url().should('contain', '/client/payments/VolejRejNm');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should pay with new card & save credit card for future use', function () {
|
|
|
|
cy.visit('/client/invoices');
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('[data-cy=pay-now]').first().click();
|
|
|
|
cy.get('[data-cy=pay-now-dropdown]').click();
|
|
|
|
cy.get('[data-cy=pay-with-0]').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('#cardholder-name').type('Invoice Ninja Rocks');
|
|
|
|
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
|
|
|
cy.getWithinIframe('[name=exp-date]').type('04/24');
|
|
|
|
cy.getWithinIframe('[name=cvc]').type('242');
|
|
|
|
cy.getWithinIframe('[name=postal]').type('42424');
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('[name=token-billing-checkbox]').first().check();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('#pay-now').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.url().should('contain', '/client/payments/Wpmbk5ezJn');
|
2020-10-13 13:36:56 +02:00
|
|
|
});
|
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
it('should pay with saved card (token)', function () {
|
2020-10-13 13:36:56 +02:00
|
|
|
cy.visit('/client/invoices');
|
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('[data-cy=pay-now]').first().click();
|
|
|
|
cy.get('[data-cy=pay-now-dropdown]').click();
|
|
|
|
cy.get('[data-cy=pay-with-0]').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('[name=payment-type]').first().check();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('#pay-now').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.url().should('contain', '/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.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');
|
|
|
|
|
|
|
|
cy.get('[data-cy=add-payment-method]').click();
|
|
|
|
cy.get('[data-cy=add-credit-card-link]').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('#cardholder-name').type('Invoice Ninja Rocks');
|
|
|
|
cy.getWithinIframe('[name=cardnumber]').type('4242424242424242');
|
|
|
|
cy.getWithinIframe('[name=exp-date]').type('04/24');
|
|
|
|
cy.getWithinIframe('[name=cvc]').type('242');
|
|
|
|
cy.getWithinIframe('[name=postal]').type('42424');
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.get('#authorize-card').click();
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
cy.url().should('contain', '/client/payment_methods');
|
2020-10-13 13:36:56 +02:00
|
|
|
});
|
|
|
|
});
|