publicKey = $this->generateToken(64); $this->deleted = 0; $this->groups = new ArrayCollection(); } /** * @param int $length * @return bool|string */ private function generateToken($length = 64){ $hash = ""; while(strlen($hash) < $length){ try { $hash .= hash('sha512', random_bytes($length)); } catch (\Exception $e) { $hash .= hash('sha512', mt_rand(0,$length*10000)); } } return substr($hash, 0,$length); } /** * use to change the pk if its not unique */ public function regeneratePublicKey(){ $this->publicKey = $this->generateToken(); } /** * @param array $_element */ public function hydrate(array $_element){ foreach ($_element as $key => $value){ $method = 'set' . ucfirst($key); if (method_exists($this, $method)) $this->$method($value); } } /** * @return int|mixed */ public function getId() { return $this->id; } /** * @return mixed */ public function getName() { return $this->name; } /** * @param mixed $name * @return PaymentMode */ public function setName(?string $name) { $this->name = $name; return $this; } /** * @return mixed */ public function getCertificate() { if($this->context == "TEST") return $this->certificateTest; else return $this->certificateProd; } /** * @param mixed $certificateTest * @return PaymentMode */ public function setCertificateTest(?string $certificateTest) { $this->certificateTest = $certificateTest; return $this; } /** * @param mixed $certificateProd * @return PaymentMode */ public function setCertificateProd(?string $certificateProd) { $this->certificateProd = $certificateProd; return $this; } /** * @return mixed */ public function getDescription() { return $this->description; } /** * @param mixed $description * @return PaymentMode */ public function setDescription(?string $description) { $this->description = $description; return $this; } /** * @return string|null */ public function getPublicKey(): ?string { return $this->publicKey; } /** * @return bool|null */ public function getDeleted(): ?bool { return $this->deleted; } /** * @param bool $deleted * @return PaymentMode */ public function setDeleted(bool $deleted): self { $this->deleted = $deleted; return $this; } public function getUrlPayment(): ?string { if($this->context == "TEST") return $this->urlPaymentTest; else return $this->urlPaymentProd; } public function setUrlPaymentTest(?string $urlPaymentTest): self { $this->urlPaymentTest = $urlPaymentTest; return $this; } public function setUrlPaymentProd(?string $urlPaymentProd): self { $this->urlPaymentProd = $urlPaymentProd; return $this; } public function getShopKey(): ?string { if($this->context == "TEST") return $this->shopKeyTest; else return $this->shopKeyProd; } public function setShopKeyTest(?string $shopKeyTest): self { $this->shopKeyTest = $shopKeyTest; return $this; } public function setShopKeyProd(?string $shopKeyProd): self { $this->shopKeyProd = $shopKeyProd; return $this; } public function getRang(): ?int { if($this->context == "TEST") return $this->rangTest; else return $this->rangProd; } public function setRangTest(?string $rangTest): self { $this->rangTest = $rangTest; return $this; } public function setRangProd(?string $rangProd): self { $this->rangProd = $rangProd; return $this; } /** * @return mixed */ public function getContext() { return $this->context; } /** * @param mixed $context * @return PaymentMode */ public function setContext(?string $context) { $this->context = $context; return $this; } /** * @param mixed $identifierTest * @return PaymentMode */ public function setIdentifierTest(?string $identifierTest) { $this->identifierTest = $identifierTest; return $this; } /** * @param mixed $identifierProd * @return PaymentMode */ public function setIdentifierProd(?string $identifierProd) { $this->identifierProd = $identifierProd; return $this; } /** * @return mixed */ public function getIdentifier() { if($this->context == "TEST") return $this->identifierTest; else return $this->identifierProd; } /** * @return mixed */ public function getUrlPaymentTest() { return $this->urlPaymentTest; } /** * @return mixed */ public function getUrlPaymentProd() { return $this->urlPaymentProd; } /** * @return mixed */ public function getCertificateTest() { return $this->certificateTest; } /** * @return mixed */ public function getCertificateProd() { return $this->certificateProd; } /** * @return mixed */ public function getShopKeyTest() { return $this->shopKeyTest; } /** * @return mixed */ public function getShopKeyProd() { return $this->shopKeyProd; } /** * @return mixed */ public function getRangTest() { return $this->rangTest; } /** * @return mixed */ public function getRangProd() { return $this->rangProd; } /** * @return mixed */ public function getIdentifierTest() { return $this->identifierTest; } /** * @return mixed */ public function getIdentifierProd() { return $this->identifierProd; } public function setPublicKey(string $publicKey): self { $this->publicKey = $publicKey; return $this; } /** * @return Collection|PaymentGroup[] */ public function getGroups(): Collection { return $this->groups; } public function addGroup(PaymentGroup $group): self { if (!$this->groups->contains($group)) { $this->groups[] = $group; } return $this; } public function removeGroup(PaymentGroup $group): self { if ($this->groups->contains($group)) { $this->groups->removeElement($group); } return $this; } public function getUrlReturnSuccess(): ?string { return $this->urlReturnSuccess; } public function setUrlReturnSuccess(?string $urlReturnSuccess): self { $this->urlReturnSuccess = $urlReturnSuccess; return $this; } public function getUrlReturnError(): ?string { return $this->urlReturnError; } public function setUrlReturnError(?string $urlReturnError): self { $this->urlReturnError = $urlReturnError; return $this; } public function getCurrency(): ?string { return $this->currency; } public function setCurrency(?string $currency): self { $this->currency = $currency; return $this; } public function getTerminal(): ?string { return $this->terminal; } public function setTerminal(?string $terminal): self { $this->terminal = $terminal; return $this; } public function getPaypalCustom(): ?string { return $this->paypalCustom; } public function setPaypalCustom(?string $paypalCustom): self { $this->paypalCustom = $paypalCustom; return $this; } public function getPaymentType(): ?string { return $this->paymentType; } public function setPaymentType(string $paymentType): self { $this->paymentType = $paymentType; return $this; } public function getExternalId(): ?int { return $this->externalId; } public function setExternalId(?int $externalId): self { $this->externalId = $externalId; return $this; } public function getCompanyName(): ?string { return $this->companyName; } public function setCompanyName(?string $companyName): self { $this->companyName = $companyName; return $this; } }