validate( 'purse', 'amount', 'currency', 'description' ); return [ 'InvId' => $this->getInvId(), 'MerchantLogin' => $this->getPurse(), 'OutSum' => $this->getAmount(), 'Description' => $this->getDescription(), 'IncCurrLabel' => $this->getCurrencyLabel(), 'OutSumCurrency' => $this->getCurrency(), 'SignatureValue' => $this->generateSignature(), 'IsTest' => (int) $this->getTestMode(), 'Receipt' => $this->getReceipt(), ] + $this->getCustomFields(); } public function generateSignature() { $params = [ $this->getPurse(), $this->getAmount(), $this->getInvId() ]; if ($this->getCurrency()) { $params[] = $this->getCurrency(); } if ($this->getReceipt()) { $params[] = $this->getReceipt(); } $params[] = $this->getSecretKey(); foreach ($this->getCustomFields() as $field => $value) { $params[] = "$field=$value"; } return md5(implode(':', $params)); } public function getCustomFields() { $fields = array_filter([ 'Shp_TransactionId' => $this->getTransactionId(), 'Shp_Client' => $this->getClient() ]); ksort($fields); return $fields; } public function sendData($data) { return $this->response = new PurchaseResponse($this, $data); } }