Example #1
0
 /**
  * Get the tax percentage to apply to the subscription.
  *
  * @return int
  */
 public function taxPercentage()
 {
     if (!Spark::collectsEuropeanVat()) {
         return 0;
     }
     $vatCalculator = new VatCalculator();
     $vatCalculator->setBusinessCountryCode(Spark::homeCountry());
     return $vatCalculator->getTaxRateForCountry($this->card_country, !empty($this->vat_id)) * 100;
 }
Example #2
0
 /**
  * Returns the tax rate for the given country.
  *
  * @param string $vat_id
  *
  * @throws \Mpociot\VatCalculator\Exceptions\VATCheckUnavailableException
  *
  * @return \Illuminate\Http\Response
  */
 public function validateVATID($vat_id)
 {
     try {
         $isValid = $this->calculator->isValidVATNumber($vat_id);
         $message = '';
     } catch (VATCheckUnavailableException $e) {
         $isValid = false;
         $message = $e->getMessage();
     }
     return ['vat_id' => $vat_id, 'is_valid' => $isValid, 'message' => $message];
 }