Skip to content

Instantly share code, notes, and snippets.

@rwsite
Last active October 24, 2024 08:46
Show Gist options
  • Save rwsite/b5bfaea95524248f1ad73ff0db21ec1e to your computer and use it in GitHub Desktop.
Save rwsite/b5bfaea95524248f1ad73ff0db21ec1e to your computer and use it in GitHub Desktop.
Холдирование бонусов
/**
* Hold money.
* Hold customer's money in loyalty program. Payment will be process on POS during processing of an order.
*
* Удерживание денег клиентов в программе лояльности. Оплата будет произведена на POS-терминале во время обработки заказа.
*
* @param string $customerId
* @param string $walletId
* @param int|string $sum
* @param string|null $comment
* @param null|string $organizationId
*
* @return string transaction UUID
* @link https://api-ru.iiko.services/api/1/loyalty/iiko/customer/wallet/hold
*/
public function hold_money($customerId, $walletId, $sum, $comment, $organizationId = null): string
{
$result = $this->get_remote_html(
[
'remote_url' => $this->settings->serv.'loyalty/iiko/customer/wallet/hold',
'method' => 'post',
'body' => [
'transactionId' => null,
'customerId' => $customerId,
'walletId' => $walletId,
'sum' => $sum,
'comment' => $comment,
'organizationId' => $organizationId ?? $this->settings->rest_id,
],
]
);
if (empty($result['transactionId'])) {
throw new Exception('Hold money request error');
}
return $result['transactionId'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment