mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Send payment line item details
This commit is contained in:
parent
1b7ddc0e4e
commit
2542b1a640
@ -10,6 +10,7 @@ use App\Models\GatewayType;
|
||||
use App\Models\License;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentMethod;
|
||||
use Omnipay\Common\Item;
|
||||
use CreditCard;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
@ -304,7 +305,10 @@ class BasePaymentDriver
|
||||
|
||||
// prepare and process payment
|
||||
$data = $this->paymentDetails($paymentMethod);
|
||||
$response = $gateway->purchase($data)->send();
|
||||
$items = $this->paymentItems();
|
||||
$response = $gateway->purchase($data)
|
||||
->setItems($items)
|
||||
->send();
|
||||
$this->purchaseResponse = (array) $response->getData();
|
||||
|
||||
// parse the transaction reference
|
||||
@ -337,6 +341,38 @@ class BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
private function paymentItems()
|
||||
{
|
||||
$invoice = $this->invoice();
|
||||
$items = [];
|
||||
$total = 0;
|
||||
|
||||
foreach ($invoice->invoice_items as $invoiceItem) {
|
||||
$item = new Item([
|
||||
'name' => $invoiceItem->product_key,
|
||||
'description' => $invoiceItem->notes,
|
||||
'price' => $invoiceItem->cost,
|
||||
'quantity' => $invoiceItem->qty,
|
||||
]);
|
||||
|
||||
$items[] = $item;
|
||||
$total += $invoiceItem->cost * $invoiceItem->qty;
|
||||
}
|
||||
|
||||
if ($total != $invoice->getRequestedAmount()) {
|
||||
$item = new Item([
|
||||
'name' => trans('texts.other'),
|
||||
'description' => '',
|
||||
'price' => $invoice->getRequestedAmount() - $total,
|
||||
'quantity' => 1,
|
||||
]);
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function updateClient()
|
||||
{
|
||||
if (! $this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) {
|
||||
|
@ -2288,6 +2288,7 @@ $LANG = array(
|
||||
'deleted_recurring_expense' => 'Successfully deleted project',
|
||||
'deleted_recurring_expense' => 'Successfully deleted :count projects',
|
||||
'view_recurring_expense' => 'View Recurring Expense',
|
||||
'other' => 'Other',
|
||||
|
||||
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user