diff --git a/src/Payments/Standard/PendingPayment.php b/src/Payments/Standard/PendingPayment.php index 5afe1d4..4dbf6fc 100644 --- a/src/Payments/Standard/PendingPayment.php +++ b/src/Payments/Standard/PendingPayment.php @@ -70,12 +70,12 @@ public static function fromArray(array $data): self if (isset($data['event']) && str_contains((string) $data['event'], 'checkout.session:created')) { return new self( event: $data['event'], - checkoutUrl: $data['checkout_url'] ?? null, reference: $data['data']['tx_ref'] ?? '', currency: Currency::from($data['data']['currency'] ?? 'MWK'), amount: (int) ($data['data']['amount'] ?? 0), mode: $data['data']['mode'] ?? 'sandbox', status: $data['data']['status'] ?? 'pending', + checkoutUrl: $data['checkout_url'] ?? null, ); } @@ -100,7 +100,7 @@ public static function fromArray(array $data): self email: $data['customer']['email'] ?? null ), customization: empty($data['customization']) ? null : Customization::fromArray($data['customization']), - logs: empty($data['logs']) ? null : array_map(fn ($log): Log => Log::fromArray($log), $data['logs']), + logs: empty($data['logs']) ? null : array_map(Log::fromArray(...), $data['logs']), createdAt: $data['created_at'] ?? null, updatedAt: $data['updated_at'] ?? null, ); diff --git a/src/Payments/Standard/StandardOrder.php b/src/Payments/Standard/StandardOrder.php index fd3dd65..5844987 100644 --- a/src/Payments/Standard/StandardOrder.php +++ b/src/Payments/Standard/StandardOrder.php @@ -52,8 +52,10 @@ public function toArray(): array 'tx_ref' => $this->reference, 'callback_url' => $this->callbackUrl, 'return_url' => $this->returnUrl, - 'title' => $this->title ?? null, - 'description' => $this->description ?? null, + 'customization' => [ + 'title' => $this->title ?? null, + 'description' => $this->description ?? null, + ], 'customer' => $this->customer?->toArray() ?? null, 'meta' => $this->meta ?? null, 'uuid' => $this->uuid ?? null, diff --git a/src/Payments/Standard/StandardPayment.php b/src/Payments/Standard/StandardPayment.php index c1f8b10..f71fed5 100644 --- a/src/Payments/Standard/StandardPayment.php +++ b/src/Payments/Standard/StandardPayment.php @@ -87,7 +87,6 @@ public function verify(Payment|string $payment): bool { $reference = $payment instanceof Payment ? $payment->reference() : $payment; - /** @var PendingPayment $payment */ $payment = $this->retrieve($reference); return $payment->status === 'success'; diff --git a/src/Payments/Standard/ValueObjects/Authorization.php b/src/Payments/Standard/ValueObjects/Authorization.php index 8ec6040..8ca0153 100644 --- a/src/Payments/Standard/ValueObjects/Authorization.php +++ b/src/Payments/Standard/ValueObjects/Authorization.php @@ -18,13 +18,13 @@ * @param ?string $completedAt The completed at date of the authorization. */ public function __construct( - public readonly ?string $channel, - public readonly ?string $cardNumber, - public readonly ?string $expiry, - public readonly ?string $brand, - public readonly ?string $provider, - public readonly ?string $mobileNumber, - public readonly ?string $completedAt, + public ?string $channel, + public ?string $cardNumber, + public ?string $expiry, + public ?string $brand, + public ?string $provider, + public ?string $mobileNumber, + public ?string $completedAt, ) { // } diff --git a/src/Payments/Standard/ValueObjects/Customization.php b/src/Payments/Standard/ValueObjects/Customization.php index 0031d7d..4b741f7 100644 --- a/src/Payments/Standard/ValueObjects/Customization.php +++ b/src/Payments/Standard/ValueObjects/Customization.php @@ -14,9 +14,9 @@ * @param ?string $logo The logo of the customization. */ public function __construct( - public readonly ?string $title, - public readonly ?string $description, - public readonly ?string $logo, + public ?string $title, + public ?string $description, + public ?string $logo, ) { // } diff --git a/src/Payments/Standard/ValueObjects/Log.php b/src/Payments/Standard/ValueObjects/Log.php index b1eafa5..c0a28dd 100644 --- a/src/Payments/Standard/ValueObjects/Log.php +++ b/src/Payments/Standard/ValueObjects/Log.php @@ -14,9 +14,9 @@ * @param string $createdAt The created at date of the log. */ public function __construct( - public readonly string $type, - public readonly string $message, - public readonly string $createdAt, + public string $type, + public string $message, + public string $createdAt, ) { // } diff --git a/src/Support/Reference.php b/src/Support/Reference.php index 1348b0d..ad0e113 100644 --- a/src/Support/Reference.php +++ b/src/Support/Reference.php @@ -13,7 +13,7 @@ /** * The prefix of the reference. */ - public readonly string $ref; + public string $ref; /** * Creates a new reference instance. diff --git a/src/Support/Webhook.php b/src/Support/Webhook.php index cf4925a..a6f346f 100644 --- a/src/Support/Webhook.php +++ b/src/Support/Webhook.php @@ -70,8 +70,8 @@ public static function getCurrentRequest(): RequestInterface $headers = []; foreach ($_SERVER as $key => $value) { - if (str_starts_with($key, 'HTTP_')) { - $header = str_replace(' ', '-', ucwords(mb_strtolower(str_replace('_', ' ', mb_substr($key, 5))))); + if (str_starts_with((string) $key, 'HTTP_')) { + $header = str_replace(' ', '-', ucwords(mb_strtolower(str_replace('_', ' ', mb_substr((string) $key, 5))))); $headers[$header] = [$value]; } diff --git a/tests/Payments/Standard/StandardOrderTest.php b/tests/Payments/Standard/StandardOrderTest.php index 23c185f..70af11b 100644 --- a/tests/Payments/Standard/StandardOrderTest.php +++ b/tests/Payments/Standard/StandardOrderTest.php @@ -16,9 +16,6 @@ returnUrl: 'https://example.com/return', title: 'Test Order', description: 'Test Order Description', - customer: null, - meta: null, - uuid: null, ); // Assert @@ -45,9 +42,6 @@ returnUrl: 'https://example.com/return', title: 'Test Order', description: 'Test Order Description', - customer: null, - meta: null, - uuid: null, ); // Assert @@ -57,8 +51,10 @@ 'tx_ref' => '1234567890', 'callback_url' => 'https://example.com/callback', 'return_url' => 'https://example.com/return', - 'title' => 'Test Order', - 'description' => 'Test Order Description', + 'customization' => [ + 'title' => 'Test Order', + 'description' => 'Test Order Description', + ], 'customer' => null, 'meta' => null, 'uuid' => null,