From 66d046e76a4ae7a8e03519b81136c22cc58d9cb6 Mon Sep 17 00:00:00 2001 From: Joe Cohen Date: Wed, 11 Oct 2017 21:23:05 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Gateways/MercadoPagoBasic/Charges.php | 2 +- .../MercadoPagoBasicGateway.php | 38 +++++++++---------- .../PaypalExpress/PaypalExpressGateway.php | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Gateways/MercadoPagoBasic/Charges.php b/src/Gateways/MercadoPagoBasic/Charges.php index 0d192cb..b54dc10 100644 --- a/src/Gateways/MercadoPagoBasic/Charges.php +++ b/src/Gateways/MercadoPagoBasic/Charges.php @@ -101,7 +101,7 @@ protected function addPaymentMethod(array $params, $payment, array $options) $paymentTypes = ['prepaid_card', 'digital_currency', 'credit_card', 'debit_card', 'ticket', 'atm', 'bank_transfer']; $enabledTypes = Arr::get($options, 'enabled_brands', []); - $excludedTypes = array_map(function($type) { + $excludedTypes = array_map(function ($type) { return ['id' => $type]; }, array_values(array_filter($paymentTypes, function ($type) use ($enabledTypes) { return !in_array($type, $enabledTypes); diff --git a/src/Gateways/MercadoPagoBasic/MercadoPagoBasicGateway.php b/src/Gateways/MercadoPagoBasic/MercadoPagoBasicGateway.php index e326424..3855e3e 100644 --- a/src/Gateways/MercadoPagoBasic/MercadoPagoBasicGateway.php +++ b/src/Gateways/MercadoPagoBasic/MercadoPagoBasicGateway.php @@ -161,7 +161,7 @@ public function mapResponse($success, $response) 'errorCode' => $success ? null : $this->getErrorCode($response), 'type' => null, ]); - } + } return (new Response())->setRaw($rawResponse)->map([ 'isRedirect' => false, @@ -169,7 +169,7 @@ public function mapResponse($success, $response) 'reference' => $success ? $this->getReference($response) : null, 'message' => $success ? 'Transaction approved' : null, 'test' => $this->config['test'], - 'authorization' => $success ?Arr::get($response, 'id') : null, + 'authorization' => $success ? Arr::get($response, 'id') : null, 'status' => $success ? $this->getStatus($response) : new Status('failed'), 'errorCode' => $success ? null : $this->getErrorCode($response), 'type' => Arr::get($response, 'topic'), @@ -180,7 +180,7 @@ public function mapResponse($success, $response) * Get MercadoPago authorization. * * @param array $response - * + * * @return string|null */ protected function getReference(array $response) @@ -190,7 +190,7 @@ protected function getReference(array $response) if (!$payments) { return Arr::get($response, 'preference_id'); } - + $lastPayment = end($payments); return Arr::get($lastPayment, 'id'); @@ -216,23 +216,23 @@ protected function getStatus(array $response) if (count($payments) > 1) { $totalPaid = 0; $totalRefund = 0; - $total = $newResponse['shipping_cost'] + $newResponse['total_amount']; + $total = $newResponse['shipping_cost'] + $newResponse['total_amount']; foreach ($payments as $payment) { - if ($payment['status'] === 'approved') { - // Get the total paid amount, considering only approved incomings. - $totalPaid += $payment['total_paid_amount'] - $payment['amount_refunded']; - } elseif ($payment['status'] === 'refunded') { - // Get the total refunded amount. - $totalRefund += $payment['amount_refunded']; - } + if ($payment['status'] === 'approved') { + // Get the total paid amount, considering only approved incomings. + $totalPaid += $payment['total_paid_amount'] - $payment['amount_refunded']; + } elseif ($payment['status'] === 'refunded') { + // Get the total refunded amount. + $totalRefund += $payment['amount_refunded']; + } } - - if ($totalPaid >= $total) { - $newResponse['status'] = 'approved'; - } elseif ($totalRefund >= $total) { - $newResponse['status'] = 'refunded'; - } elseif ($totalRefund > 0) { + + if ($totalPaid >= $total) { + $newResponse['status'] = 'approved'; + } elseif ($totalRefund >= $total) { + $newResponse['status'] = 'refunded'; + } elseif ($totalRefund > 0) { $newResponse['status'] = 'partially_refunded'; } else { $newResponse['status'] = 'pending'; @@ -242,7 +242,7 @@ protected function getStatus(array $response) } $newResponse['status'] = $payments[0]['amount_refunded'] > 0 ? 'partially_refunded' : $payments[0]['status']; - + return parent::getStatus($newResponse); } diff --git a/src/Gateways/PaypalExpress/PaypalExpressGateway.php b/src/Gateways/PaypalExpress/PaypalExpressGateway.php index de16034..1724656 100644 --- a/src/Gateways/PaypalExpress/PaypalExpressGateway.php +++ b/src/Gateways/PaypalExpress/PaypalExpressGateway.php @@ -325,7 +325,7 @@ protected function getPaymentStatus($response) case 'Processed': return new Status('paid'); case 'Created': - case 'Pending': + case 'Pending': return new Status('pending'); case 'Canceled_Reversal': return new Status('canceled');