forked from thePHPcc/phpdd18-event-sourcing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.php
More file actions
28 lines (18 loc) · 706 Bytes
/
run.php
File metadata and controls
28 lines (18 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require __DIR__ . '/vendor/autoload.php';
$sessionId = new \Eventsourcing\SessionId('has4t1glskcktjh4ujs9eet26u');
$_SESSION = [
//'checkout_id' => '9B0B64CA-7DB7-404B-9AE2-12E2164873E1'
];
$factory = new \Eventsourcing\Factory($sessionId);
$cartItems = $factory->createCartService()->getCartItems();
$checkout = $factory->createCheckout();
$checkout->startCheckout($cartItems);
$checkout->setBillingAddress(
new \Eventsourcing\BillingAddress('foo', 'bar', 'baz', '123', 'foobaz', 'DE')
);
$checkout->placeOrder();
$eventLog = $checkout->getRecordedEvents();
$writer = $factory->createEventLogWriter();
$writer->write($eventLog);
$factory->createEventListener()->handle($eventLog);