This commit is contained in:
Benjamin Beganović 2021-02-03 16:49:29 +01:00
parent 83a42cf410
commit 6a972ba378
8 changed files with 176 additions and 50 deletions

View File

@ -86,6 +86,10 @@ class CreditCard
$state = array_merge($state, $request->all());
$state['store_card'] = boolval($state['store_card']);
if ($request->has('token') && !is_null($request->token)) {
$state['store_card'] = false;
}
$state['payment_intent'] = PaymentIntent::retrieve($state['server_response']->id);
$state['customer'] = $state['payment_intent']->customer;
@ -116,7 +120,6 @@ class CreditCard
'gateway_type_id' => GatewayType::CREDIT_CARD,
];
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['amount' => $data['amount']]);
$this->stripe->payment_hash->save();

View File

@ -1,8 +1,8 @@
{
"video": false,
"baseUrl": "http://localhost:8080/",
"baseUrl": "https://localhost:8000/",
"chromeWebSecurity": false,
"env": {
"runningEnvironment": "docker"
"runningEnvironment": "native"
}
}

View File

@ -1,21 +1,87 @@
context('Checkout.com gateway test', () => {
beforeEach(() => {
cy.viewport('macbook-13');
context('Checkout.com: Credit card testing', () => {
before(() => {
cy.artisan('migrate:fresh --seed');
cy.artisan('ninja:create-single-account checkout');
});
it('should migrate & seed checkout', function () {
// cy.artisan('migrate:fresh --seed');
// cy.artisan('ninja:create-single-account');
beforeEach(() => {
cy.viewport('macbook-13');
cy.clientLogin();
});
afterEach(() => {
cy.visit('/client/logout');
});
it('should not be able to add payment method', function () {
cy.visit('/client/payment_methods');
cy.get('[data-cy=add-payment-method]').click();
cy.get('[data-cy=add-credit-card-link]').click();
cy.get('[data-ref=gateway-container]')
.contains('Checkout.com can be can saved as payment method for future use, once you complete your first transaction. Don\'t forget to check "Store credit card details" during payment process.');
});
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.getWithinIframe('#checkout-frames-card-number').type('4242424242424242');
cy.getWithinIframe('#checkout-frames-expiry-date').type('12/30');
cy.getWithinIframe('#checkout-frames-cvv').type('100');
cy.getWithinIframe('#checkout-frames-card-number').type('4658584090000001');
cy.getWithinIframe('#checkout-frames-expiry-date').type('12/22');
cy.getWithinIframe('#checkout-frames-cvv').type('257');
cy.get('#pay-button').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');
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('[name=token-billing-checkbox]').first().check();
cy.getWithinIframe('#checkout-frames-card-number').type('4543474002249996');
cy.getWithinIframe('#checkout-frames-expiry-date').type('12/22');
cy.getWithinIframe('#checkout-frames-cvv').type('956');
cy.get('#pay-button').click();
cy.url().should('contain', '/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.get('[name=payment-type]').first().check();
cy.get('#pay-now-with-token').click();
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.');
});
});

View File

@ -1,47 +1,98 @@
describe('Stripe Credit Card Payments', () => {
describe('Stripe: Credit card testing', () => {
before(() => {
cy.artisan('migrate:fresh --seed');
cy.artisan('ninja:create-single-account stripe');
});
beforeEach(() => {
cy.viewport('macbook-13');
cy.clientLogin();
});
it('should be able to add credit card using Stripe', () => {
afterEach(() => {
cy.visit('/client/logout');
});
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');
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('[name=token-billing-checkbox]').first().check();
cy.get('#pay-now').click();
cy.url().should('contain', '/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.get('[name=payment-type]').first().check();
cy.get('#pay-now').click();
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();
cy.get('#cardholder-name').type('Invoice Ninja');
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.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('#authorize-card').click();
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');
cy.url().should('contain', '/client/payment_methods');
});
});

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
"/js/clients/payments/checkout-credit-card.js": "/js/clients/payments/checkout-credit-card.js?id=98e406fa8e4db0e93427",
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=c4012ad90f17d60432ad",
"/js/clients/payments/stripe-alipay.js": "/js/clients/payments/stripe-alipay.js?id=6dbe9316b98deea55421",
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=9418a9c5c137994c4bd8",
"/js/clients/payments/stripe-credit-card.js": "/js/clients/payments/stripe-credit-card.js?id=c37c3892d35c50d82521",
"/js/clients/payments/stripe-sofort.js": "/js/clients/payments/stripe-sofort.js?id=9b9fd56d655ad238f149",
"/js/clients/quotes/action-selectors.js": "/js/clients/quotes/action-selectors.js?id=1b8f9325aa6e8595e7fa",
"/js/clients/quotes/approve.js": "/js/clients/quotes/approve.js?id=85bcae0a646882e56b12",

View File

@ -95,7 +95,7 @@ class StripeCreditCard {
if (tokenBillingCheckbox) {
document.querySelector('input[name="store_card"]').value =
tokenBillingCheckbox.checked;
tokenBillingCheckbox.value;
}
document.getElementById('server-response').submit();

View File

@ -1,4 +1,10 @@
@if($gateway->company_gateway->token_billing !== 'always')
@php
$token_billing = $gateway instanceof \App\Models\CompanyGateway
? $gateway->token_billing !== 'always'
: $gateway->company_gateway->token_billing !== 'always';
@endphp
@if($token_billing)
<div class="sm:grid px-4 py-5 sm:grid-cols-3 sm:gap-4 sm:px-6" id="save-card--container">
<dt class="text-sm leading-5 font-medium text-gray-500">
{{ ctrans('texts.save_payment_method_details') }}