Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit ef6cba4

Browse files
author
fd6130
committed
fix optional parameter deprecation notice
1 parent 7e047d8 commit ef6cba4

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

src/Service/Billplz.php

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ class Billplz implements BillplzInterface
1111

1212
private array $config;
1313

14-
public function __construct
15-
(
14+
public function __construct(
1615
array $config
1716
)
1817
{
19-
$this->client = $config['enable_sandbox'] == false ?
20-
Client::make($config['live']['api_key'], $config['live']['signature_key']) :
18+
$this->client = $config['enable_sandbox'] == false ?
19+
Client::make($config['live']['api_key'], $config['live']['signature_key']) :
2120
Client::make($config['sandbox']['api_key'], $config['sandbox']['signature_key'])->useSandbox();
2221
$this->config = $config;
2322
}
@@ -47,32 +46,36 @@ public function getBillPaymentUrl(string $billId): string
4746
return $this->isSandbox() == true ? sprintf('https://www.billplz-sandbox.com/bills/%s', $billId) : sprintf('https://www.billplz.com/bills/%s', $billId);
4847
}
4948

50-
public function createBill
51-
(
49+
public function createBill(
5250
string $collectionKey,
5351
?string $email = null,
5452
?string $mobile = null,
55-
string $name,
56-
int|string $amount,
57-
string $callbackUrl,
58-
string $description,
53+
string $name = null,
54+
int|string $amount = null,
55+
string $callbackUrl = null,
56+
string $description = null,
5957
array $optional = []
60-
) : Response
58+
): Response
6159
{
6260
$collection = $this->getCurrentConfiguration()['collection'];
6361

6462
$index = array_search($collectionKey, array_column($collection, 'name'));
65-
if($index === false)
63+
if ($index === false)
6664
{
6765
throw new \LogicException(sprintf("Unable to find '%s' from the collection.", $collectionKey));
6866
}
6967

7068
return $this->client->bill()
71-
->create
72-
(
73-
$collection[$index]['id'], $email, $mobile, $name, \Duit\MYR::given($amount * 100), $callbackUrl, $description, $optional
74-
)
75-
;
69+
->create(
70+
$collection[$index]['id'],
71+
$email,
72+
$mobile,
73+
$name,
74+
\Duit\MYR::given($amount * 100),
75+
$callbackUrl,
76+
$description,
77+
$optional
78+
);
7679
}
7780

7881
public function computeRedirectSignature(array $params)
@@ -83,7 +86,7 @@ public function computeRedirectSignature(array $params)
8386
'billplzpaid' . $params['billplz[paid]']
8487
];
8588

86-
return hash_hmac(algo: "sha256", data: implode('|', $data) , key: $this->client->getSignatureKey());
89+
return hash_hmac(algo: "sha256", data: implode('|', $data), key: $this->client->getSignatureKey());
8790
}
8891

8992
public function computeCallbackSignature(array $params)
@@ -103,6 +106,6 @@ public function computeCallbackSignature(array $params)
103106
'url' . $params['url'],
104107
];
105108

106-
return hash_hmac(algo: "sha256", data: implode('|', $data) , key: $this->client->getSignatureKey());
109+
return hash_hmac(algo: "sha256", data: implode('|', $data), key: $this->client->getSignatureKey());
107110
}
108-
}
111+
}

src/Service/BillplzInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ public function getAllConfiguration(): array;
1414
public function getCurrentConfiguration(): array;
1515
public function computeRedirectSignature(array $params);
1616
public function computeCallbackSignature(array $params);
17-
public function createBill(string $collectionKey, ?string $email = null, ?string $mobile = null, string $name, int|string $amount, string $callbackUrl, string $description, array $optional = []): Response;
18-
}
17+
public function createBill(string $collectionKey, ?string $email = null, ?string $mobile = null, string $name = null, int|string $amount = null, string $callbackUrl = null, string $description = null, array $optional = []): Response;
18+
}

0 commit comments

Comments
 (0)