mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6291 from turbo124/v5-develop
Fixes for PaypalExpressDriver
This commit is contained in:
commit
729c92a343
@ -35,7 +35,7 @@ class StripeController extends BaseController
|
||||
public function import()
|
||||
{
|
||||
|
||||
return response()->json(['message' => 'Processing'], 200);
|
||||
// return response()->json(['message' => 'Processing'], 200);
|
||||
|
||||
|
||||
if(auth()->user()->isAdmin())
|
||||
|
@ -197,36 +197,23 @@ class PayPalExpressPaymentDriver extends BaseDriver
|
||||
|
||||
public function generatePaymentItems(array $data)
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
$items = collect($this->payment_hash->data->invoices)->map(function ($i) use (&$total) {
|
||||
$invoice = Invoice::findOrFail($this->decodePrimaryKey($i->invoice_id));
|
||||
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||
$invoice = Invoice::findOrFail($this->decodePrimaryKey($_invoice->invoice_id));
|
||||
|
||||
return collect($invoice->line_items)->map(function ($lineItem) use (&$total) {
|
||||
if (floatval($lineItem->quantity) != intval($lineItem->quantity)) {
|
||||
return null;
|
||||
}
|
||||
$line_item = collect($invoice->line_items)->first();
|
||||
|
||||
$total += $lineItem->cost * $lineItem->quantity;
|
||||
$items = [];
|
||||
|
||||
return new Item([
|
||||
'name' => $lineItem->product_key,
|
||||
'description' => substr(strip_tags($lineItem->notes), 0, 100),
|
||||
'price' => $lineItem->cost,
|
||||
'quantity' => $lineItem->quantity,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
if ($total != $data['total']['amount_with_fee']) {
|
||||
$items[0][] = new Item([
|
||||
'name' => trans('texts.taxes_and_fees'),
|
||||
'description' => '',
|
||||
'price' => $data['total']['amount_with_fee'] - $total,
|
||||
$items[] = new Item([
|
||||
'name' => " ",
|
||||
'description' => ctrans('texts.invoice_number') . "# " . $invoice->number,
|
||||
'price' => $data['total']['amount_with_fee'],
|
||||
'quantity' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
return $items[0]->toArray();
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user