Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Checkout] Preventing payment step completion without a selected method #6217

Merged
merged 8 commits into from
Sep 29, 2016

Conversation

tuka217
Copy link
Contributor

@tuka217 tuka217 commented Sep 26, 2016

Q A
Bug fix? yes
New feature? no
BC breaks? no
Related tickets -
License MIT

@tuka217 tuka217 force-pushed the checkout-payment-validation branch 2 times, most recently from c31369a to 9c05d47 Compare September 27, 2016 08:45
public function iShouldNotBeAbleToCompleteThePaymentStep()
{
Assert::true(
$this->selectPaymentPage->hasNoAvailableNextStepButton(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about isNextStepButtonUnavailable?

<div class="header">{{ 'sylius.ui.warning'|trans }}</div>
<p>{{ 'sylius.ui.no_payment_methods_available'|trans }}.</p>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line

/** @var CorePaymentInterface $shipment */
Assert::isInstanceOf($shipment, CorePaymentInterface::class);

$paymentMethods = $this->paymentMethodRepository->findBy(['enabled' => true]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use $this->paymentMethodRepository->findEnabledForChannel($channel) method.

if ($channel->hasPaymentMethod($paymentMethod)) {
return $paymentMethod;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic will not be necessary after the above comment, but should be removed from the DefaultShippingMethodResolver also (in a separate PR).

@tuka217 tuka217 force-pushed the checkout-payment-validation branch 5 times, most recently from a2eb195 to 69c3289 Compare September 27, 2016 14:16
@@ -0,0 +1,53 @@
@checkout
Feature: Preventing payment step completion without a selected method
In order to be prevent from finish payment step without selected method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it should be prevented

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the above + from finishing the payment step without selecting a method / from finishing the payment step with no method selected

Feature: Preventing payment step completion without a selected method
In order to be prevent from finish payment step without selected method
As a Customer
I want to be prevent from finish payment step without selected method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

@@ -1212,6 +1212,36 @@ public function thereShouldBeInformationAboutNoShippingMethodsAvailableFormMyShi
}

/**
* @Given I do not select any payment method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@When

@tuka217 tuka217 changed the title [WIP] [Checkout] Preventing payment step completion without a selected method [Checkout] Preventing payment step completion without a selected method Sep 29, 2016
{
Assert::true(
$this->selectPaymentPage->isNextStepButtonUnavailable(),
'The "next step" button should be disabled, but it does not.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is not. although I'd be in favour of dropping this part in every method as it doesn't bring any value. If the message is in an exception and it says The "next step" button should be disabled. it's quite obvious what happened without an overly explicit explanation.

@@ -19,6 +19,8 @@ sylius:
payment:
currency_code:
not_valid: The currency code you entered is invalid.
method:
not_blank: 'Please select payment method.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a payment method.

{% endfor %}
</div>
</div>
{% else %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it even physically possible to get to this checkout step without a payment?

Copy link
Contributor Author

@tuka217 tuka217 Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I should suppose that channel cannot be created without payment method then it is impossible. Otherwise you can create a shop without payment method at all and then it could happen.

*/
final class UnresolvedDefaultPaymentMethodExceptionSpec extends ObjectBehavior
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line

$this->getDefaultPaymentMethod($payment)->shouldReturn($firstPaymentMethod);
}

function it_throws_exception_if_there_is_no_enabled_payment_methods(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there_are_no

namespace spec\Sylius\Component\Payment\Resolver;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

@@ -36,4 +38,4 @@ sylius:
not_blank: Please enter the fee percent.
code:
not_blank: 'Please enter payment method code.'
unique: 'The payment method with given code already exists.'
unique: 'The payment method with given code already exists.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing blank line.

@@ -54,7 +54,7 @@ public function it_does_not_allow_to_select_payment_for_order_that_is_not_addres
$this->addressOrder($orderId);

$url = sprintf('/api/checkouts/select-payment/%d', $orderId);
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
$this->client->request('PATCH', $url, [], [], static::$authorizedHeaderWithContentType);
Copy link
Contributor Author

@tuka217 tuka217 Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screen shot 2016-09-29 at 16 49 07

The other way is remove now this test until api's tests will be rebuild.

@tuka217 tuka217 force-pushed the checkout-payment-validation branch 2 times, most recently from 9d969fa to 2114400 Compare September 29, 2016 15:22
@michalmarcinkowski michalmarcinkowski merged commit 8da8c30 into Sylius:master Sep 29, 2016
@michalmarcinkowski
Copy link
Contributor

Thank you Ania! 👍

pamil pushed a commit to pamil/Sylius that referenced this pull request May 7, 2019
[Checkout] Preventing payment step completion without a selected method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants