本文整理汇总了PHP中Payum\Core\Bridge\Spl\ArrayObject::ensureArrayObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::ensureArrayObject方法的具体用法?PHP ArrayObject::ensureArrayObject怎么用?PHP ArrayObject::ensureArrayObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payum\Core\Bridge\Spl\ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::ensureArrayObject方法的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: createConfig
/**
* {@inheritDoc}
*/
public function createConfig(array $config = array())
{
$config = ArrayObject::ensureArrayObject($config);
$config->defaults($this->defaultConfig);
$config->defaults($this->coreGatewayFactory->createConfig((array) $config));
return (array) $config;
}
示例3: execute
/**
* {@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();
}
示例4: execute
/**
* {@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();
}
示例5: execute
/**
* {@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();
}
示例6: execute
/**
* {@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));
}
}
}
示例7: execute
/**
* {@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;
}
示例8: 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();
}
示例9: execute
/**
* {@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
}
}
示例10: 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));
}
示例11: 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));
}
示例12: 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();
}
示例13: 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();
}
示例14: 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']));
}
示例15: 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);
}
}