/** * Tries to get an authorization or captures the money immediately for the given order if capturing the money * separately isn't supported or not configured by the shop owner. * * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object * @param array $params Request parameter if available * @return \Aimeos\MShop\Common\Item\Helper\Form\Standard Form object with URL, action and parameters to redirect to * (e.g. to an external server of the payment provider or to a local success page) */ public function process(\Aimeos\MShop\Order\Item\Iface $order, array $params = array()) { $order->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED); $this->saveOrder($order); return parent::process($order, $params); }
/** * Tries to get an authorization or captures the money immediately for the given order if capturing the money * separately isn't supported or not configured by the shop owner. * * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object * @param array $params Request parameter if available * @return \Aimeos\MShop\Common\Item\Helper\Form\Standard Form object with URL, action and parameters to redirect to * (e.g. to an external server of the payment provider or to a local success page) */ protected function processOrder(\Aimeos\MShop\Order\Item\Iface $order, array $params = array()) { $urls = $this->getPaymentUrls(); $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_SERVICE | \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ADDRESS; $base = $this->getOrderBase($order->getBaseId(), $parts); $desc = $this->getContext()->getI18n()->dt('mshop', 'Order %1$s'); $card = $this->getCardDetails($base, $params); $orderid = $order->getId(); $data = array('token' => '', 'card' => $card, 'transactionId' => $orderid, 'description' => sprintf($desc, $orderid), 'amount' => $this->getAmount($base->getPrice()), 'currency' => $base->getLocale()->getCurrencyId(), 'language' => $base->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT)->getLanguageId(), 'clientIp' => $this->getValue('client.ipaddress')) + $urls; try { $provider = $this->getProvider(); if ($this->getValue('authorize', false) && $provider->supportsAuthorize()) { $response = $provider->authorize($data)->send(); $status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED; } else { $response = $provider->purchase($data)->send(); $status = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; } if ($response->isSuccessful()) { $this->saveTransationRef($base, $response->getTransactionReference()); $order->setPaymentStatus($status); $this->saveOrder($order); } elseif ($response->isRedirect()) { if (($ref = $response->getTransactionReference()) != null) { $this->saveTransationRef($base, $ref); } return $this->getRedirectForm($response); } else { $order->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_REFUSED); $this->saveOrder($order); throw new \Aimeos\MShop\Service\Exception($response->getMessage()); } } catch (\Exception $e) { throw new \Aimeos\MShop\Service\Exception($e->getMessage()); } return new \Aimeos\MShop\Common\Item\Helper\Form\Standard($urls['returnUrl'], 'POST', array()); }
/** * Tries to get an authorization or captures the money immediately for the given order if capturing the money * separately isn't supported or not configured by the shop owner. * * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object * @param array $params Request parameter if available * @return \Aimeos\MShop\Common\Item\Helper\Form\Standard Form object with URL, action and parameters to redirect to * (e.g. to an external server of the payment provider or to a local success page) */ protected function processOrder(\Aimeos\MShop\Order\Item\Iface $order, array $params = array()) { $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_SERVICE | \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ADDRESS; $base = $this->getOrderBase($order->getBaseId(), $parts); $data = $this->getData($base, $order->getId(), $params); $urls = $this->getPaymentUrls(); try { $provider = $this->getProvider(); if ($this->getValue('authorize', false) && $provider->supportsAuthorize()) { $response = $provider->authorize($data)->send(); $status = \Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED; } else { $response = $provider->purchase($data)->send(); $status = \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED; } if ($response->isSuccessful()) { $this->saveTransationRef($base, $response->getTransactionReference()); $order->setPaymentStatus($status); $this->saveOrder($order); } elseif ($response->isRedirect()) { if (($ref = $response->getTransactionReference()) != null) { $this->saveTransationRef($base, $ref); } return $this->getRedirectForm($response); } else { $order->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_REFUSED); $this->saveOrder($order); throw new \Aimeos\MShop\Service\Exception($response->getMessage()); } } catch (\Exception $e) { throw new \Aimeos\MShop\Service\Exception($e->getMessage()); } return new \Aimeos\MShop\Common\Item\Helper\Form\Standard($urls['returnUrl'], 'POST', array()); }
/** * Maps the PayPal status to the appropriate payment status and sets it in the order object. * * @param \Aimeos\MShop\Order\Item\Iface $invoice Order invoice object * @param array $response Associative list of key/value pairs containing the PayPal response */ protected function setPaymentStatus(\Aimeos\MShop\Order\Item\Iface $invoice, array $response) { if (!isset($response['PAYMENTSTATUS'])) { return; } switch ($response['PAYMENTSTATUS']) { case 'Pending': if (isset($response['PENDINGREASON'])) { if ($response['PENDINGREASON'] === 'authorization') { $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED); break; } $str = 'PayPal Express: order ID = ' . $invoice->getId() . ', PENDINGREASON = ' . $response['PENDINGREASON']; $this->getContext()->getLogger()->log($str, \Aimeos\MW\Logger\Base::INFO); } $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_PENDING); break; case 'In-Progress': $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_PENDING); break; case 'Completed': case 'Processed': $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_RECEIVED); break; case 'Failed': case 'Denied': case 'Expired': $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_REFUSED); break; case 'Refunded': case 'Partially-Refunded': case 'Reversed': $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_REFUND); break; case 'Canceled-Reversal': case 'Voided': $invoice->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_CANCELED); break; default: $str = 'PayPal Express: order ID = ' . $invoice->getId() . ', response = ' . print_r($response, true); $this->getContext()->getLogger()->log($str, \Aimeos\MW\Logger\Base::INFO); } }
/** * Cancels the authorization for the given order if supported. * * @param \Aimeos\MShop\Order\Item\Iface $order Order invoice object */ public function cancel(\Aimeos\MShop\Order\Item\Iface $order) { $order->setPaymentStatus(\Aimeos\MShop\Order\Item\Base::PAY_CANCELED); $this->saveOrder($order); }