/** * {@inheritDoc} */ public function execute($request) { /** @var $request DeleteAgreement */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $model->validateNotEmpty(array('agreementRef')); $result = $this->api->delete((array) $model); $model->replace($result); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request AutoPayAgreement */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); $model->validatedKeysSet(array('agreementRef', 'price', 'productNumber', 'description', 'orderId', 'purchaseOperation', 'currency')); $result = $this->api->autoPay((array) $model); $model->replace($result); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request CheckAgreement */ if (false == $this->supports($request)) { throw RequestNotSupportedException::createActionNotSupported($this, $request); } $model = ArrayObject::ensureArrayObject($request->getModel()); $model->validateNotEmpty(array('agreementRef')); $result = $this->api->check((array) $model); $model->replace($result); }
/** * {@inheritDoc} */ public function execute($request) { /** @var $request CreateAgreement */ RequestNotSupportedException::assertSupports($this, $request); $model = ArrayObject::ensureArrayObject($request->getModel()); if ($model['agreementRef']) { throw new LogicException('The agreement has already been created.'); } $model->validatedKeysSet(array('merchantRef', 'description', 'purchaseOperation', 'maxAmount', 'startDate', 'stopDate')); $model->validateNotEmpty(array('maxAmount', 'merchantRef', 'description')); $result = $this->api->create((array) $model); $model->replace($result); }
/** * @test */ public function shouldUseSoapClientOnAgreementAutoPayAndConvertItsResponse() { $response = new \stdClass(); $response->AutoPay3Result = '<foo>fooValue</foo>'; $soapClientMock = $this->getMock('SoapClient', array('AutoPay3'), array(), '', false); $soapClientMock->expects($this->once())->method('AutoPay3')->with($this->isType('array'))->will($this->returnValue($response)); $clientFactoryMock = $this->getMock('Payum\\Payex\\Api\\SoapClientFactory', array('createWsdlClient')); $clientFactoryMock->expects($this->atLeastOnce())->method('createWsdlClient')->will($this->returnValue($soapClientMock)); $agreementApi = new AgreementApi($clientFactoryMock, array('encryptionKey' => 'aKey', 'accountNumber' => 'aNumber', 'sandbox' => true)); $result = $agreementApi->autoPay(array()); $this->assertEquals(array('fooValue'), $result); }