Skip to content
Last updated

UpdatePayMethod

Update a Credit Card Pay Method.

Request Parameters

ParameterTypeDescriptionRequired
actionstring"UpdatePayMethod"Required
clientidintThe id of the client matching the Pay MethodRequired
paymethodidintThe id of the payment method to updateRequired
card_numberstringCredit Card Number. The card number to update for a CreditCard or RemoteCreditCard Pay Method. Optional. Only provide if you wish to make an updateOptional
card_expirystringThe expiry date to update for a CreditCard or RemoteCreditCard Pay Method. Format 'MMYY' eg 0122. Optional. Only provide if you wish to make an updateOptional
card_startstringThe start date to update for a CreditCard or RemoteCreditCard Pay Method. Format 'MMYY' 'eg' 0122. Optional. Only provide if you wish to make an updateOptional
card_issue_numberintThe issue_number to update for a CreditCard or RemoteCreditCard Pay Method. Optional. Only provide if you wish to make an updateOptional
bank_namestringThe name of the bank. Optional. Only provide if you wish to make an updateOptional
bank_account_typestringThe type of bank account (checking, credit etc). Optional. Only provide if you wish to make an updateOptional
bank_codestringThe bank code. Also called sort code or routing number. Optional. Only provide if you wish to make an updateOptional
bank_accountstringThe account number. Required for BankAccount type. Optional. Only provide if you wish to make an updateOptional
set_as_defaultboolShould the new Pay Method be the client defaultOptional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
paymethodidintThe id of the updated Pay Method
clientidintThe id of the client

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'UpdatePayMethod',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'paymethodid' => '1',
            'clientid' => '1',
            'card_expiry' => '1025',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'UpdatePayMethod';
$postData = array(
    'paymethodid' => '1',
    'clientid' => '1',
    'card_expiry' => '1025',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

Example Response JSON

{
    "result": "success",
    "clientid": "1",
    "paymethodid": "1"
}

Error Responses

Possible error condition responses include:

  • Pay Method ID is Required
  • Client ID is Required
  • Invalid Pay Method ID
  • Pay Method does not belong to passed Client ID
  • Unsupported Gateway Type for Update
  • No Details Provided for Update
  • Unable to Update Card Number for Assisted Gateway
  • Expiry Date is invalid
  • Start Date is invalid
  • Issue Number is invalid
  • Error Updating Remote Pay Method: xxx (message from gateway)

Version History

VersionChangelog
7.8.0Initial Version