/** * {@inheritdoc} * * @param $request Capture */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var $payment SyliusPaymentInterface */ $payment = $request->getModel(); /** @var OrderInterface $order */ $order = $payment->getOrder(); $this->gateway->execute($status = new GetStatus($payment)); if ($status->isNew()) { try { $this->gateway->execute($convert = new Convert($payment, 'array', $request->getToken())); $payment->setDetails($convert->getResult()); } catch (RequestNotSupportedException $e) { $totalAmount = $order->getTotal(); $payumPayment = new PayumPayment(); $payumPayment->setNumber($order->getNumber()); $payumPayment->setTotalAmount($totalAmount); $payumPayment->setCurrencyCode($order->getCurrencyCode()); $payumPayment->setClientEmail($order->getCustomer()->getEmail()); $payumPayment->setClientId($order->getCustomer()->getId()); $payumPayment->setDescription(sprintf('Payment contains %d items for a total of %01.2f', $order->getItems()->count(), round($totalAmount / 100, 2))); $payumPayment->setDetails($payment->getDetails()); $this->gateway->execute($convert = new Convert($payumPayment, 'array', $request->getToken())); $payment->setDetails($convert->getResult()); } } $details = ArrayObject::ensureArrayObject($payment->getDetails()); try { $request->setModel($details); $this->gateway->execute($request); } finally { $payment->setDetails((array) $details); } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request StatusRequestInterface */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } /** @var PaymentInterface $payment */ $payment = $request->getModel(); if (in_array($payment->getState(), array(PaymentInterface::STATE_APPROVED, PaymentInterface::STATE_DEPOSITED))) { $request->markSuccess(); return; } if (in_array($payment->getState(), array(PaymentInterface::STATE_DEPOSITING))) { $request->markPending(); return; } if (in_array($payment->getState(), array(PaymentInterface::STATE_CANCELED))) { $request->markCanceled(); return; } if (in_array($payment->getState(), array(PaymentInterface::STATE_EXPIRED))) { $request->markExpired(); return; } if (in_array($payment->getState(), array(PaymentInterface::STATE_FAILED))) { $request->markFailed(); return; } if (in_array($payment->getState(), array(PaymentInterface::STATE_NEW, PaymentInterface::STATE_APPROVING))) { $request->markNew(); return; } $request->markUnknown(); }
/** * {@inheritDoc} */ public function execute($request) { if (!$this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['_status']) { return; } if (false == $model->validateNotEmpty(array('card'), false)) { try { $creditCardRequest = new ObtainCreditCardRequest(); $this->payment->execute($creditCardRequest); $card = $creditCardRequest->obtain(); $firstName = $lastName = ''; list($firstName, $lastName) = explode(' ', $card->getHolder(), 1); $model['card'] = new SensitiveValue(array('number' => $card->getNumber(), 'cvv' => $card->getSecurityCode(), 'expiryMonth' => $card->getExpireAt()->format('m'), 'expiryYear' => $card->getExpireAt()->format('y'), 'firstName' => $firstName, 'lastName' => $lastName)); } catch (RequestNotSupportedException $e) { throw new LogicException('Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCardRequest request.'); } } $response = $this->gateway->purchase($model->toUnsafeArray())->send(); $model['_reference'] = $response->getTransactionReference(); $model['_status'] = $response->isSuccessful() ? 'success' : 'failed'; $model['_status_code'] = $response->getCode(); $model['_status_message'] = $response->isSuccessful() ? '' : $response->getMessage(); }
/** * {@inheritdoc} */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var GetStatusInterface $request */ $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model['transaction_id']) { $request->markNew(); return; } if (false != ($responseCode = $model['response_code'])) { // Success if ('00' === $responseCode) { $request->markCaptured(); return; } // Cancelled by user if ('17' === $responseCode) { $request->markCanceled(); return; } // Failure $request->markFailed(); return; } $request->markPending(); }
/** * {@inheritDoc} * * @param GetStatusInterface $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['error_code']) { $request->markFailed(); return; } if ($model['invoice_number']) { $request->markCaptured(); return; } if ($model['reservation']) { $request->markAuthorized(); return; } if (false == $model['status'] || Constants::STATUS_CHECKOUT_INCOMPLETE == $model['status']) { $request->markNew(); return; } if (Constants::STATUS_CHECKOUT_COMPLETE == $model['status']) { $request->markPending(); return; } $request->markUnknown(); }
/** * {@inheritdoc} */ public function execute($request) { /** * @var $request \Payum\Core\Request\CaptureRequest */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } /** @var Payment $model */ $model = $request->getModel(); if (false == isset($model->state) && isset($model->payer->payment_method) && 'paypal' == $model->payer->payment_method) { $model->create($this->api); foreach ($model->links as $link) { if ($link->rel == 'approval_url') { throw new RedirectUrlInteractiveRequest($link->href); } } } if (false == isset($model->state) && isset($model->payer->payment_method) && 'credit_card' == $model->payer->payment_method) { $model->create($this->api); } if (true == isset($model->state) && isset($model->payer->payment_method) && 'paypal' == $model->payer->payment_method) { $execution = new PaymentExecution(); $execution->payer_id = $_GET['PayerID']; //Execute the payment $model->execute($execution, $this->api); } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Capture */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = new ArrayObject($request->getModel()); if (is_numeric($model['RESULT'])) { return; } $cardFields = array('ACCT', 'CVV2', 'EXPDATE'); if (false == $model->validateNotEmpty($cardFields, false)) { try { $this->payment->execute($obtainCreditCard = new ObtainCreditCard()); $card = $obtainCreditCard->obtain(); $model['EXPDATE'] = new SensitiveValue($card->getExpireAt()->format('my')); $model['ACCT'] = $card->getNumber(); $model['CVV2'] = $card->getSecurityCode(); } catch (RequestNotSupportedException $e) { throw new LogicException('Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.'); } } $buzzRequest = new Request(); $buzzRequest->setFields($model->toUnsafeArray()); $response = $this->api->doPayment($buzzRequest); $model->replace($response); }
/** * {@inheritDoc} * * @param Notify $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); $this->gateway->execute($httpRequest = new GetHttpRequest()); if (!isset($httpRequest->request['merchantReference']) || empty($httpRequest->request['merchantReference'])) { $details['response_status'] = 401; return; } if (!isset($details['merchantReference']) || $details['merchantReference'] != $httpRequest->request['merchantReference']) { $details['response_status'] = 402; return; } if (false === $this->api->verifyNotification($httpRequest->request)) { $details['response_status'] = 403; return; } // Check notification code if (isset($httpRequest->request['eventCode'])) { $httpRequest->request['authResult'] = $httpRequest->request['eventCode']; if ('AUTHORISATION' == $httpRequest->request['eventCode']) { if ('true' == $httpRequest->request['success']) { $httpRequest->request['authResult'] = 'AUTHORISED'; } elseif (!empty($httpRequest->request['reason'])) { $httpRequest->request['authResult'] = 'REFUSED'; } } } $details['authResult'] = $httpRequest->request['authResult']; $details['response_status'] = 200; }
/** * {@inheritdoc} */ public function execute($request) { /** @var $request CaptureRequest */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model['PAYMENTREQUEST_0_PAYMENTACTION']) { $model['PAYMENTREQUEST_0_PAYMENTACTION'] = Api::PAYMENTACTION_SALE; } if (false == $model['TOKEN']) { if (false == $model['RETURNURL'] && $request instanceof SecuredCaptureRequest) { $model['RETURNURL'] = $request->getToken()->getTargetUrl(); } if (false == $model['CANCELURL'] && $request instanceof SecuredCaptureRequest) { $model['CANCELURL'] = $request->getToken()->getTargetUrl(); } $this->payment->execute(new SetExpressCheckoutRequest($model)); $this->payment->execute(new AuthorizeTokenRequest($model)); } $this->payment->execute(new SyncRequest($model)); if ($model['PAYERID'] && Api::CHECKOUTSTATUS_PAYMENT_ACTION_NOT_INITIATED == $model['CHECKOUTSTATUS'] && $model['PAYMENTREQUEST_0_AMT'] > 0) { $this->payment->execute(new DoExpressCheckoutPaymentRequest($model)); } $this->payment->execute(new SyncRequest($model)); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Sync */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model['token']) { return; } $this->payment->execute(new GetTransactionDetails($model)); if (isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR) { if (isset($model['transaction_status'])) { if ($model['transaction_status'] === TransactionStatus::PAID) { $model['state'] = StateInterface::STATE_CONFIRMED; } else { if ($model['transaction_status'] === TransactionStatus::NOT_PAID) { $model['state'] = StateInterface::STATE_ERROR; } else { if ($model['transaction_status'] === TransactionStatus::PAID_WAITING_FOR_PROCESS) { $model['state'] = StateInterface::STATE_NOTIFIED; } } } } } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Sync */ RequestNotSupportedException::assertSupports($this, $request); $this->payment->execute(new CheckAgreement($request->getModel())); }
/** * {@inheritDoc} */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (null === $model['Signature']) { $request->markNew(); return; } if ($model['Signature'] && null === $model['Status']) { $request->markPending(); return; } switch ($model['Status']) { case Api::PAYMENT_STATUS_AUTHORIZED: $request->markAuthorized(); break; case Api::PAYMENT_STATUS_NOT_AUTHORIZED: $request->markFailed(); break; case Api::PAYMENT_STATUS_PAID: $request->markCaptured(); break; case Api::PAYMENT_STATUS_CANCELED: $request->markCanceled(); break; case Api::PAYMENT_STATUS_WAITING: $request->markPending(); break; default: $request->markUnknown(); break; } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request GetStatusInterface */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (isset($model['status'])) { switch ($model['status']) { case 'NEW': $request->markNew(); break; case 'PAID': $request->markCaptured(); break; case 'CANCELLED_BY_MERCHANT': case 'CANCELLED_BY_ADMIN': $request->markCanceled(); break; case 'EXPIRED': $request->markExpired(); break; case 'INVALID': $request->markFailed(); break; } } }
/** * {@inheritDoc} * * @param ModelAggregateInterface|ModelAwareInterface $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var DetailsAggregateInterface $model */ $model = $request->getModel(); $details = $model->getDetails(); if (is_array($details)) { $details = ArrayObject::ensureArrayObject($details); } $request->setModel($details); try { $this->payment->execute($request); if ($model instanceof DetailsAwareInterface) { $model->setDetails($details); } } catch (\Exception $e) { if ($model instanceof DetailsAwareInterface) { $model->setDetails($details); } throw $e; } }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (null !== $model['token']) { return; } if (false == $model['return_url'] && $request->getToken()) { $model['return_url'] = $request->getToken()->getTargetUrl(); } if (false == $model['cancel_url'] && $request->getToken()) { $model['cancel_url'] = $request->getToken()->getTargetUrl(); } $this->payment->execute(new SetExpressCheckout($model)); if ($model['error_code'] == '00') { if (!isset($model['checkout_url'])) { throw new \LogicException('Payment gateway Nganluong is not returned "checkout_url"'); } throw new HttpRedirect($model['checkout_url']); } else { return; // failed } }
/** * {@inheritDoc} * * @param $request Notify */ public function execute($request) { if (!$this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $this->payment->execute($httpRequest = new GetHttpRequest()); $details = $httpRequest->query; if (!$this->api->verifyHash($details)) { throw new BadRequestHttpException('Hash cannot be verified.'); } if (empty($details['ORDERID'])) { throw new BadRequestHttpException('Order id cannot be guessed'); } $payment = $this->paymentRepository->findOneBy(array($this->identifier => $details['ORDERID'])); if (null === $payment) { throw new BadRequestHttpException('Payment cannot be retrieved.'); } if ((int) $details['AMOUNT'] !== $payment->getAmount()) { throw new BadRequestHttpException('Request amount cannot be verified against payment amount.'); } // Actually update payment details $details = array_merge($payment->getDetails(), $details); $payment->setDetails($details); $status = new GetStatus($payment); $this->payment->execute($status); $nextState = $status->getValue(); $this->updatePaymentState($payment, $nextState); $this->objectManager->flush(); throw new HttpResponse(new Response('OK', 200)); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $postData = ArrayObject::ensureArrayObject($request->getModel()); if (empty($postData['Ds_Merchant_MerchantURL']) && $request->getToken() && $this->tokenFactory) { $notifyToken = $this->tokenFactory->createNotifyToken($request->getToken()->getGatewayName(), $request->getToken()->getDetails()); $postData['Ds_Merchant_MerchantURL'] = $notifyToken->getTargetUrl(); } $postData->validatedKeysSet(array('Ds_Merchant_Amount', 'Ds_Merchant_Order', 'Ds_Merchant_Currency', 'Ds_Merchant_TransactionType', 'Ds_Merchant_MerchantURL')); $postData['Ds_Merchant_MerchantCode'] = $this->api->getMerchantCode(); $postData['Ds_Merchant_Terminal'] = $this->api->getMerchantTerminalCode(); if (false == $postData['Ds_Merchant_UrlOK'] && $request->getToken()) { $postData['Ds_Merchant_UrlOK'] = $request->getToken()->getTargetUrl(); } if (false == $postData['Ds_Merchant_UrlKO'] && $request->getToken()) { $postData['Ds_Merchant_UrlKO'] = $request->getToken()->getTargetUrl(); } $postData['Ds_SignatureVersion'] = Api::SIGNATURE_VERSION; if (false == $postData['Ds_MerchantParameters'] && $request->getToken()) { $postData['Ds_MerchantParameters'] = $this->api->createMerchantParameters($postData->toUnsafeArray()); } if (false == $postData['Ds_Signature']) { $postData['Ds_Signature'] = $this->api->sign($postData->toUnsafeArray()); throw new HttpPostRedirect($this->api->getRedsysUrl(), $postData->toUnsafeArray()); } }
/** * {@inheritdoc} */ public function execute($request) { /* @var $request Notify */ RequestNotSupportedException::assertSupports($this, $request); $this->gateway->execute(new Sync($request->getModel())); throw new HttpResponse('OK', 200); }
/** * {@inheritDoc} * * @param $request Authorize */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var $payment Payment */ $payment = $request->getModel(); $this->gateway->execute($status = new GetHumanStatus($payment)); if ($status->isNew()) { $this->gateway->execute(new ObtainMissingDetailsRequest($payment, $request->getToken())); try { $this->gateway->execute($convert = new Convert($payment, 'array', $request->getToken())); $payment->setDetails($convert->getResult()); } catch (RequestNotSupportedException $e) { $payumPayment = new PayumPayment(); $payumPayment->setNumber($payment->getNumber()); $payumPayment->setTotalAmount($payment->getTotalAmount()); $payumPayment->setCurrencyCode($payment->getCurrencyCode()); $payumPayment->setClientEmail($payment->getPayer()->getEmail()); $payumPayment->setClientId($payment->getPayer()->getId() ?: $payment->getPayer()->getEmail()); $payumPayment->setDescription($payment->getDescription() ?: sprintf('Payment %s', $payment->getNumber())); $payumPayment->setCreditCard($payment->getCreditCard()); $payumPayment->setDetails($payment->getDetails()); $this->gateway->execute($convert = new Convert($payumPayment, 'array', $request->getToken())); $payment->setDetails($convert->getResult()); } } $details = ArrayObject::ensureArrayObject($payment->getDetails()); try { $request->setModel($details); $this->gateway->execute($request); } finally { $payment->setDetails((array) $details); } }
/** * {@inheritdoc} */ public function execute($request) { /** @var $request GetStatusInterface */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); if (null === $model['response_code']) { $request->markNew(); return; } if (\AuthorizeNetAIM_Response::APPROVED == $model['response_code']) { $request->markSuccess(); return; } if (\AuthorizeNetAIM_Response::DECLINED == $model['response_code']) { $request->markCanceled(); return; } if (\AuthorizeNetAIM_Response::ERROR == $model['response_code']) { $request->markFailed(); return; } if (\AuthorizeNetAIM_Response::HELD == $model['response_code']) { $request->markPending(); return; } $request->markUnknown(); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model['token']) { $this->payment->execute(new Log('No token. First....', $this)); if (false == $model['return_url'] && $request->getToken()) { $model['return_url'] = $request->getToken()->getTargetUrl(); } if (false == $model['cancel_url'] && $request->getToken()) { $model['cancel_url'] = $request->getToken()->getTargetUrl(); } $model['state'] = StateInterface::STATE_WAITING; $this->payment->execute(new Log('Waiting for reply when calling SetExpressCheckout', $this)); $this->payment->execute(new SetExpressCheckout($model)); if (isset($model['error_code']) && $model['error_code'] === Errors::ERRCODE_NO_ERROR) { if (isset($model['checkout_url'])) { $model['state'] = StateInterface::STATE_REPLIED; $this->payment->execute(new Log('checkout_url=' . $model['checkout_url'], $this)); throw new HttpRedirect($model['checkout_url']); } else { $model['state'] = StateInterface::STATE_ERROR; $this->payment->execute(new Log('No checkout_url returned.', $this)); } } } else { $this->payment->execute(new Log('Before calling GetTransactionDetails', $this)); $this->logAllModel($model); $copiedModel = new ArrayObject(array('token' => $model['token'])); $this->payment->execute(new GetTransactionDetails($copiedModel)); $this->payment->execute(new Log('After calling GetTransactionDetails', $this)); $this->logAllModel($copiedModel); if ($copiedModel['error_code'] === Errors::ERRCODE_NO_ERROR) { $model['bank_code'] = $copiedModel['bank_code']; $model['transaction_id'] = $copiedModel['transaction_id']; $model['transaction_status'] = $copiedModel['transaction_status']; if ($copiedModel['transaction_status'] == TransactionStatus::PAID) { $model['state'] = StateInterface::STATE_CONFIRMED; $this->payment->execute(new Log('Order paid. OK. OK. OK.', $this)); } else { if ($copiedModel['transaction_status'] == TransactionStatus::NOT_PAID) { $model['state'] = StateInterface::STATE_ERROR; $this->payment->execute(new Log('Payer decided to avoid payment', $this)); } else { if ($copiedModel['transaction_status'] == TransactionStatus::PAID_WAITING_FOR_PROCESS) { $model['state'] = StateInterface::STATE_NOTIFIED; $this->payment->execute(new Log('Payment process notified but not captured.', $this)); } else { $model['state'] = StateInterface::STATE_ERROR; $this->payment->execute(new Log('Payment process return OK but transaction status is not invalid. Unknown error !!!', $this)); } } } } else { $model['state'] = StateInterface::STATE_ERROR; $this->payment->execute(new Log('Error after calling GetTransactionDetails', $this)); } } }
/** * {@inheritDoc} * * @param Convert $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var PaymentInterface $payment */ $payment = $request->getSource(); throw new \LogicException('Not implemented'); }
/** * {@inheritdoc} */ public function execute($request) { /* @var $request Notify */ RequestNotSupportedException::assertSupports($this, $request); $this->gateway->execute(new RefundTransaction($request->getModel())); $this->gateway->execute(new Sync($request->getModel())); }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); if ($details['_status']) { return; } if (false == $details['_completeCaptureRequired']) { if (false == $details->validateNotEmpty(array('card'), false) && false == $details->validateNotEmpty(array('cardReference'), false)) { try { $obtainCreditCard = new ObtainCreditCard($request->getFirstModel(), $request->getModel()); $this->gateway->execute($obtainCreditCard); $card = $obtainCreditCard->obtain(); if ($card->getToken()) { $details['cardReference'] = $card->getToken(); } else { $details['card'] = SensitiveValue::ensureSensitive(array('number' => $card->getNumber(), 'cvv' => $card->getSecurityCode(), 'expiryMonth' => $card->getExpireAt()->format('m'), 'expiryYear' => $card->getExpireAt()->format('y'), 'firstName' => $card->getHolder(), 'lastName' => '')); } } catch (RequestNotSupportedException $e) { throw new LogicException('Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.'); } } } parent::execute($request); }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $httpRequest = new GetHttpRequest(); $this->gateway->execute($httpRequest); if (isset($httpRequest->request[Api::FIELD_V2_HASH])) { $model->replace($httpRequest->request); //validate hash if (false === $this->api->verifyHash($httpRequest->request[Api::FIELD_V2_HASH], $httpRequest->request)) { throw new HttpRedirect((string) $request->getToken()->getAfterUrl()); } } else { //payment canceled if (isset($httpRequest->request[Api::FIELD_PAYMENT_BATCH_NUM]) && (int) $httpRequest->request[Api::FIELD_PAYMENT_BATCH_NUM] === 0) { $model->replace($httpRequest->request); throw new HttpRedirect((string) $request->getToken()->getAfterUrl()); } if (false === isset($model[Api::FIELD_PAYMENT_URL]) && $request->getToken()) { $model[Api::FIELD_PAYMENT_URL] = $request->getToken()->getTargetUrl(); } if (false === isset($model[Api::FIELD_NOPAYMENT_URL]) && $request->getToken()) { $model[Api::FIELD_NOPAYMENT_URL] = $request->getToken()->getTargetUrl(); } throw new HttpPostRedirect($this->api->getApiEndpoint(), $this->api->preparePayment($model->toUnsafeArray())); } }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request Capture */ RequestNotSupportedException::assertSupports($this, $request); $details = ArrayObject::ensureArrayObject($request->getModel()); $details->defaults(array('PAYMENTREQUEST_0_PAYMENTACTION' => Api::PAYMENTACTION_SALE)); if (false == $details['TOKEN']) { if (false == $details['RETURNURL'] && $request->getToken()) { $details['RETURNURL'] = $request->getToken()->getTargetUrl(); } if (false == $details['CANCELURL'] && $request->getToken()) { $details['CANCELURL'] = $request->getToken()->getTargetUrl(); } if (empty($details['PAYMENTREQUEST_0_NOTIFYURL']) && $request->getToken() && $this->tokenFactory) { $notifyToken = $this->tokenFactory->createNotifyToken($request->getToken()->getGatewayName(), $request->getToken()->getDetails()); $details['PAYMENTREQUEST_0_NOTIFYURL'] = $notifyToken->getTargetUrl(); } $this->gateway->execute(new SetExpressCheckout($details)); if ($details['L_ERRORCODE0']) { return; } $this->gateway->execute(new AuthorizeToken($details)); } $this->gateway->execute(new Sync($details)); if ($details['PAYERID'] && Api::CHECKOUTSTATUS_PAYMENT_ACTION_NOT_INITIATED == $details['CHECKOUTSTATUS'] && $details['PAYMENTREQUEST_0_AMT'] > 0) { $this->gateway->execute(new DoExpressCheckoutPayment($details)); } $this->gateway->execute(new Sync($details)); }
/** * {@inheritDoc} * * @param Convert $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var PaymentInterface $payment */ $payment = $request->getSource(); $model = ArrayObject::ensureArrayObject($payment->getDetails()); //$model['DESCRIPTION'] = $payment->getDescription(); if (false == $model['amount']) { $this->gateway->execute($currency = new GetCurrency($payment->getCurrencyCode())); if (2 < $currency->exp) { throw new RuntimeException('Unexpected currency exp.'); } $divisor = pow(10, 2 - $currency->exp); $model['currency_code'] = $currency->numeric; $model['amount'] = abs($payment->getTotalAmount() / $divisor); } if (false == $model['order_id']) { $model['order_id'] = $payment->getNumber(); } if (false == $model['customer_id']) { $model['customer_id'] = $payment->getClientId(); } if (false == $model['customer_email']) { $model['customer_email'] = $payment->getClientEmail(); } $request->setResult((array) $model); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request \Payum\Core\Request\GetStatusInterface */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); //TODO: It may be not correct for all cases. This does NOT indicate wether the transaction requested was successful, only wether the request was carried out successfully. if ($model['errorCode'] && OrderApi::ERRORCODE_OK != $model['errorCode']) { $request->markFailed(); return; } if (is_numeric($model['agreementStatus']) && AgreementApi::AGREEMENTSTATUS_NOTVERIFIED == $model['agreementStatus']) { $request->markNew(); return; } if (is_numeric($model['agreementStatus']) && AgreementApi::AGREEMENTSTATUS_VERIFIED == $model['agreementStatus']) { $request->markSuccess(); return; } if (is_numeric($model['agreementStatus']) && AgreementApi::AGREEMENTSTATUS_DELETED == $model['agreementStatus']) { $request->markCanceled(); return; } $request->markUnknown(); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request GetStatusInterface */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if (false == $model[Constants::FIELD_STATUS] || $model[Constants::FIELD_STATUS] == Constants::STATUS_NEW) { $request->markNew(); return; } if (Constants::STATUS_PENDING == $model[Constants::FIELD_STATUS]) { $request->markPending(); return; } if (Constants::STATUS_CAPTURED == $model[Constants::FIELD_STATUS]) { $request->markCaptured(); return; } if (Constants::STATUS_AUTHORIZED == $model[Constants::FIELD_STATUS]) { $request->markAuthorized(); return; } if (Constants::STATUS_FAILED == $model[Constants::FIELD_STATUS]) { $request->markFailed(); return; } if (Constants::STATUS_REFUNDED == $model[Constants::FIELD_STATUS]) { $request->markRefunded(); return; } if (Constants::STATUS_COMPLAINT == $model[Constants::FIELD_STATUS] || Constants::STATUS_CANCELED == $model[Constants::FIELD_STATUS]) { $request->markCanceled(); return; } $request->markUnknown(); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request \Payum\Core\Request\Capture */ RequestNotSupportedException::assertSupports($this, $request); $this->payment->execute(new AutoPayAgreement($request->getModel())); }