Documentation

Add

Description and parameters

int
CSaleUserCards::Add(
 array arFields
);

The method Add adds information about a new user credit card.

Parameters

ParameterDescription
arFields An associated array of the credit card parameters with the following keys:
  • USER_ID - the user ID;
  • SORT - sort weight;
  • PAY_SYSTEM_ACTION_ID - the ID of the payment system handler;
  • CURRENCY - the currency in which money can be withdrawn;
  • CARD_CODE - the CVC2 code;
  • CARD_TYPE - the type of the card;
  • CARD_NUM - the credit card number;
  • CARD_EXP_MONTH - the month of the credit card expiration;
  • CARD_EXP_YEAR - the year of the credit card expiration;
  • DESCRIPTION - brief description;
  • SUM_MIN - minimum amount which can be withdrawn from the card within a single transaction;
  • SUM_MAX - maximum amount which can be withdrawn from the card within a single transaction;
  • SUM_CURRENCY - the currency of the minimum/maximum amounts;
  • LAST_STATUS - the status of the last card usage;
  • LAST_STATUS_CODE - the ID of the status of the last card usage;
  • LAST_STATUS_DESCRIPTION - the description of the status of the last card usage;
  • LAST_STATUS_MESSAGE - the response received from the payment system;
  • LAST_SUM - the last amount withdrawn from the card;
  • LAST_CURRENCY - the currency of the last amount withdrawn from the card;
  • ACTIVE - active state flag;
  • LAST_DATE - the date when the credit card was last used.

Note
The credit card number must be encrypted using the CSaleUserCards::CryptData method before adding the record.

Returned values

The method returns the ID of the added record on success, or false otherwise.

Example


<?
// Save the information about the current user's new card

if (CSaleUserCards::CheckPassword())
{
    $arFields = array(
            "USER_ID" => $USER->GetID(),
            "ACTIVE" => "Y",
            "SORT" => "100",
            "PAY_SYSTEM_ACTION_ID" => 11,
            "CURRENCY" => "USD",
            "CARD_TYPE" => 
                CSaleUserCards::IdentifyCardType("4111111111111"),
            "CARD_NUM" => 
                CSaleUserCards::CryptData("4111111111111", "E"),
            "CARD_EXP_MONTH" => 11,
            "CARD_EXP_YEAR" => 2007,
            "DESCRIPTION" => false,
            "CARD_CODE" => "123",
            "SUM_MIN" => False,
            "SUM_MAX" => False,
            "SUM_CURRENCY" => False
        );

    $UserCardID = CSaleUserCards::Add($arFields);
}
?>
© «Bitrix24», 2001-2024