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(() => {
|
2021-02-05 13:06:47 +01:00
|
|
|
cy.visit('/client/logout').visit('/client/login');
|
2021-02-03 16:49:29 +01:00
|
|
|
});
|
2020-10-13 13:36:56 +02:00
|
|
|
|
2021-02-03 16:49:29 +01:00
|
|
|
it('should pay with new card', function () {
|
2021-02-05 13:06:47 +01:00
|
|
|
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();
|
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');
|
|
|
|
|
|
|
|
cy.get('#pay-now').click();
|
|
|
|
|
2021-02-05 13:06:47 +01:00
|
|
|
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/VolejRejNm');
|
2021-02-03 16:49:29 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should pay with new card & save credit card for future use', function () {
|
2021-02-05 13:06:47 +01:00
|
|
|
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();
|
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-05 13:06:47 +01:00
|
|
|
cy.location('pathname', {timeout: 60000}).should('include', '/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 () {
|
2021-02-05 13:06:47 +01:00
|
|
|
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();
|
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-05 13:06:47 +01:00
|
|
|
cy.location('pathname', {timeout: 60000}).should('include', '/client/payments/Opnel5aKBz');
|
2021-02-03 16:49:29 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to remove payment method', function () {
|
2021-02-05 13:06:47 +01:00
|
|
|
cy.visit('/client/payment_methods')
|
|
|
|
.get('[data-cy=view-payment-method]').click();
|
2021-02-03 16:49:29 +01:00
|
|
|
|
|
|
|
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 () {
|
2021-02-05 13:06:47 +01:00
|
|
|
cy.visit('/client/payment_methods')
|
|
|
|
.get('[data-cy=add-payment-method]').click()
|
|
|
|
.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-05 13:06:47 +01:00
|
|
|
cy.location('pathname', {timeout: 60000})
|
|
|
|
.should('include', '/client/payment_methods')
|
|
|
|
.get('[data-cy=pm-last4]').contains('**** 4242');
|
2020-10-13 13:36:56 +02:00
|
|
|
});
|
|
|
|
});
|