Skip to content

Commit

Permalink
Fix default customer object
Browse files Browse the repository at this point in the history
  • Loading branch information
andykim committed Aug 19, 2022
1 parent 228f24c commit caf5a61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion modules/gateways/xendit/lib/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,21 @@ public function generateCCPaymentRequest(array $params = [], int $auth_id = null
throw new \Exception("Invoice does not exist");
}

$billingDetailObject = $this->extractCustomer($params['clientdetails'], true);
$payload = [
"amount" => $this->roundUpTotal($params["amount"]),
"currency" => $params["currency"],
"token_id" => $params["gatewayid"],
"external_id" => $this->generateExternalId($params["invoiceid"], true),
"store_name" => $params["companyname"],
"items" => $this->extractItems($invoice),
"billing_details" => $this->extractCustomer($params['clientdetails'], true),
"is_recurring" => true,
"should_charge_multiple_use_token" => true
];

if(!empty($billingDetailObject)){
$payload['billing_details'] = $billingDetailObject;
}
if (!empty($auth_id)) {
$payload["authentication_id"] = $auth_id;
}
Expand Down
9 changes: 6 additions & 3 deletions modules/gateways/xendit/lib/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Link extends ActionBase
protected function generateInvoicePayload(array $params, bool $retry = false): array
{
$invoice = $this->getInvoice($params["invoiceid"]);

$customerObject = $this->extractCustomer($params['clientdetails']);
$payload = [
'external_id' => $this->generateExternalId($params["invoiceid"], $retry),
'payer_email' => $params['clientdetails']['email'],
Expand All @@ -29,10 +29,13 @@ protected function generateInvoicePayload(array $params, bool $retry = false): a
'platform_callback_url' => $params["systemurl"] . $this->callbackUrl,
'success_redirect_url' => $this->invoiceUrl($params['invoiceid'], $params['systemurl']),
'failure_redirect_url' => $this->invoiceUrl($params['invoiceid'], $params['systemurl']),
'should_charge_multiple_use_token' => true,
'customer' => $this->extractCustomer($params['clientdetails'])
'should_charge_multiple_use_token' => true
];

if(!empty($customerObject)){
$payload['customer'] = $customerObject;
}

// Only add the payment fee if it's > 0
if ($params['paymentfee'] > 0) {
$payload["fees"] = array(['type' => 'Payment Fee', 'value' => (float)$params['paymentfee']]);
Expand Down

0 comments on commit caf5a61

Please sign in to comment.