本文整理汇总了PHP中Payum\Core\Exception\RequestNotSupportedException::assertSupports方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestNotSupportedException::assertSupports方法的具体用法?PHP RequestNotSupportedException::assertSupports怎么用?PHP RequestNotSupportedException::assertSupports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payum\Core\Exception\RequestNotSupportedException
的用法示例。
在下文中一共展示了RequestNotSupportedException::assertSupports方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@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);
}
}
示例2: execute
/**
* {@inheritDoc}
*
* @param Capture $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var $order OrderInterface */
$order = $request->getModel();
$this->payment->execute($status = new GetHumanStatus($order));
if ($status->isNew()) {
$this->payment->execute(new FillOrderDetails($order, $request->getToken()));
}
$details = ArrayObject::ensureArrayObject($order->getDetails());
$request->setModel($details);
try {
$this->payment->execute($request);
$order->setDetails($details);
} catch (\Exception $e) {
$order->setDetails($details);
throw $e;
}
}
示例3: execute
/**
* {@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);
}
示例4: execute
/**
* {@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);
}
}
示例5: execute
/**
* {@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()));
}
示例6: execute
/**
* {@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()));
}
}
示例7: execute
/**
* {@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());
}
}
示例8: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request SetExpressCheckout */
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
/*
if ( false == $model->validateNotEmpty( array('payment_method', 'payment_type'), false ) )
{
try
{
$this->execute( $paymentInfoRequest = new GetPaymentMethod($model) );
$paymentInfo = $paymentInfoRequest->getInfo();
$model['payment_method'] = $paymentInfo['payment_method'];
$model['payment_type'] = $paymentInfo['payment_type'];
}
catch (RequestNotSupportedException $e) {
throw new LogicException('Payment info (method, type, ...)) has to be set explicitly or there has to be an action that supports PaymentMethod request.');
}
}
*/
$model['payment_method'] = 'VISA';
$model['payment_type'] = 1;
$model->validateNotEmpty(array('total_amount', 'cur_code', 'order_code', 'payment_method', 'payment_type'));
$model->replace($this->api->setExpressCheckout((array) $model));
}
示例9: execute
/**
* {@inheritDoc}
*/
public function execute($request)
{
/** @var $request \Payum\Core\Request\Capture */
RequestNotSupportedException::assertSupports($this, $request);
$this->payment->execute(new AutoPayAgreement($request->getModel()));
}
示例10: execute
/**
* {@inheritDoc}
*
* @param GetStatusInterface $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$details = ArrayObject::ensureArrayObject($request->getModel());
if ($details['error_code']) {
$request->markFailed();
return;
}
if ($details['canceled']) {
$request->markCanceled();
return;
}
if ($details['invoice_number']) {
$request->markSuccess();
return;
}
if (false == $details['status']) {
$request->markNew();
return;
}
if (\KlarnaFlags::ACCEPTED == $details['status'] || \KlarnaFlags::PENDING == $details['status']) {
//authorized but not capture, there must be a separate status for it, pending for now.
$request->markPending();
return;
}
if (\KlarnaFlags::DENIED == $details['status']) {
$request->markFailed();
return;
}
$request->markUnknown();
}
示例11: execute
/**
* {@inheritDoc}
*
* @param Capture $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
if (null != $model['response_code']) {
return;
}
if (false == $model->validateNotEmpty(array('card_num', 'exp_date'), false)) {
try {
$obtainCreditCard = new ObtainCreditCard($request->getToken());
$obtainCreditCard->setModel($request->getFirstModel());
$obtainCreditCard->setModel($request->getModel());
$this->gateway->execute($obtainCreditCard);
$card = $obtainCreditCard->obtain();
$model['exp_date'] = SensitiveValue::ensureSensitive($card->getExpireAt()->format('m/y'));
$model['card_num'] = SensitiveValue::ensureSensitive($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));
}
示例12: execute
/**
* {@inheritDoc}
*
* @param Authorize $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
if ($model['reservation']) {
return;
}
$model['activate'] = false;
$backupConfig = clone $this->config;
$token = $model['recurring_token'];
try {
unset($model['recurring_token']);
$baseUri = Constants::BASE_URI_LIVE == $backupConfig->baseUri ? Constants::BASE_URI_RECURRING_LIVE : Constants::BASE_URI_RECURRING_SANDBOX;
$this->config->contentType = Constants::CONTENT_TYPE_RECURRING_ORDER_V1;
$this->config->acceptHeader = Constants::ACCEPT_HEADER_RECURRING_ORDER_ACCEPTED_V1;
$this->config->baseUri = str_replace('{recurring_token}', $token, $baseUri);
$this->gateway->execute($createOrderRequest = new CreateOrder($model));
$model->replace($createOrderRequest->getOrder()->marshal());
} catch (\Exception $e) {
$this->config->contentType = $backupConfig->contentType;
$this->config->acceptHeader = $backupConfig->acceptHeader;
$this->config->baseUri = $backupConfig->baseUri;
$model['recurring_token'] = $token;
throw $e;
}
$model['recurring_token'] = $token;
$this->config->contentType = $backupConfig->contentType;
$this->config->acceptHeader = $backupConfig->acceptHeader;
$this->config->baseUri = $backupConfig->baseUri;
}
示例13: execute
/**
* {@inheritDoc}
*
* @param PopulateKlarnaFromDetails $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$details = ArrayObject::ensureArrayObject($request->getModel());
$klarna = $request->getKlarna();
if ($details['articles']) {
foreach ($details['articles'] as $article) {
$article = ArrayObject::ensureArrayObject($article);
$klarna->addArticle(utf8_decode($article['qty']), utf8_decode($article['artNo']), utf8_decode($article['title']), utf8_decode($article['price']), utf8_decode($article['vat']), utf8_decode($article['discount']), $article['flags'] ?: \KlarnaFlags::NO_FLAG);
}
}
if ($details['partial_articles']) {
foreach ($details['partial_articles'] as $article) {
$klarna->addArtNo(utf8_decode($article['qty']), utf8_decode($article['artNo']));
}
}
if ($details['shipping_address']) {
$address = ArrayObject::ensureArrayObject($details['shipping_address']);
$klarna->setAddress(\KlarnaFlags::IS_SHIPPING, new \KlarnaAddr(utf8_decode($address['email']), utf8_decode($address['telno']), utf8_decode($address['cellno']), utf8_decode($address['fname']), utf8_decode($address['lname']), utf8_decode($address['careof']), utf8_decode($address['street']), utf8_decode($address['zip']), utf8_decode($address['city']), utf8_decode($address['country']), utf8_decode($address['house_number']), utf8_decode($address['house_extension'])));
}
if ($details['billing_address']) {
$address = ArrayObject::ensureArrayObject($details['billing_address']);
$klarna->setAddress(\KlarnaFlags::IS_BILLING, new \KlarnaAddr(utf8_decode($address['email']), utf8_decode($address['telno']), utf8_decode($address['cellno']), utf8_decode($address['fname']), utf8_decode($address['lname']), utf8_decode($address['careof']), utf8_decode($address['street']), utf8_decode($address['zip']), utf8_decode($address['city']), utf8_decode($address['country']), utf8_decode($address['house_number']), utf8_decode($address['house_extension'])));
}
if ($details['estore_info']) {
$estoreInfo = ArrayObject::ensureArrayObject($details['estore_info']);
$klarna->setEstoreInfo(utf8_decode($estoreInfo['order_id1']), utf8_decode($estoreInfo['order_id2']), utf8_decode($estoreInfo['username']));
}
$klarna->setComment(utf8_decode($details['comment']));
}
示例14: execute
/**
* {@inheritDoc}
*
* @param ActivateReservation $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$details = ArrayObject::ensureArrayObject($request->getModel());
$klarna = $this->getKlarna();
try {
$this->payment->execute(new PopulateKlarnaFromDetails($details, $klarna));
$result = $klarna->activateReservation(
$details['pno'],
$details['rno'],
$details['gender'],
$details['ocr'],
$details['activate_reservation_flags'] ?: \KlarnaFlags::NO_FLAG
);
$details['risk_status'] = $result[0];
$details['invoice_number'] = $result[1];
} catch (\KlarnaException $e) {
$this->populateDetailsWithError($details, $e, $request);
}
}
示例15: execute
/**
* {@inheritDoc}
*
* @param Convert $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var PaymentInterface $payment */
$payment = $request->getSource();
throw new \LogicException('Not implemented');
}