/** * @param array $data * @param array $billingData * @param bool $isValid * @param bool $isAsChildValid * @dataProvider isThirdPartyDataValidDataProvider */ public function testIsThirdPartyDataValid($data, $billingData, $isValid, $isAsChildValid) { $this->billingAddressMock->expects($this->atLeastOnce())->method('importData')->with($billingData)->willReturnSelf(); if (null === $isAsChildValid) { $this->billingAddressMock->expects($this->never())->method('isAsChildValid'); } else { $this->billingAddressMock->expects($this->atLeastOnce())->method('isAsChildValid')->willReturn($isAsChildValid); } $this->paymentProfile->importData($data); $this->assertEquals($isValid, $this->paymentProfile->isThirdPartyDataValid()); }
/** * @param \SubscribePro\Service\PaymentProfile\PaymentProfileInterface $paymentProfile * @return \SubscribePro\Service\PaymentProfile\PaymentProfileInterface * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ public function saveThirdPartyToken(PaymentProfileInterface $paymentProfile) { if (!$paymentProfile->isThirdPartyDataValid()) { throw new EntityInvalidDataException('Not all required fields are set.'); } $response = $this->httpClient->post('/services/v2/paymentprofile/third-party-token.json', [self::API_NAME_PROFILE => $paymentProfile->getThirdPartyTokenFormData()]); return $this->retrieveItem($response, self::API_NAME_PROFILE, $paymentProfile); }