Skip to content

Commit

Permalink
Added 9 methods to the checkout interface
Browse files Browse the repository at this point in the history
- Their implementations already existed since v3
  • Loading branch information
fulopattila122 committed Apr 2, 2024
1 parent ff4304c commit 4f612e0
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 37 deletions.
9 changes: 9 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
- BC: Added the void return type to `Checkout::setShippingAddress()`
- BC: Added the following methods to the Checkout interface:
- `removeShippingAddress()`
- `getShipToBillingAddress()`
- `setShipToBillingAddress()`
- `getShippingMethodId()`
- `setShippingMethodId()`
- `getPaymentMethodId()`
- `setPaymentMethodId()`
- `getNotes()`
- `setNotes()`
- `clear()`
- `getShippingAmount()`
- `setShippingAmount()`
- `getTaxesAmount()`
Expand Down
9 changes: 9 additions & 0 deletions src/Checkout/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
- BC: Added the void return type to `Checkout::setShippingAddress()`
- BC: Added the following methods to the Checkout interface:
- `removeShippingAddress()`
- `getShipToBillingAddress()`
- `setShipToBillingAddress()`
- `getShippingMethodId()`
- `setShippingMethodId()`
- `getPaymentMethodId()`
- `setPaymentMethodId()`
- `getNotes()`
- `setNotes()`
- `clear()`
- `getShippingAmount()`
- `setShippingAmount()`
- `getTaxesAmount()`
Expand Down
45 changes: 45 additions & 0 deletions src/Checkout/CheckoutManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,51 @@ public function removeShippingAddress(): void
$this->store->removeShippingAddress();
}

public function getShipToBillingAddress(bool $default = true): bool
{
return $this->store->getShipToBillingAddress($default);
}

public function setShipToBillingAddress(bool $value): void
{
$this->store->setShipToBillingAddress($value);
}

public function getShippingMethodId(): null|int|string
{
return $this->store->getShippingMethodId();
}

public function setShippingMethodId(int|string|null $shippingMethodId): void
{
$this->store->setShippingMethodId($shippingMethodId);
}

public function getPaymentMethodId(): null|int|string
{
return $this->store->getPaymentMethodId();
}

public function setPaymentMethodId(int|string|null $paymentMethodId): void
{
$this->store->setPaymentMethodId($paymentMethodId);
}

public function getNotes(): ?string
{
return $this->store->getNotes();
}

public function setNotes(?string $text): void
{
$this->store->setNotes($text);
}

public function clear(): void
{
$this->store->clear();
}

public function setCustomAttribute(string $key, $value): void
{
$this->store->setCustomAttribute($key, $value);
Expand Down
45 changes: 18 additions & 27 deletions src/Checkout/Contracts/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,8 @@ interface Checkout extends Shippable, ArrayAccess
{
public function getCart(): ?CheckoutSubject;

/**
* Set the cart for the checkout
*
* @param CheckoutSubject $cart
*/
public function setCart(CheckoutSubject $cart);

/**
* Returns the state of the checkout
*
* @return CheckoutState
*/
public function getState(): CheckoutState;

/**
Expand All @@ -46,26 +36,32 @@ public function getState(): CheckoutState;
*/
public function setState($state);

/**
* Returns the bill payer details
*
* @return Billpayer
*/
public function getBillpayer(): Billpayer;

/**
* Sets the bill payer details
*
* @param Billpayer $billpayer
*/
public function setBillpayer(Billpayer $billpayer);

public function getShippingAddress(): ?Address;

public function setShippingAddress(Address $address): void;

public function removeShippingAddress(): void;

public function getShipToBillingAddress(bool $default = true): bool;

public function setShipToBillingAddress(bool $value): void;

public function getShippingMethodId(): null|int|string;

public function setShippingMethodId(null|int|string $shippingMethodId): void;

public function getPaymentMethodId(): null|int|string;

public function setPaymentMethodId(null|int|string $paymentMethodId): void;

public function getNotes(): ?string;

public function setNotes(?string $text): void;

public function clear(): void;

public function setCustomAttribute(string $key, $value): void;

public function getCustomAttribute(string $key);
Expand Down Expand Up @@ -93,10 +89,5 @@ public function itemsTotal(): float;
*/
public function update(array $data);

/**
* Returns the grand total of the checkout
*
* @return float
*/
public function total();
}
10 changes: 0 additions & 10 deletions src/Checkout/Drivers/BaseCheckoutStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,6 @@ public function offsetGet(mixed $offset): mixed
}
}

abstract public function clear(): void;

abstract public function getShippingAmount(): DetailedAmount;

abstract public function setShippingAmount(float|DetailedAmount $amount): void;

abstract public function getTaxesAmount(): DetailedAmount;

abstract public function setTaxesAmount(float|DetailedAmount $amount): void;

protected function getShipToName(Billpayer $billpayer): string
{
if ($billpayer->isOrganization()) {
Expand Down
45 changes: 45 additions & 0 deletions src/Checkout/Tests/Example/MemoryStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,51 @@ public function setTaxesAmount(float|DetailedAmount $amount): void
// TODO: Implement setTaxesAmount() method.
}

public function getShipToBillingAddress(bool $default = true): bool
{
// TODO: Implement getShipToBillingAddress() method.
}

public function setShipToBillingAddress(bool $value): void
{
// TODO: Implement setShipToBillingAddress() method.
}

public function getShippingMethodId(): null|int|string
{
// TODO: Implement getShippingMethodId() method.
}

public function setShippingMethodId(int|string|null $shippingMethodId): void
{
// TODO: Implement setShippingMethodId() method.
}

public function getPaymentMethodId(): null|int|string
{
// TODO: Implement getPaymentMethodId() method.
}

public function setPaymentMethodId(int|string|null $paymentMethodId): void
{
// TODO: Implement setPaymentMethodId() method.
}

public function getNotes(): ?string
{
// TODO: Implement getNotes() method.
}

public function setNotes(?string $text): void
{
// TODO: Implement setNotes() method.
}

public function clear(): void
{
// TODO: Implement clear() method.
}

public function update(array $data)
{
// TODO: Implement update() method.
Expand Down

0 comments on commit 4f612e0

Please sign in to comment.