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()
|
public function import()
|
||||||
{
|
{
|
||||||
|
|
||||||
return response()->json(['message' => 'Processing'], 200);
|
// return response()->json(['message' => 'Processing'], 200);
|
||||||
|
|
||||||
|
|
||||||
if(auth()->user()->isAdmin())
|
if(auth()->user()->isAdmin())
|
||||||
|
@ -197,36 +197,23 @@ class PayPalExpressPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public function generatePaymentItems(array $data)
|
public function generatePaymentItems(array $data)
|
||||||
{
|
{
|
||||||
$total = 0;
|
|
||||||
|
|
||||||
$items = collect($this->payment_hash->data->invoices)->map(function ($i) use (&$total) {
|
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||||
$invoice = Invoice::findOrFail($this->decodePrimaryKey($i->invoice_id));
|
$invoice = Invoice::findOrFail($this->decodePrimaryKey($_invoice->invoice_id));
|
||||||
|
|
||||||
return collect($invoice->line_items)->map(function ($lineItem) use (&$total) {
|
$line_item = collect($invoice->line_items)->first();
|
||||||
if (floatval($lineItem->quantity) != intval($lineItem->quantity)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$total += $lineItem->cost * $lineItem->quantity;
|
$items = [];
|
||||||
|
|
||||||
return new Item([
|
$items[] = new Item([
|
||||||
'name' => $lineItem->product_key,
|
'name' => " ",
|
||||||
'description' => substr(strip_tags($lineItem->notes), 0, 100),
|
'description' => ctrans('texts.invoice_number') . "# " . $invoice->number,
|
||||||
'price' => $lineItem->cost,
|
'price' => $data['total']['amount_with_fee'],
|
||||||
'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,
|
|
||||||
'quantity' => 1,
|
'quantity' => 1,
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
return $items[0]->toArray();
|
return $items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user