voucherifyClient = createVoucherifyClient(); } /** * @param string $voucherCode * @param float $amount * @param object $employee * @return null|object * @throws ErrorException */ public function execute(string $voucherCode, ?float $amount, ?object $employee) { try { if($amount){ $result = $this->voucherifyClient->validations->validateVoucher($voucherCode, [ "customer" => [ // "id" => $employee->id, "name" => $employee->name, "email" => $employee->email, ], "order" => [ "amount" => $amount * 100 //converting it to cents ] ]); } else{ $res = $this->voucherifyClient->validations->validateVoucher($voucherCode); $result = [ "valid" => $res->valid, "code" => $res->code ]; if (isset($res->reason)) { $result["reason"] = $res->reason; } } return $result; } catch (\Voucherify\ClientException $e) { // throw $e; Log::error('ValidatesVoucher error:' . $e); return null; } } }