-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,925 additions
and
637 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class CouldNotCancelMollieRefundException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $mollieOrderId, | ||
string $orderNumber, | ||
string $refundId, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf("Could not cancel the refund with id %s for order %s (Order number %s)", | ||
$refundId, | ||
$mollieOrderId, | ||
$orderNumber | ||
); | ||
|
||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class CouldNotCreateMollieRefundException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $mollieOrderId, | ||
string $orderNumber, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf("Could not create a refund for order %s (Order number %s)", | ||
$mollieOrderId, | ||
$orderNumber | ||
); | ||
|
||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class CouldNotExtractMollieOrderIdException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $orderNumber, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf('Could not extract the Mollie Order ID for order with number %s', $orderNumber); | ||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class CouldNotFetchMollieOrderException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $mollieOrderId, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf("Could not fetch the Mollie Order for ID %s", $mollieOrderId); | ||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class CouldNotFetchMollieRefundsException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $mollieOrderId, | ||
string $orderNumber, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf( | ||
"Could not fetch refunds for the Mollie Order with ID %s (Order number %s)", | ||
$mollieOrderId, | ||
$orderNumber | ||
); | ||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Exception; | ||
|
||
class PaymentNotFoundException extends \RuntimeException | ||
{ | ||
public function __construct( | ||
string $mollieOrderId, | ||
?\Throwable $previous = null | ||
) | ||
{ | ||
$message = sprintf('A payment for the Mollie order %s could not be found', $mollieOrderId); | ||
parent::__construct($message, 0, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Kiener\MolliePayments\Hydrator; | ||
|
||
use Mollie\Api\Resources\Refund; | ||
|
||
class RefundHydrator | ||
{ | ||
/** | ||
* @param Refund $refund | ||
* @return array<string, mixed> | ||
*/ | ||
public function hydrate(Refund $refund): array | ||
{ | ||
$amount = null; | ||
if ($refund->amount instanceof \stdClass) { | ||
$amount = [ | ||
'value' => $refund->amount->value, | ||
'currency' => $refund->amount->currency, | ||
]; | ||
} | ||
|
||
$settlementAmount = null; | ||
if ($refund->settlementAmount instanceof \stdClass) { | ||
$settlementAmount = [ | ||
'value' => $refund->settlementAmount->value, | ||
'currency' => $refund->settlementAmount->currency, | ||
]; | ||
} | ||
|
||
return [ | ||
'id' => $refund->id, | ||
'orderId' => $refund->orderId, | ||
'paymentId' => $refund->paymentId, | ||
'amount' => $amount, | ||
'settlementAmount' => $settlementAmount, | ||
'description' => $refund->description, | ||
'createdAt' => $refund->createdAt, | ||
'status' => $refund->status, | ||
'isFailed' => $refund->isFailed(), | ||
'isPending' => $refund->isPending(), | ||
'isProcessing' => $refund->isProcessing(), | ||
'isQueued' => $refund->isQueued(), | ||
'isTransferred' => $refund->isTransferred(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.