Skip to content

Commit

Permalink
Merge pull request #17 from xendit/TPI-6989/whmcs-create-invoice-via-…
Browse files Browse the repository at this point in the history
…admin-error

Fix admin create invoice error
  • Loading branch information
andykim authored Apr 28, 2022
2 parents 84c3d4e + bdb4b48 commit 142928e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .buddy/phpcodesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- type: "PUSH"
refs:
- "refs/heads/master"
- "refs/pull/*"
- type: "CREATE_REF"
refs:
- "refs/pull/*"
Expand Down
4 changes: 2 additions & 2 deletions modules/gateways/xendit.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function xendit_remoteinput($params)
$secretKey = $params['xenditTestMode'] == 'on' ? $params['xenditTestSecretKey'] : $params['xenditSecretKey'];

// Client Parameters
$clientId = $params["clientdetails"]["id"];
$clientId = $params["clientdetails"]["id"] ?? $params['userid'];

// System Parameters
$systemUrl = $params['systemurl'];
Expand Down Expand Up @@ -273,7 +273,7 @@ function xendit_remoteupdate($params)
$remoteStorageToken = $params['gatewayid'];

// Client Parameters
$clientId = $params['client_id'];
$clientId = $params['client_id'] ?? $params['userid'];
$payMethodId = $params['paymethodid'];
$card_expired_date = (new DateTime($params['payMethod']->payment->expiry_date));
$currencyData = getCurrency($clientId);
Expand Down
6 changes: 5 additions & 1 deletion modules/gateways/xendit/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* @return void
*/
add_hook('InvoiceCreation', 1, function ($vars) {
if ($vars['status'] == 'Draft') {
return;
}

$xenditRecurring = new Recurring();
$invoice = $xenditRecurring->getInvoice($vars['invoiceid']);

Expand All @@ -31,7 +35,7 @@
add_hook("ClientAreaPageCart", 1, function ($vars) {
if ($vars['templatefile'] == 'viewcart') {
$actionBase = new ActionBase();
$activeCurrency = $vars['activeCurrency']->code;
$activeCurrency = $vars['currency']['code'] ?? $vars['activeCurrency']->code;
if (!$actionBase->validateCompatibilityVersion() || !in_array($activeCurrency, ActionBase::ALLOW_CURRENCIES)) {
unset($vars['gateways']["xendit"]);
}
Expand Down

0 comments on commit 142928e

Please sign in to comment.