Skip to content

Commit

Permalink
Merge branch '4.0' into next
Browse files Browse the repository at this point in the history
* 4.0:
  [Release] 4.0.10
  [Release] 3.2.13
  [Release] 3.2.13
  [composer] remove minimum stability
  [Payum] req payum/payum-bundle:^2.6
  [Payment] fix test
  [Payment] when payment is authorized or paid, order get's confirmed
  • Loading branch information
dpfaffenbauer committed Sep 10, 2024
2 parents fc5f015 + 38d6eca commit 42aea6b
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 147 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG-3.2.x.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
## 3.2.12
# 3.2.13
* [Currency/Money] implement Pimcore Grid Column by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2686
* [StorageList] make sure to remove StorageList from Session on Logout by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2684
* [InventoryBundle] add stock label renderer and hide onHand field by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2690
* [InventoryBundle] add translations for stock label #2 by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2691
* [Product] fix regression of price rules for products with default unit by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2698
* [OrderBundle] fix precison/factor for Payment Total by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2700
* [Payum] req payum/payum-bundle:^2.6 by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2710

# 3.2.12
* [MoneyBundle] money and moneyCurrency type should respect money_decimal_precision by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2671
* [VariantBundle] Add possibility to exclude Variants from AttributeCollector via AttributePreconditionEvent by @almshadi in https://github.com/coreshop/CoreShop/pull/2674
* [Product] don't allow Price and DiscountPrice Rule for unit prices by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2678
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG-4.0.x.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
## 4.0.10

* [PimcoreBundle] respect user language for grid filter labels (#2694) by @benwalch in https://github.com/coreshop/CoreShop/pull/2695
* [Product] fix regression of price rules for products with default unit by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2698
* [NotificationBundle] Mail Processor: Fix adding recipient twice by @benwalch in https://github.com/coreshop/CoreShop/pull/2701

## 4.0.9

* [OrderBundle] use context language for OrderState Operator by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2677
* [VariantBundle] Variant Creator by @breakone in https://github.com/coreshop/CoreShop/pull/2679

## 4.0.8

* [PaymentBundle] fix null title for payment provider by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2640
* [ProductBundle] fix missing cascade merge by @benwalch in https://github.com/coreshop/CoreShop/pull/2647
* [PaymentBundle/ShippingBundle] fix logo select form type by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2654
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"laminas/laminas-stdlib": "^3.6",
"laminas/laminas-zendframework-bridge": "^1.5",
"payum/payum": "^1.7",
"payum/payum-bundle": "^2.5",
"payum/payum-bundle": "^2.6",
"php-http/guzzle7-adapter": "^1.0",
"php-http/message-factory": "^1.1",
"pimcore/admin-ui-classic-bundle": "^1.2",
Expand Down
6 changes: 6 additions & 0 deletions features/domain/order/order_payment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,34 @@ Feature: Create a new order and add a payment
Given I create a payment for my order with payment provider "Bankwire" and amount 1800
And I apply payment transition "fail" to latest order payment
Then the order payment state should be "awaiting_payment"
And the order state should be "new"

Scenario: Create cancelled payment
Given I create a payment for my order with payment provider "Bankwire" and amount 1800
And I apply payment transition "cancel" to latest order payment
Then the order payment state should be "awaiting_payment"
And the order state should be "new"

Scenario: Create fully paid payment
Given I create a payment for my order with payment provider "Bankwire" and amount 2400
And I apply payment transition "complete" to latest order payment
Then the order payment state should be "paid"
And the order state should be "confirmed"

Scenario: Create partially paid payment
Given I create a payment for my order with payment provider "Bankwire" and amount 1800
And I apply payment transition "complete" to latest order payment
Then the order payment state should be "partially_paid"
And the order state should be "confirmed"

Scenario: Create fully authorized payment
Given I create a payment for my order with payment provider "Bankwire" and amount 2400
And I apply payment transition "authorize" to latest order payment
Then the order payment state should be "authorized"
And the order state should be "confirmed"

Scenario: Create partially authorized payment
Given I create a payment for my order with payment provider "Bankwire" and amount 1800
And I apply payment transition "authorize" to latest order payment
Then the order payment state should be "partially_authorized"
And the order state should be "confirmed"
4 changes: 1 addition & 3 deletions features/domain/order/order_workflow.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ Feature: Create a new order and add a invoice
Scenario: Create order with payment and shipment which still is new
Given I create an order from my cart
And I create a payment for my order with payment provider "Bankwire" and amount 2400
And I apply payment transition "complete" to latest order payment
And I create a shipment for my order
And I apply order shipment transition "request_shipment" to my order
And I apply shipment transition "ship" to latest order shipment
Then the order shipping state should be "shipped"
And the order payment state should be "paid"
And the order payment state should be "awaiting_payment"
And the order state should be "new"

Scenario: Create order with payment and shipment which still is completed
Given I create an order from my cart
And I apply transition "confirm" to my order
And I create a payment for my order with payment provider "Bankwire" and amount 2400
And I apply payment transition "complete" to latest order payment
And I create a shipment for my order
Expand Down
2 changes: 1 addition & 1 deletion src/CoreShop/Bundle/CoreBundle/Application/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class Version

public const MINOR_VERSION = '0';

public const RELEASE_VERSION = '9';
public const RELEASE_VERSION = '10';

public const EXTRA_VERSION = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ core_shop_workflow:
callbacks:
after:
resolve_state:
on: ['pay']
on: ['partially_authorize', 'authorize', 'partially_pay', 'pay']
do: ['@CoreShop\Bundle\OrderBundle\StateResolver\OrderStateResolver', 'resolve']
args: ['object']
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,26 @@ public function __construct(
public function resolve(OrderInterface $order): void
{
$stateMachine = $this->stateMachineManager->get($order, 'coreshop_order');

if ($this->canOrderBeConfirmed($order) && $stateMachine->can($order, OrderTransitions::TRANSITION_CONFIRM)) {
$stateMachine->apply($order, OrderTransitions::TRANSITION_CONFIRM);
}

if ($this->canOrderBeComplete($order) && $stateMachine->can($order, OrderTransitions::TRANSITION_COMPLETE)) {
$stateMachine->apply($order, OrderTransitions::TRANSITION_COMPLETE);
}
}

private function canOrderBeConfirmed(OrderInterface $order): bool
{
return in_array($order->getPaymentState(), [
OrderPaymentStates::STATE_PAID,
OrderPaymentStates::STATE_PARTIALLY_PAID,
OrderPaymentStates::STATE_AUTHORIZED,
OrderPaymentStates::STATE_PARTIALLY_AUTHORIZED,
], true);
}

private function canOrderBeComplete(OrderInterface $order): bool
{
$coreStates = OrderPaymentStates::STATE_PAID === $order->getPaymentState() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,12 @@

namespace CoreShop\Bundle\PayumBundle\Exception;

use Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter as BaseReplyToSymfonyResponseConverter;
use Payum\Core\Reply\ReplyInterface;
use Symfony\Component\HttpFoundation\Response;

/**
* @psalm-suppress TypeDoesNotContainType
*/
if (false) {
//This is just for the IDE
class BaseCoreShopReplayToSymfonyResponseConverter
{
public function convert(ReplyInterface $reply): Response
{
throw new \RuntimeException('Not implemented');
}
}
}

if (class_exists('Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter')) {
\class_alias(\Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter');
} elseif (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) {
\class_alias(\Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter');
} else {
throw new \RuntimeException('Cannot find Payum ReplyToSymfonyResponseConverter class');
}

class ReplyToSymfonyResponseConverter extends BaseCoreShopReplayToSymfonyResponseConverter
class ReplyToSymfonyResponseConverter extends BaseReplyToSymfonyResponseConverter
{
public function convert(ReplyInterface $reply): Response
public function convert(ReplyInterface $reply)
{
if ($reply instanceof ReplyException && null !== $reply->getPrevious()) {
throw $reply->getPrevious();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ services:
tags:
- { name: payum.extension, all: true, prepend: true }

CoreShop\Bundle\PayumBundle\Extension\UpdateOrderStateExtension:
arguments:
- '@CoreShop\Bundle\WorkflowBundle\Manager\StateMachineManagerInterface'
tags:
- { name: payum.extension, all: true, prepend: true }

0 comments on commit 42aea6b

Please sign in to comment.