/** * @dataProvider getTestData */ public function testWithSomeData($name, $value, $encrypt) { $extendedData = new ExtendedData(); $extendedData->set($name, $value, $encrypt); $this->assertEquals($value, $extendedData->get($name)); if ($encrypt) { $this->assertTrue($extendedData->isEncryptionRequired($name)); } else { $this->assertFalse($extendedData->isEncryptionRequired($name)); } }
public function onPrePersist() { $this->updatedAt = new \DateTime(); if (null !== $this->extendedDataOriginal && null !== $this->extendedData && false === $this->extendedData->equals($this->extendedDataOriginal)) { $this->extendedData = clone $this->extendedData; } }
public function executePayment(BillingRequestInterface $billingRequest) { $paymentProfile = $billingRequest->getPaymentProfile(); if (null !== $paymentProfile && $paymentProfile instanceof CreditCard) { $totalValue = $billingRequest->getPrice(); $ex = new ExtendedData(); $ex->set('cardId', $paymentProfile->getReference(), false, false); /** $result = $this->getBillingService()->doStraightPayment($totalValue, $ex); if ($result->getStatus() == Result::STATUS_SUCCESS) { $billingRequest->setStatus(BillingRequest::STATUS_PAID); $this->gateway->updateBillingRequest($billingRequest); } */ } }
public function onPreSave() { $this->updatedAt = new \Datetime(); // this is necessary until Doctrine adds an interface for comparing // value objects. Right now this is done by referential equality if (null !== $this->extendedDataOriginal && false === $this->extendedData->equals($this->extendedDataOriginal)) { $this->extendedData = clone $this->extendedData; } }
public function reverseTransform($data, array $options) { $method = isset($data['method']) ? $data['method'] : null; $data = isset($data['data_' . $method]) ? $data['data_' . $method] : array(); $extendedData = new ExtendedData(); foreach ($data as $k => $v) { $extendedData->set($k, $v); } if (isset($options['predefined_data'][$method])) { if (!is_array($options['predefined_data'][$method])) { throw new \RuntimeException(sprintf('"predefined_data" is expected to be an array for each method, but got "%s" for method "%s".', json_encode($options['extra_data'][$method]), $method)); } foreach ($options['predefined_data'][$method] as $k => $v) { $extendedData->set($k, $v); } } $amount = $this->computeAmount($options['amount'], $options['currency'], $method, $extendedData); return new PaymentInstruction($amount, $options['currency'], $method, $extendedData); }
public function testConversion() { ExtendedDataType::setEncryptionService(new MCryptEncryptionService('foo')); $extendedData = new ExtendedData(); $extendedData->set('foo', 'foo', false); $extendedData->set('foo2', 'secret', true); $extendedData->set('foo3', 'foo', false); $type = Type::getType(ExtendedDataType::NAME); $serialized = $type->convertToDatabaseValue($extendedData, $this->getPlatform()); $this->assertTrue(false !== ($unserialized = unserialize($serialized))); $this->assertInternalType('array', $unserialized); $this->assertEquals('secret', $extendedData->get('foo2'), 'ExtendedData object is not affected by encryption.'); $this->assertEquals('foo', $extendedData->get('foo'), 'ExtendedData object is not affected by conversion.'); $this->assertEquals('foo', $unserialized['foo'][0]); $this->assertNotEquals('secret', $unserialized['foo2'][0]); $this->assertEquals('foo', $unserialized['foo3'][0]); $extendedData = $type->convertToPHPValue($serialized, $this->getPlatform()); $this->assertEquals('foo', $extendedData->get('foo')); $this->assertEquals('secret', $extendedData->get('foo2')); $this->assertEquals('foo', $extendedData->get('foo')); }
/** * @param \JMS\Payment\CoreBundle\Entity\ExtendedData $data * * @return string|null */ public function getLogo(ExtendedData $data) { return $data->has('logo') ? $data->get('logo') : $this->logo; }
/** * @param string $amount * @param string $currency * @param array $extendedDataValues * * @return \JMS\Payment\CoreBundle\Entity\FinancialTransaction */ protected function createTransaction($amount, $currency, array $extendedDataValues = array('CN' => 'Foo Bar')) { $transaction = new FinancialTransaction(); $transaction->setRequestedAmount($amount); $extendedData = new ExtendedData(); foreach ($extendedDataValues as $key => $value) { $extendedData->set($key, $value); } $paymentInstruction = new PaymentInstruction($amount, $currency, 'ogone_caa', $extendedData); $payment = new Payment($paymentInstruction, $amount); $payment->addTransaction($transaction); return $transaction; }
/** * @param \JMS\Payment\CoreBundle\Entity\ExtendedData $data * * @return string|null */ public function getBackUrl(ExtendedData $data) { return $data->has('backUrl') ? $data->get('backUrl') : $this->backUrl; }
/** * Check that the extended data contains the needed values * before approving and depositing the transation * * @param ExtendedData $data * * @throws BlockedException */ protected function checkExtendedDataBeforeApproveAndDeposit(ExtendedData $data) { if (!$data->has('t_status') || !$data->has('t_id') || !$data->has('amount')) { // if these data are missing, we should wait the response from DotPay // and the transaction should stay in pending state throw new BlockedException("Awaiting extended data from DotPay"); } }