$this->_params = $this->prepareParamsForPaymentProcessor($this->_params);
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
- $this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
$paymentParams['fee_amount'] = NULL;
$paymentParams['description'] = $this->getSourceText();
try {
+ $paymentParams['invoiceID'] = $this->getInvoiceID();
$result = $payment->doPayment($paymentParams);
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
'total_amount' => $params['amount'],
'tax_amount' => $params['tax_amount'],
'amount_level' => $params['amount_level'],
- 'invoice_id' => $params['invoiceID'],
+ 'invoice_id' => $this->getInvoiceID(),
'currency' => $this->getCurrency(),
'source' => $this->getSourceText(),
'is_pay_later' => FALSE,
]), $maxLength);
}
+ /**
+ * @return string
+ */
+ public function getInvoiceID(): string {
+ if (!$this->invoiceID) {
+ $this->invoiceID = md5(uniqid(rand(), TRUE));
+ }
+ return $this->invoiceID;
+ }
+
}