-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from xendit/TPI-4983/TPI-5081/admin-settings
Migrate Kredivo to Invoice
- Loading branch information
Showing
27 changed files
with
140 additions
and
1,037 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
211 changes: 0 additions & 211 deletions
211
Xendit/M2Invoice/Controller/Checkout/CardlessCreditMultishipping.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,28 @@ private function getApiRequestData($order) | |
$orderId = $order->getRealOrderId(); | ||
$preferredMethod = $this->getRequest()->getParam('preferred_method'); | ||
|
||
$billingaddress = $order->getBillingAddress(); | ||
$shippingAddress = $order->getShippingAddress(); | ||
$address = [ | ||
'street_line1' => $shippingAddress->getData('street') ?: 'N/A', | ||
'city' => $shippingAddress->getData('city') ?: 'N/A', | ||
'state' => $shippingAddress->getData('region') ?: 'N/A', | ||
'postal_code' => $shippingAddress->getData('postcode') ?: 'N/A', | ||
'country' => $shippingAddress->getData('country_id') ?: 'ID' | ||
]; | ||
|
||
$orderItems = $order->getAllItems(); | ||
$items = []; | ||
foreach ($orderItems as $orderItem) { | ||
$item = []; | ||
$product = $orderItem->getProduct(); | ||
$item['reference_id'] = $product->getId(); | ||
$item['name'] = $product->getName(); | ||
$item['price'] = $product->getPrice(); | ||
$item['type'] = 'PRODUCT'; | ||
$item['url'] = $product->getProductUrl(); | ||
$item['quantity'] = (int) $orderItem->getQtyOrdered(); | ||
$items[] = (object) $item; | ||
} | ||
|
||
$requestData = [ | ||
'external_id' => $this->getDataHelper()->getExternalId($orderId), | ||
|
@@ -78,10 +99,13 @@ private function getApiRequestData($order) | |
'success_redirect_url' => $this->getDataHelper()->getSuccessUrl(), | ||
'failure_redirect_url' => $this->getDataHelper()->getFailureUrl($orderId), | ||
'customer' => (object) [ | ||
'given_names' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), | ||
'email' => $order->getCustomerEmail(), | ||
'mobile_number' => $billingaddress->getTelephone() | ||
] | ||
'given_names' => $order->getCustomerFirstname() ?: 'N/A', | ||
'surname' => $order->getCustomerLastname() ?: 'N/A', | ||
'email' => $order->getCustomerEmail() ?: '[email protected]' , | ||
'mobile_number' => $shippingAddress->getTelephone() ?: 'N/A', | ||
'addresses' => [(object) $address] | ||
], | ||
'items' => $items | ||
]; | ||
|
||
return $requestData; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,10 @@ public function execute() | |
$transactionAmount = 0; | ||
$orderProcessed = false; | ||
$orders = []; | ||
$addresses = []; | ||
$items = []; | ||
|
||
$orderIncrementIds = ''; | ||
$orderIncrementIds = ''; | ||
|
||
$c = 0; | ||
foreach ($orderIds as $key => $value) { | ||
|
@@ -53,11 +55,32 @@ public function execute() | |
$order->save(); | ||
|
||
$transactionAmount += (int)$order->getTotalDue(); | ||
$billingEmail = $order->getCustomerEmail(); | ||
$billingFirstName = $order->getCustomerFirstname(); | ||
$billingLastName = $order->getCustomerLastname(); | ||
$billingaddress = $order->getBillingAddress(); | ||
$billingEmail = $order->getCustomerEmail() ?: '[email protected]'; | ||
$shippingAddress = $order->getShippingAddress(); | ||
$currency = $order->getBaseCurrencyCode(); | ||
|
||
$address = [ | ||
'street_line1' => $shippingAddress->getData('street') ?: 'N/A', | ||
'city' => $shippingAddress->getData('city') ?: 'N/A', | ||
'state' => $shippingAddress->getData('region') ?: 'N/A', | ||
'postal_code' => $shippingAddress->getData('postcode') ?: 'N/A', | ||
'country' => $shippingAddress->getData('country_id') ?: 'ID' | ||
]; | ||
$addresses[] = (object) $address; | ||
|
||
$orderItems = $order->getAllItems(); | ||
foreach ($orderItems as $orderItem) { | ||
$item = []; | ||
$product = $orderItem->getProduct(); | ||
$item['reference_id'] = $product->getId(); | ||
$item['name'] = $product->getName(); | ||
$item['price'] = $product->getPrice(); | ||
$item['type'] = 'PRODUCT'; | ||
$item['url'] = $product->getProductUrl(); | ||
$item['quantity'] = (int) $orderItem->getQtyOrdered(); | ||
$items[] = (object) $item; | ||
} | ||
|
||
$c++; | ||
} | ||
|
||
|
@@ -83,10 +106,13 @@ public function execute() | |
'success_redirect_url' => $this->getDataHelper()->getSuccessUrl(true), | ||
'failure_redirect_url' => $this->getDataHelper()->getFailureUrl($orderIncrementIds, true), | ||
'customer' => (object) [ | ||
'given_names' => $billingFirstName . ' ' . $billingLastName, | ||
'email' => $billingEmail, | ||
'mobile_number' => $billingaddress->getTelephone() | ||
] | ||
'given_names' => $order->getCustomerFirstname() ?: 'N/A', | ||
'surname' => $order->getCustomerLastname() ?: 'N/A', | ||
'email' => $billingEmail, | ||
'mobile_number' => $shippingAddress->getTelephone() ?: 'N/A', | ||
'addresses' => $addresses | ||
], | ||
'items' => $items | ||
]; | ||
|
||
$invoice = $this->createInvoice($requestData); | ||
|
Oops, something went wrong.