|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Shopware\Core\Test\Integration\Builder\Order; |
|
4
|
|
|
|
|
5
|
|
|
use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice; |
|
6
|
|
|
use Shopware\Core\Checkout\Cart\Tax\Struct\CalculatedTaxCollection; |
|
7
|
|
|
use Shopware\Core\Checkout\Cart\Tax\Struct\TaxRuleCollection; |
|
8
|
|
|
use Shopware\Core\Content\Test\Product\ProductBuilder; |
|
9
|
|
|
use Shopware\Core\Framework\Log\Package; |
|
10
|
|
|
use Shopware\Core\Framework\Test\IdsCollection; |
|
11
|
|
|
use Shopware\Core\Test\TestBuilderTrait; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @final |
|
15
|
|
|
*/ |
|
16
|
|
|
#[Package('customer-order')] |
|
17
|
|
|
class OrderTransactionCaptureRefundPositionBuilder |
|
18
|
|
|
{ |
|
19
|
|
|
use TestBuilderTrait; |
|
20
|
|
|
|
|
21
|
|
|
protected string $id; |
|
22
|
|
|
|
|
23
|
|
|
protected CalculatedPrice $amount; |
|
24
|
|
|
|
|
25
|
|
|
public function __construct( |
|
26
|
|
|
IdsCollection $ids, |
|
27
|
|
|
string $key, |
|
28
|
|
|
protected string $refundId, |
|
29
|
|
|
float $amount = 420.69, |
|
30
|
|
|
protected ?string $externalReference = null, |
|
31
|
|
|
protected ?string $reason = null, |
|
32
|
|
|
protected ?string $orderLineItemId = null |
|
33
|
|
|
) { |
|
34
|
|
|
$this->id = $ids->get($key); |
|
35
|
|
|
$this->ids = $ids; |
|
36
|
|
|
|
|
37
|
|
|
$this->amount($amount); |
|
38
|
|
|
|
|
39
|
|
|
if (!$orderLineItemId) { |
|
40
|
|
|
$this->add('orderLineItem', (new ProductBuilder($this->ids, '10000')) |
|
41
|
|
|
->add('identifier', $this->ids->get('order_line_item')) |
|
42
|
|
|
->add('quantity', 1) |
|
43
|
|
|
->add('label', 'foo') |
|
44
|
|
|
->add('price', new CalculatedPrice( |
|
45
|
|
|
420.69, |
|
46
|
|
|
420.69, |
|
47
|
|
|
new CalculatedTaxCollection(), |
|
48
|
|
|
new TaxRuleCollection() |
|
49
|
|
|
)) |
|
50
|
|
|
->build()); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function amount(float $amount): self |
|
55
|
|
|
{ |
|
56
|
|
|
$this->amount = new CalculatedPrice($amount, $amount, new CalculatedTaxCollection(), new TaxRuleCollection()); |
|
57
|
|
|
|
|
58
|
|
|
return $this; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|