本文整理匯總了PHP中Payum\Core\Bridge\Spl\ArrayObject::toUnsafeArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayObject::toUnsafeArray方法的具體用法?PHP ArrayObject::toUnsafeArray怎麽用?PHP ArrayObject::toUnsafeArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Payum\Core\Bridge\Spl\ArrayObject
的用法示例。
在下文中一共展示了ArrayObject::toUnsafeArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: 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());
}
示例3: execute
/**
* {@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);
}
示例4: getPaymentStatus
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());
}
}
示例5: shouldConvertArrayObjectToPrimitiveArrayMakingSensitiveValueUnsafeAndEraseIt
/**
* @test
*/
public function shouldConvertArrayObjectToPrimitiveArrayMakingSensitiveValueUnsafeAndEraseIt()
{
$sensitiveValue = new SensitiveValue('theCreditCard');
$arrayObject = new ArrayObject();
$arrayObject['creditCard'] = $sensitiveValue;
$arrayObject['email'] = 'bar@example.com';
$primitiveArray = $arrayObject->toUnsafeArray();
$this->assertInternalType('array', $primitiveArray);
$this->assertArrayHasKey('creditCard', $primitiveArray);
$this->assertEquals('theCreditCard', $primitiveArray['creditCard']);
$this->assertArrayHasKey('email', $primitiveArray);
$this->assertEquals('bar@example.com', $primitiveArray['email']);
$this->assertNull($sensitiveValue->peek());
}