Bitrix Site Manager

CSaleUserAccount::Withdraw

double
CSaleUserAccount::Withdraw(
 int userID,
 double paySum,
 string payCurrency[,
 int orderID = 0]
);

The method Withdraw withdraws the specified amount from the internal user account. If there is not enough money on the internal account, the method withdraws maximum available amount.

Parameters

ParameterDescription
userID The user ID.
paySum The amount to withdraw.
payCurrency The currency of the amount to withdraw.
orderID The order ID (if applicable).

Return Values

The method returns the amount actually withdrawn, or false otherwise.

Remarks

The amount is withdrawn only from the account in currency passed in payCurrency. Other user accounts are not affected.

Example



<?
// Pay the order 21 in full or partially from the user's account

$arOrder = CSaleOrder::GetByID(21);

$withdrawSum = CSaleUserAccount::Withdraw(
        $arOrder["USER_ID"],
        $arOrder["PRICE"],
        $arOrder["CURRENCY"],
        $arOrder["ID"]
    );

if ($withdrawSum > 0)
{
    $arFields = array(
            "SUM_PAID" => $withdrawSum,
            "USER_ID" => $arOrder["USER_ID"]
        );
    CSaleOrder::Update($arOrder["ID"], $arFields);

    if ($withdrawSum == $arOrder["PRICE"])
        CSaleOrder::PayOrder($arOrder["ID"], "Y", False, False);
}
?>