Bitrix Site Manager

CSaleUserAccount::UpdateAccount

int
CSaleUserAccount::UpdateAccount(
 int userID,
 double sum,
 string currency[,
 string description = ""[,
 int orderID = 0[,
 string notes = ""]]]
);

The method UpdateAccount modifies the amount of the account of a specified user.

Parameters

ParameterDescription
userID The user ID.
sum The amount to be added to or subtracted from the account. To increase the account amount, pass positive value. To decrease the account amount, pass negative value. 
currency The currency of the amount.
description Description of the reason to modify the amount.
orderID The order ID (if applicable).
notes Arbitrary description.

Return Values

The method returns the ID of the user account on success, or false otherwise.

Remarks

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

Example



<?
// Callback function called when the flag "Delivery allowed" changes. 
// The function adds or withdraws USD 100 to or from the account.

function MyDeliveryOrderCallback($productID, $userID, $bPaid, $orderID)
{
    global $DB;

    // Process the input parameters
    $productID = IntVal($productID);    // The ID of the ordered product
    $userID = IntVal($userID);  // The customer ID
    $bPaid = ($bPaid ? True : False);   // Set or unset the delivery flag
    $orderID = IntVal($orderID);    // The order ID

    if ($userID <= 0)
        return False;

    if ($orderID <= 0)
        return False;

    // place (withdraw) money to the account
    if (!CSaleUserAccount::UpdateAccount(
            $userID,
            ($bPaid ? 100 : -100),
            "USD",
            "MANUAL",
            $orderID
        ))
        return False;

    return True;
}
?>