/**
  * @param string $token
  * @param \SubscribePro\Service\PaymentProfile\PaymentProfileInterface $paymentProfile
  * @return \SubscribePro\Service\PaymentProfile\PaymentProfileInterface
  * @throws \SubscribePro\Exception\EntityInvalidDataException
  * @throws \SubscribePro\Exception\HttpException
  */
 public function verifyAndSaveToken($token, PaymentProfileInterface $paymentProfile)
 {
     if (!$paymentProfile->isTokenDataValid()) {
         throw new EntityInvalidDataException('Not all required fields are set.');
     }
     $response = $this->httpClient->post("/services/v1/vault/tokens/{$token}/verifyandstore.json", ['payment_profile' => $paymentProfile->getTokenFormData()]);
     return $this->retrieveItem($response, self::API_NAME_PROFILE, $paymentProfile);
 }
 /**
  * @param array $data
  * @param bool $isValid
  * @dataProvider isTokenDataValidDataProvider
  */
 public function testIsTokenDataValid($data, $isValid)
 {
     $this->billingAddressMock->expects($this->atLeastOnce())->method('importData')->with([])->willReturnSelf();
     $this->paymentProfile->importData($data);
     $this->assertEquals($isValid, $this->paymentProfile->isTokenDataValid());
 }