本文整理汇总了PHP中Payum\Core\Exception\RequestNotSupportedException::createActionNotSupported方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestNotSupportedException::createActionNotSupported方法的具体用法?PHP RequestNotSupportedException::createActionNotSupported怎么用?PHP RequestNotSupportedException::createActionNotSupported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payum\Core\Exception\RequestNotSupportedException
的用法示例。
在下文中一共展示了RequestNotSupportedException::createActionNotSupported方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritDoc}
*
* @param Capture $request
*/
public function execute($request)
{
if (false == $this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$form = $this->createPurchaseForm();
$form->handleRequest($this->container->get('request'));
if ($form->isValid()) {
$data = $form->getData();
/** @var Cart $cart */
$cart = $request->getModel();
$cartStorage = $this->container->get('payum')->getStorage($cart);
$paymentStorage = $this->container->get('payum')->getStorage('Acme\\PaymentBundle\\Model\\PaymentDetails');
/** @var $payment PaymentDetails */
$payment = $paymentStorage->create();
$payment['amount'] = $cart->getPrice();
$payment['card_num'] = new SensitiveValue($data['card_number']);
$payment['exp_date'] = new SensitiveValue($data['card_expiration_date']);
$paymentStorage->update($payment);
$cart->setDetails($payment);
$cartStorage->update($cart);
$request->setModel($payment);
$this->gateway->execute($request);
return;
}
throw new HttpResponse(new Response($this->container->get('templating')->render('AcmeOtherExamplesBundle:CartExamples:_submit_credit_card.html.twig', array('form' => $form->createView()))));
}
示例2: execute
/**
* {@inheritDoc}
*
* @param Capture $request
*/
public function execute($request)
{
if (!$this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$details = ArrayObject::ensureArrayObject($request->getModel());
if ($details['_status']) {
return;
}
if (false == $details['clientIp']) {
$this->payment->execute($httpRequest = new GetHttpRequest);
$details['clientIp'] = $httpRequest->clientIp;
}
if (isset($details['_completeCaptureRequired'])) {
$response = $this->gateway->completePurchase($details->toUnsafeArray())->send();
unset($details['_completeCaptureRequired']);
} else {
if (false == $details->validateNotEmpty(array('card'), false) && false == $details->validateNotEmpty(array('cardReference'), false)) {
try {
$this->payment->execute($creditCardRequest = new ObtainCreditCard);
$card = $creditCardRequest->obtain();
$details['card'] = new SensitiveValue(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.');
}
}
$response = $this->gateway->purchase($details->toUnsafeArray())->send();
}
if ($response->isRedirect()) {
$details['_completeCaptureRequired'] = 1;
if ($response->getRedirectMethod() == 'POST') {
throw new HttpPostRedirect($response->getRedirectUrl(), $response->getRedirectData());
}
else {
throw new HttpRedirect($response->getRedirectUrl());
}
}
$details['_reference'] = $response->getTransactionReference();
$details['_status'] = $response->isSuccessful() ? 'captured' : 'failed';
$details['_status_code'] = $response->getCode();
$details['_status_message'] = $response->isSuccessful() ? '' : $response->getMessage();
}
示例3: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request ObtainCreditCard */
if (!$this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
if (!$this->httpRequest) {
throw new LogicException('The action can be run only when http request is set.');
}
$form = $this->createCreditCardForm();
$form->handleRequest($this->httpRequest);
if ($form->isSubmitted()) {
/** @var CreditCardInterface $card */
$card = $form->getData();
$card->secure();
if ($form->isValid()) {
$request->set($card);
return;
}
}
$renderTemplate = new RenderTemplate($this->templateName, array(
'form' => $form->createView(),
));
$this->payment->execute($renderTemplate);
throw new HttpResponse(new Response($renderTemplate->getResult(), 200, array(
'Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0',
'Pragma' => 'no-cache',
)));
}
示例4: execute
/**
* {@inheritdoc}
*/
public function execute($request)
{
if (!$this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$options = ArrayObject::ensureArrayObject($request->getModel());
if ($options['_status']) {
return;
}
if (isset($options['_completeCaptureRequired'])) {
unset($options['_completeCaptureRequired']);
$response = $this->gateway->completePurchase($options->toUnsafeArray())->send();
} else {
$response = $this->gateway->purchase($options->toUnsafeArray())->send();
}
if ($response->isRedirect()) {
$options['_completeCaptureRequired'] = 1;
if ($response->getRedirectMethod() == 'POST') {
throw new HttpPostRedirect($response->getRedirectUrl(), $response->getRedirectData());
} else {
throw new HttpRedirect($response->getRedirectUrl());
}
}
$options['_reference'] = $response->getTransactionReference();
$options['_status'] = $response->isSuccessful() ? 'success' : 'failed';
$options['_status_code'] = $response->getCode();
$options['_status_message'] = $response->isSuccessful() ? '' : $response->getMessage();
}
示例5: execute
/**
* {@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();
}
示例6: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request GetStatusInterface */
if (false == $this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$model = ArrayObject::ensureArrayObject($request->getModel());
if ($model['error']) {
$request->markFailed();
return;
}
if (false == $model['card']) {
$request->markNew();
return;
}
// means we have only received a stripe token but have not done a payment.
if (is_string($model['card'])) {
$request->markPending();
return;
}
if (is_array($model['card']) && $model['captured'] && $model['paid']) {
$request->markSuccess();
return;
}
$request->markUnknown();
}
示例7: execute
/**
* {@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));
}
示例8: execute
/**
* {@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));
}
示例9: execute
/**
* {@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);
}
示例10: execute
/**
* {@inheritdoc}
*/
public function execute($request)
{
/** @var $request ObtainCreditCard */
if (false == $this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
if ($this->request->isMethod('POST')) {
$creditCard = new CreditCard();
$creditCard->setHolder($this->request->get('card_holder'));
$creditCard->setNumber($this->request->get('card_number'));
$creditCard->setSecurityCode($this->request->get('card_cvv'));
$creditCard->setExpireAt(new DateTime($this->request->get('card_expire_at')));
$request->set($creditCard);
return;
}
$form = $this->viewFactory->make($this->templateName, ['model' => $request->getModel(), 'firstModel' => $request->getFirstModel(), 'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null]);
throw new HttpResponse(new Response($form->render(), 200, ['Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0', 'X-Status-Code' => 200, 'Pragma' => 'no-cache']));
/*
$content = $this->viewFactory->make($this->templateName, [
'model' => $request->getModel(),
'firstModel' => $request->getFirstModel(),
'form' => $form->render(),
'actionUrl' => $request->getToken() ? $request->getToken()->getTargetUrl() : null,
]);
$this->gateway->execute($renderTemplate);
throw new HttpResponse(new Response($renderTemplate->getResult(), 200, [
'Cache-Control' => 'no-store, no-cache, max-age=0, post-check=0, pre-check=0',
'X-Status-Code' => 200,
'Pragma' => 'no-cache',
]));
*/
}
示例11: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request \Payum\Core\Request\Capture */
if (false == $this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$model = new ArrayObject($request->getModel());
if (null !== $model['EXECCODE']) {
return;
}
$cardFields = array('CARDCODE', 'CARDCVV', 'CARDVALIDITYDATE', 'CARDFULLNAME');
if (false == $model->validateNotEmpty($cardFields, false) && false == $model['ALIAS']) {
try {
$creditCardRequest = new ObtainCreditCard();
$this->payment->execute($creditCardRequest);
$card = $creditCardRequest->obtain();
$model['CARDVALIDITYDATE'] = new SensitiveValue($card->getExpireAt()->format('m-y'));
$model['CARDCODE'] = $card->getNumber();
$model['CARDFULLNAME'] = $card->getHolder();
$model['CARDCVV'] = $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.');
}
}
//instruction must have an alias set (e.g oneclick payment) or credit card info.
if (false == ($model['ALIAS'] || $model->validateNotEmpty($cardFields, false))) {
throw new LogicException('Either credit card fields or its alias has to be set.');
}
$response = $this->api->payment($model->toUnsafeArray());
$model->replace((array) $response->getContentJson());
}
示例12: execute
/**
* {@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();
}
示例13: execute
/**
* {@inheritdoc}
*/
public function execute($request)
{
/** @var $request Capture */
if (false == $this->supports($request)) {
throw RequestNotSupportedException::createActionNotSupported($this, $request);
}
$model = ArrayObject::ensureArrayObject($request->getModel());
if (null != $model['response_code']) {
return;
}
if (false == $model->validateNotEmpty(array('card_num', 'exp_date'), false)) {
try {
$this->payment->execute($obtainCreditCard = new ObtainCreditCard());
$card = $obtainCreditCard->obtain();
$model['exp_date'] = new SensitiveValue($card->getExpireAt()->format('m/y'));
$model['card_num'] = new SensitiveValue($card->getNumber());
} 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.');
}
}
$api = clone $this->api;
$api->ignore_not_x_fields = true;
$api->setFields(array_filter($model->toUnsafeArray()));
$response = $api->authorizeAndCapture();
$model->replace(get_object_vars($response));
}
示例14: execute
/**
* {@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);
}
}
示例15: execute
/**
* {@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();
}