1. Go to this page and download the library: Download mead-steve/tale library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mead-steve / tale example snippets
class DebitCustomerBalanceStep implements Step
{
//.. Some constructor logic for initialising the api etc...
public function execute(CustomerPurchase $state)
{
$paymentId = $this->customerApi->debit($state->Amount);
return $state->markAsPaid($paymentId);
}
public function compensate($state): void
{
$this->customerApi->refundAccountForPayment($state->paymentId)
}
class BookFlightStep implements Step
{
//.. Some constructor logic for initialising the api etc...
public function execute(FlightPurchase $state)
{
$flightsBookingRef = $this->flightApi->buildBooking(
$state->Destination,
$state->Origin,
self::RETURN,
$this->airline
);
if ($flightsBookingRef=== null) {
raise \Exception("Unable to book flights");
}
return $state->flightsBooked($flightsBookingRef);
}
public function compensate($state): void
{
$this->customerApi->cancelFlights($state->flightsBookingRef)
}