/** * {@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 \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()); }
/** * {@inheritDoc} * * @param Capture $request */ public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); $model = new ArrayObject($request->getModel()); if (null !== $model['EXECCODE']) { return; } if (false == $model['CLIENTUSERAGENT']) { $this->gateway->execute($httpRequest = new GetHttpRequest()); $model['CLIENTUSERAGENT'] = $httpRequest->userAgent; } if (false == $model['CLIENTIP']) { $this->gateway->execute($httpRequest = new GetHttpRequest()); $model['CLIENTIP'] = $httpRequest->clientIp; } $cardFields = array('CARDCODE', 'CARDCVV', 'CARDVALIDITYDATE', 'CARDFULLNAME'); if (false == $model->validateNotEmpty($cardFields, false) && false == $model['ALIAS']) { try { $this->gateway->execute($creditCardRequest = new ObtainCreditCard()); $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.'); } $result = $this->api->payment($model->toUnsafeArray()); $model->replace((array) $result); }
/** * {@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} */ protected function populateConfig(ArrayObject $config) { if (!class_exists('Klarna_Checkout_Order')) { throw new \LogicException('You must install "klarna/checkout" library.'); } $config->defaults(array('payum.factory_name' => 'klarna_checkout', 'payum.factory_title' => 'Klarna Checkout', 'payum.template.authorize' => '@PayumKlarnaCheckout/Action/capture.html.twig', 'contentType' => Constants::CONTENT_TYPE_AGGREGATED_ORDER_V2, 'sandbox' => true)); $config->defaults(array('payum.action.authorize_recurring' => new AuthorizeRecurringAction(), 'payum.action.authorize' => new AuthorizeAction($config['payum.template.authorize']), 'payum.action.notify' => new NotifyAction(), 'payum.action.status' => new StatusAction(), 'payum.action.sync' => new SyncAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.api.create_order' => new CreateOrderAction(), 'payum.action.api.update_order' => new UpdateOrderAction(), 'payum.action.api.fetch_order' => new FetchOrderAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('merchant_id' => '', 'secret' => '', 'terms_uri' => '', 'checkout_uri' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('merchant_id', 'secret'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $klarnaConfig = new Config(); $klarnaConfig->merchantId = $config['merchant_id']; $klarnaConfig->secret = $config['secret']; $klarnaConfig->contentType = $config['contentType']; $klarnaConfig->termsUri = $config['termsUri']; $klarnaConfig->checkoutUri = $config['checkoutUri']; $klarnaConfig->baseUri = $config['sandbox'] ? Constants::BASE_URI_SANDBOX : Constants::BASE_URI_LIVE; return $klarnaConfig; }; } $config['payum.paths'] = array_replace(['PayumKlarnaCheckout' => __DIR__ . '/Resources/views'], $config['payum.paths'] ?: []); }
public function getPaymentStatus(ArrayObject $notificationResponse) { if (!isset($notificationResponse['p24_session_id']) || !isset($notificationResponse['p24_order_id']) || !isset($notificationResponse['p24_amount'])) { throw new \InvalidArgumentException("Missing one of parameter."); } try { $response = $this->httpClient->post($this->getStatusPaymentUrl(), ['form_params' => ['p24_id_sprzedawcy' => $this->gatewayId, 'p24_session_id' => $notificationResponse['p24_session_id'], 'p24_order_id' => $notificationResponse['p24_order_id'], 'p24_kwota' => $notificationResponse['p24_amount'], 'p24_sign' => $this->createHashForPaymentStatus($notificationResponse->toUnsafeArray())]]); return $this->parseResponse($response->getBody()); } catch (RequestException $requestException) { throw new \RuntimeException($requestException->getMessage()); } }
/** * {@inheritdoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'sofortuberweisung', 'payum.factory_title' => 'Sofortuberweisung payment gateway', 'payum.action.capture' => new CaptureAction(), 'payum.action.status' => new StatusAction(), 'payum.action.sync' => new AuthorizeAction(), 'payum.action.authorize' => new SyncAction(), 'payum.action.convert' => new ConvertAction(), 'payum.action.api.request_sofort_uberweisung' => new RequestSofortUberweisungAction(), 'payum.action.api.get_transaction_data' => new GetTransactionDataAction(), 'payum.action.api.fill_order_details' => new ConvertAction(), 'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension()]); if (false == $config['payum.api']) { $config['payum.default_options'] = ['configkey' => '', 'timeout' => 1800]; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['configkey']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api($config->getArrayCopy()); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'perfectmoney', 'payum.factory_title' => 'Perfect Money', 'payum.action.capture' => new CaptureAction(), 'payum.action.status' => new StatusAction(), 'payum.action.convert_payment' => new ConvertPaymentAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = ['sandbox' => true, 'alternate_passphrase' => null, 'payee_account' => null, 'display_name' => null]; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['payee_account', 'alternate_passphrase', 'display_name']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api((array) $config, $config['payum.http_client']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'paymill', 'payum.factory_title' => 'Paymill', 'payum.action.capture' => new CaptureAction(), 'payum.action.transaction' => new TransactionAction(), 'payum.action.status' => new StatusAction(), 'payum.action.convert_payment' => new ConvertPaymentAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = array('api_private_key' => '', 'api_public_key' => '', 'test_private_key' => '', 'test_public_key' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = []; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api((array) $config, $config['payum.http_client']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'skeleton', 'payum.factory_title' => 'skeleton', 'payum.action.capture' => new CaptureAction(), 'payum.action.authorize' => new AuthorizeAction(), 'payum.action.refund' => new RefundAction(), 'payum.action.cancel' => new CancelAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.status' => new StatusAction(), 'payum.action.convert_payment' => new ConvertPaymentAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = array('sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = []; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'be2bill_direct', 'payum.factory_title' => 'Be2Bill Direct', 'payum.action.capture' => new CaptureAction(), 'payum.action.status' => new StatusAction(), 'payum.action.convert_payment' => new ConvertPaymentAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('identifier' => '', 'password' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('identifier', 'password'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api(array('identifier' => $config['identifier'], 'password' => $config['password'], 'sandbox' => $config['sandbox']), $config['payum.http_client'], $config['httplug.message_factory']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'payu', 'payum.factory_title' => 'PayU', 'payum.action.capture' => new CaptureAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.status' => new StatusAction(), 'payum.action.set_payu' => new SetPayUAction(), 'payum.action.notify' => new NotifyAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('environment' => 'secure', 'pos_id' => '', 'signature_key' => ''); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('environment', 'pos_id', 'signature_key'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $payuConfig = array('environment' => $config['environment'], 'pos_id' => $config['pos_id'], 'signature_key' => $config['signature_key']); return $payuConfig; }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'yandex_money', 'payum.factory_title' => 'Yandex Money', 'payum.action.capture' => new CaptureAction(), 'payum.action.notify' => new NotifyAction($config['payum.security.token_storage']), 'payum.action.notify_null' => new NotifyNullAction(), 'payum.action.status' => new StatusAction(), 'payum.action.convert_payment' => new ConvertPaymentAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('account' => null, 'secret' => null); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('account'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $apiConfig = array('account' => $config['account'], 'secret' => $config['secret']); return new Api($apiConfig); }; } }
/** * * @param ArrayObject $config */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'dotpay', 'payum.factory_title' => 'Dotpay', 'payum.action.capture' => new CaptureAction(), 'payum.action.status' => new StatusAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.sync' => new SyncAction($config), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.api.do_payment' => new DoPaymentAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = ['id' => '', 'URLC' => '', 'endpoint' => Api::DEFAULT_ENDPOINT, 'method' => 'GET']; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['id']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $dotpayConfig = ['id' => $config['id'], 'URLC' => $config['URLC'], 'endpoint' => $config['endpoint'], 'method' => $config['method'], 'url' => $config['url'], 'type' => $config['type'], 'PIN' => $config['PIN'], 'ip' => $config['ip']]; return new Api($dotpayConfig, $config['payum.http_client']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'paypal_pro_checkout_nvp', 'payum.factory_title' => 'PayPal ProCheckout', 'payum.action.capture' => new CaptureAction(), 'payum.action.refund' => new RefundAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.status' => new StatusAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('username' => '', 'password' => '', 'partner' => '', 'vendor' => '', 'tender' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('username', 'password', 'partner', 'vendor', 'tender'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $paypalConfig = array('username' => $config['username'], 'password' => $config['password'], 'partner' => $config['partner'], 'vendor' => $config['vendor'], 'tender' => $config['tender'], 'sandbox' => $config['sandbox']); return new Api($paypalConfig, $config['payum.http_client'], $config['httplug.message_factory']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'paypal_masspay_nvp', 'payum.factory_title' => 'PayPal Masspay', 'payum.action.payout' => new PayoutAction(), 'payum.action.api.masspay' => new MasspayAction(), 'payum.action.convert_payout' => new ConvertPayoutAction(), 'payum.action.get_payout_status' => new GetPayoutStatusAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('username' => '', 'password' => '', 'signature' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('username', 'password', 'signature'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $paypalConfig = ['username' => $config['username'], 'password' => $config['password'], 'signature' => $config['signature'], 'sandbox' => $config['sandbox']]; return new Api($paypalConfig, $config['payum.http_client'], $config['httplug.message_factory']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'adyen', 'payum.factory_title' => 'Adyen']); $config->defaults(['payum.action.capture' => new CaptureAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.status' => new StatusAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = ['skinCode' => '', 'merchantAccount' => '', 'hmacKey' => '', 'sandbox' => true, 'notification_method' => 'basic', 'default_payment_fields' => []]; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['skinCode', 'merchantAccount', 'hmacKey']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api(['skinCode' => $config['skinCode'], 'merchantAccount' => $config['merchantAccount'], 'hmacKey' => $config['hmacKey'], 'sandbox' => $config['sandbox'], 'notification_method' => $config['notification_method'], 'default_payment_fields' => $config['default_payment_fields']], $config['payum.http_client']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(['payum.factory_name' => 'paypal_pro_hosted', 'payum.factory_title' => 'Paypal Pro Hosted', 'payum.action.capture' => new CaptureAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.status' => new StatusAction(), 'payum.action.sync' => new SyncAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.api.get_transaction_details' => new GetTransactionDetailsAction(), 'payum.action.api.create_button_payment' => new CreateButtonPaymentAction()]); if (false == $config['payum.api']) { $config['payum.default_options'] = ['username' => '', 'password' => '', 'signature' => '', 'business' => '', 'sandbox' => true]; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['username', 'password', 'signature']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $paypalConfig = array('username' => $config['username'], 'password' => $config['password'], 'signature' => $config['signature'], 'business' => $config['business'], 'sandbox' => $config['sandbox']); return new Api($paypalConfig, $config['payum.http_client'], $config['httplug.message_factory']); }; } }
/** * {@inheritDoc} */ protected function populateConfig(ArrayObject $config) { $config->defaults(array('payum.factory_name' => 'paypal_express_checkout_nvp', 'payum.factory_title' => 'PayPal ExpressCheckout', 'payum.action.capture' => new CaptureAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.status' => new PaymentDetailsStatusAction(), 'payum.action.sync' => new PaymentDetailsSyncAction(), 'payum.action.recurring_status' => new RecurringPaymentDetailsStatusAction(), 'payum.action.recurring_sync' => new RecurringPaymentDetailsSyncAction(), 'payum.action.api.set_express_checkout' => new SetExpressCheckoutAction(), 'payum.action.api.get_express_checkout_details' => new GetExpressCheckoutDetailsAction(), 'payum.action.api.get_transaction_details' => new GetTransactionDetailsAction(), 'payum.action.api.do_express_checkout_payment' => new DoExpressCheckoutPaymentAction(), 'payum.action.api.create_recurring_payment_profile' => new CreateRecurringPaymentProfileAction(), 'payum.action.api.update_recurring_payment_profile' => new UpdateRecurringPaymentProfileAction(), 'payum.action.api.get_recurring_payments_profile_details' => new GetRecurringPaymentsProfileDetailsAction(), 'payum.action.api.cancel_recurring_payments_profile' => new CancelRecurringPaymentsProfileAction(), 'payum.action.api.manage_recurring_payments_profile_status' => new ManageRecurringPaymentsProfileStatusAction(), 'payum.action.api.create_billing_agreement' => new CreateBillingAgreementAction(), 'payum.action.api.do_reference_transaction' => new DoReferenceTransactionAction(), 'payum.action.api.authorize_token' => new AuthorizeTokenAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = array('username' => '', 'password' => '', 'signature' => '', 'sandbox' => true); $config->defaults($config['payum.default_options']); $config['payum.required_options'] = array('username', 'password', 'signature'); $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); $paypalConfig = array('username' => $config['username'], 'password' => $config['password'], 'signature' => $config['signature'], 'sandbox' => $config['sandbox']); return new Api($paypalConfig, $config['payum.http_client']); }; } }
/** * {@inheritdoc} */ public function execute($request) { /** @var $request DoCapture */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $paymentRequestN = $request->getPaymentRequestN(); $fields = new ArrayObject([]); foreach ($this->getPaymentRequestNFields() as $field) { $fields[$field] = $model['PAYMENTREQUEST_' . $paymentRequestN . '_' . $field]; } $fields['AUTHORIZATIONID'] = $fields['TRANSACTIONID']; $fields->validateNotEmpty(['AMT', 'COMPLETETYPE', 'AUTHORIZATIONID']); $this->api->doCapture((array) $fields); $this->gateway->execute(new GetTransactionDetails($model, $paymentRequestN)); }
/** * {@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) { 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} * * @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} * * @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} * * @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) { 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} */ 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} */ protected function populateConfig(ArrayObject $config) { if (false == class_exists(Sofortueberweisung::class)) { throw new LogicException('You must install "sofort/sofortlib-php:^3.0" library.'); } $config->defaults(array('payum.factory_name' => 'sofort', 'payum.factory_title' => 'Sofort', 'payum.action.capture' => new CaptureAction(), 'payum.action.status' => new StatusAction(), 'payum.action.notify' => new NotifyAction(), 'payum.action.sync' => new SyncAction(), 'payum.action.refund' => new RefundAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.api.create_transaction' => new CreateTransactionAction(), 'payum.action.api.get_transaction_data' => new GetTransactionDataAction(), 'payum.action.api.refund_transaction' => new RefundTransactionAction())); if (false == $config['payum.api']) { $config['payum.default_options'] = ['config_key' => '', 'abort_url' => '']; $config->defaults($config['payum.default_options']); $config['payum.required_options'] = ['config_key']; $config['payum.api'] = function (ArrayObject $config) { $config->validateNotEmpty($config['payum.required_options']); return new Api(['config_key' => $config['config_key'], 'abort_url' => $config['abort_url']]); }; } }
/** * {@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 createConfig(array $config = array()) { $config = ArrayObject::ensureArrayObject($config); $config->defaults($this->defaultConfig); $config->defaults(array('payum.template.layout' => '@PayumCore/layout.html.twig', 'payum.http_client' => HttpClientFactory::create(), 'guzzle.client' => HttpClientFactory::createGuzzle(), 'twig.env' => function (ArrayObject $config) { $loader = new \Twig_Loader_Filesystem(); foreach ($config['payum.paths'] as $namespace => $path) { $loader->addPath($path, $namespace); } return new \Twig_Environment($loader); }, 'payum.action.get_http_request' => new GetHttpRequestAction(), 'payum.action.capture_payment' => new CapturePaymentAction(), 'payum.action.execute_same_request_with_model_details' => new ExecuteSameRequestWithModelDetailsAction(), 'payum.action.render_template' => function (ArrayObject $config) { return new RenderTemplateAction($config['twig.env'], $config['payum.template.layout']); }, 'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension(), 'payum.action.get_currency' => function (ArrayObject $config) { return new GetCurrencyAction($config['payum.iso4217']); }, 'payum.prepend_actions' => array(), 'payum.prepend_extensions' => array(), 'payum.prepend_apis' => array(), 'payum.default_options' => array(), 'payum.required_options' => array(), 'payum.api.http_client' => function (ArrayObject $config) { return $config['payum.http_client']; }, 'payum.security.token_storage' => null)); if ($config['payum.security.token_storage']) { $config['payum.action.get_token'] = function (ArrayObject $config) { return new GetTokenAction($config['payum.security.token_storage']); }; } $config['payum.paths'] = array_replace(['PayumCore' => __DIR__ . '/Resources/views'], $config['payum.paths'] ?: []); return (array) $config; }