Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Payments/Standard/PendingPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand All @@ -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,
);
Expand Down
6 changes: 4 additions & 2 deletions src/Payments/Standard/StandardOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/Payments/Standard/StandardPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
14 changes: 7 additions & 7 deletions src/Payments/Standard/ValueObjects/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
//
}
Expand Down
6 changes: 3 additions & 3 deletions src/Payments/Standard/ValueObjects/Customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
//
}
Expand Down
6 changes: 3 additions & 3 deletions src/Payments/Standard/ValueObjects/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
//
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* The prefix of the reference.
*/
public readonly string $ref;
public string $ref;

/**
* Creates a new reference instance.
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
12 changes: 4 additions & 8 deletions tests/Payments/Standard/StandardOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
returnUrl: 'https://example.com/return',
title: 'Test Order',
description: 'Test Order Description',
customer: null,
meta: null,
uuid: null,
);

// Assert
Expand All @@ -45,9 +42,6 @@
returnUrl: 'https://example.com/return',
title: 'Test Order',
description: 'Test Order Description',
customer: null,
meta: null,
uuid: null,
);

// Assert
Expand All @@ -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,
Expand Down