protected function getRedirectUrl(FinancialTransactionInterface $transaction) { $data = $transaction->getExtendedData(); $client = $this->requestClient; $client->setAmount($transaction->getPayment()->getApprovingAmount())->setCurrency($transaction->getPayment()->getPaymentInstruction()->getCurrency())->setOrderNumber($transaction->getPayment()->getId())->setReturnUrl($data->get('return_url')); if ($data->has('description')) { $client->setDescription($data->get('description')); } if ($data->has('merchantOrderNumber')) { $client->setMerchantOrderNumber($data->get('merchantOrderNumber')); } return $client->getRequestUrl(); }
/** * @param FinancialTransactionInterface $transaction * * @return array */ protected function getBillData(FinancialTransactionInterface $transaction) { /** @var PaymentInstruction $paymentInstruction */ $paymentInstruction = $transaction->getPayment()->getPaymentInstruction(); $order = $this->getOrderByPaymentInstruction($paymentInstruction); $data = ['bill' => ['order_id' => $order->getId(), 'sum' => $paymentInstruction->getAmount(), 'client_company_name' => $order->getUser()->getCompany()->getName()], 'template' => 'transfer']; return $data; }
/** * @param FinancialTransactionInterface $transaction * * @return array */ protected function getBillData(FinancialTransactionInterface $transaction) { /** @var PaymentInstruction $paymentInstruction */ $paymentInstruction = $transaction->getPayment()->getPaymentInstruction(); $order = $this->getOrderByPaymentInstruction($paymentInstruction); $data = ['bill' => ['order_id' => $order->getId(), 'sum' => $paymentInstruction->getAmount()], 'template' => 'receipt']; return $data; }
public function approveAndDeposit(FinancialTransactionInterface $transaction, $retry) { /** @var $payment \Jms\Payment\CoreBundle\Model\PaymentInterface */ $payment = $transaction->getPayment(); $transaction->setProcessedAmount($payment->getTargetAmount()); $transaction->setState(FinancialTransactionInterface::STATE_SUCCESS); $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS); $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS); }
/** * @param FinancialTransactionInterface $transaction * @param bool $retry */ public function approveAndDeposit(FinancialTransactionInterface $transaction, $retry) { /** @var PaymentInstructionInterface $instruction */ $instruction = $transaction->getPayment()->getPaymentInstruction(); if ($transaction->getState() === FinancialTransactionInterface::STATE_NEW) { /** @var Order $order */ $order = $this->getOrderByPaymentInstruction($instruction); $order->setBillData($this->getBillData($transaction)); throw $this->createRedirectActionException($transaction, $order); } $transaction->setProcessedAmount($instruction->getAmount()); $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS); $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS); }
public function getRedirectUrl(FinancialTransactionInterface $transaction) { /** @var PaymentInstructionInterface $instruction */ $instruction = $transaction->getPayment()->getPaymentInstruction(); $inv_id = $instruction->getId(); /** @var ExtendedDataInterface $data */ $data = $transaction->getExtendedData(); $data->set('inv_id', $inv_id); $description = 'test desc'; if ($data->has('description')) { $description = $data->get('description'); } $parameters = ['MrchLogin' => $this->login, 'OutSum' => $transaction->getRequestedAmount(), 'InvId' => $inv_id, 'Desc' => $description, 'IncCurrLabel' => '', 'IsTest' => $this->test ? 1 : 0, 'Signature' => $this->auth->sign($this->login, $transaction->getRequestedAmount(), $inv_id)]; return $this->getWebServerUrl() . '?' . http_build_query($parameters); }
/** * {@inheritdoc} */ public function approveAndDeposit(FinancialTransactionInterface $transaction, $retry) { try { $data = $transaction->getExtendedData(); $client = $this->api->getClient($data->has('client') ? $data->get('client') : null); $apiTransaction = new \Paymill\Models\Request\Transaction(); $apiTransaction->setToken($data->get('token'))->setClient($client)->setAmount($transaction->getRequestedAmount() * 100)->setCurrency($transaction->getPayment()->getPaymentInstruction()->getCurrency())->setDescription($data->has('description') ? $data->get('description') : null); $apiTransaction = $this->api->create($apiTransaction); } catch (PaymillException $e) { $ex = new FinancialException($e->getErrorMessage()); $ex->setFinancialTransaction($transaction); $transaction->setResponseCode($e->getStatusCode()); $transaction->setReasonCode($e->getResponseCode()); throw $ex; } switch ($apiTransaction->getStatus()) { case 'closed': $transaction->setReferenceNumber($apiTransaction->getId()); $transaction->setProcessedAmount($apiTransaction->getAmount() / 100); $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_SUCCESS); $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS); break; case 'open': case 'pending': $ex = new PaymentPendingException('Payment is still pending'); $transaction->setReferenceNumber($apiTransaction->getId()); $transaction->setResponseCode(PluginInterface::RESPONSE_CODE_PENDING); $transaction->setReasonCode(PluginInterface::REASON_CODE_SUCCESS); $ex->setFinancialTransaction($transaction); throw $ex; default: $ex = new FinancialException('Transaction failed'); $ex->setFinancialTransaction($transaction); $transaction->setResponseCode('Failed'); $transaction->setReasonCode($apiTransaction->getResponseCode()); throw $ex; } }
/** * @param FinancialTransactionInterface $transaction * @return BatchResponse */ private function sendPayment(FinancialTransactionInterface $transaction) { $paymentInstruction = $transaction->getPayment()->getPaymentInstruction(); $file = $this->buildFile($paymentInstruction, self::PAYMENT); $this->logger->debug('Sending payment request to Ogone with file {file}', array('file' => $file)); $xmlResponse = $this->sendBatchRequest($file); return new BatchResponse($xmlResponse); }
/** * @param FinancialTransactionInterface $transaction * @return mixed */ protected function findOrCreatePlan(FinancialTransactionInterface $transaction) { $data = $transaction->getExtendedData(); if ($data->has('plan_id')) { return $data->get('plan_id'); } $opts = $data->has('checkout_params') ? $data->get('checkout_params') : array(); $opts['id'] = array_key_exists('id', $opts) ? $opts['id'] : ''; $response = $this->client->retrievePlan($opts['id']); if (!$response->isSuccess()) { $opts['amount'] = $this->client->convertAmountToStripeFormat($transaction->getRequestedAmount()); $opts['currency'] = $transaction->getPayment()->getPaymentInstruction()->getCurrency(); $opts['interval'] = $this->getIntervalForStripe($transaction->getPayment()->getPaymentInstruction()->getBillingInterval()); $opts['interval_count'] = $transaction->getPayment()->getPaymentInstruction()->getBillingFrequency(); $response = $this->client->createPlan($opts); } $this->throwUnlessSuccessResponse($response, $transaction); $data->set('plan_id', $response->getResponse()->id); return $data->get('plan_id'); }
/** * @param \JMS\Payment\CoreBundle\Model\FinancialTransactionInterface $transaction * @param string $paymentAction * * @throws \JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException if user has to authenticate the token * * @return string */ protected function obtainExpressCheckoutToken(FinancialTransactionInterface $transaction, $paymentAction) { $data = $transaction->getExtendedData(); if ($data->has('express_checkout_token')) { return $data->get('express_checkout_token'); } $opts = $data->has('checkout_params') ? $data->get('checkout_params') : array(); $opts['PAYMENTREQUEST_0_PAYMENTACTION'] = $paymentAction; $opts['PAYMENTREQUEST_0_CURRENCYCODE'] = $transaction->getPayment()->getPaymentInstruction()->getCurrency(); $response = $this->client->requestSetExpressCheckout($transaction->getRequestedAmount(), $this->getReturnUrl($data), $this->getCancelUrl($data), $opts); $this->throwUnlessSuccessResponse($response, $transaction); $data->set('express_checkout_token', $response->body->get('TOKEN')); $authenticateTokenUrl = $this->client->getAuthenticateExpressCheckoutTokenUrl($response->body->get('TOKEN')); $actionRequest = new ActionRequiredException('User must authorize the transaction.'); $actionRequest->setFinancialTransaction($transaction); $actionRequest->setAction(new VisitUrl($authenticateTokenUrl)); throw $actionRequest; }
protected function constructFinancialTransactionResult(FinancialTransactionInterface $transaction, $status, $reasonCode) { $this->financialTransaction = $transaction; $this->credit = $transaction->getCredit(); $this->payment = $transaction->getPayment(); $this->paymentInstruction = null !== $this->credit ? $this->credit->getPaymentInstruction() : $this->payment->getPaymentInstruction(); $this->status = $status; $this->reasonCode = $reasonCode; $this->recoverable = false; }
protected function getGateway(FinancialTransactionInterface $transaction) { $gateways = array('ideal' => 'IDEAL', 'mister_cash' => 'MISTERCASH', 'visa' => 'VISA', 'mastercard' => 'MASTERCARD', 'direct_ebanking' => 'DIRECTBANK', 'giropay' => 'GIROPAY', 'maestro' => 'MAESTRO', 'bank_transfer' => 'BANKTRANS', 'direct_debit' => 'DIRDEB'); $name = substr($transaction->getPayment()->getPaymentInstruction()->getPaymentSystemName(), 13); return isset($gateways[$name]) ? $gateways[$name] : null; }
/** * @param FinancialTransactionInterface $transaction * @return string */ protected function getMethod(FinancialTransactionInterface $transaction) { return substr($transaction->getPayment()->getPaymentInstruction()->getPaymentSystemName(), 7); }