== cards.update ==
==== Description ====
Update record of stored credit card or replace it with different card
==== Input Parameters ====
<table>
<tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
<tr><td>tracking_user</td><td>int</td><td>Yes</td><td>Client application user ID(s)</td></tr>
<tr><td>card_number</td><td>string</td><td>Yes</td><td>Credit card number</td></tr>
<tr><td>card_expire</td><td>string</td><td>Yes</td><td>Credit card expiration date</td></tr>
<tr><td>card_cvv2</td><td>string</td><td>Yes</td><td>Credit card CVV2 number</td></tr>
<tr><td>first_name</td><td>string</td><td>Yes</td><td>User first name</td></tr>
<tr><td>last_name</td><td>string</td><td>Yes</td><td>User last name</td></tr>
</table>
==== Returned ====
Array with these data in each array
<table>
<tr><th>Name</th><th>Type</th><th>Description</th></tr>
<tr><td>result</td><td>array</td><td>success, ccdt_id, updated_orders included in result</td></tr>
</table>
===== Notes
Depending on exact **Payment Processor** and **Merchant Account** settings, this API call can be **time-limited**.
This means that some time period must pass between 2 successful calls.
If there are more calls with the same data within this period, this call could return failure.
Good approximation for this period is 5 minutes.
For **Rocket Gate** processor, this setting is available on **Merchant Admin** :
`BlockDupPurchaseTimer` - Minimum time between purchases using same card and amount.
==== Usage Example ====
```
<?php
$curl = new \Dinke\CurlHttpClient;
//setup payment url and timeout
$payment_url = 'https://dev-payment.datingvip.com/api.json';
$timeout = 30;
$curl->setCredentials('some-token', 'some-pass');
$post_data = array(
'cmd' => 'cards.update',
'data' => array(
'tracking_user' => '4151302',
'ccdt_id' => '393',
'card_number' => '5555555555554444',
'card_expire' => '1215',
'card_cvv2' => '123',
'first_name' => 'Pera',
'last_name' => 'Peric'
)
);
$response = $curl->sendPostData($payment_url, $post_data, null, $timeout);
if($response === false)
{
//handle errors
}
//decode json to get array
$response = json_decode($response, true);
var_dump($response);
```
Excepted output after running this script should be:
```
array (size=9)
'code' => int 700
'status' => string 'Action completed succesfully' (length=28)
'command' => string 'cards.update' (length=12)
'result' => array (size=3)
'success' => boolean true,
'ccdt_id' => int 123
'updated_orders' array (length=1)
int 123455
'request' =>
array (size=4)
'token' => string 'some-token' (length=10)
'password' => string 'some-pass' (length=32)
'command' => string 'cards.update' (length=12)
'data' =>
array (size=7)
'tracking_user' => string '4151302' (length=1)
'ccdt_id' => string '393' (length=1)
'card_number' => string '555555xxxxxx4444' (length=16)
'card_expire' => string '1215' (length=4)
'card_cvv2' => string 'xxx' (length=3)
'first_name' => string 'Dragan' (length=6)
'last_name' => string 'Dinic' (length=5)
'ts' => int 1399652185
'origin_ip' => boolean false
'debug' => null
'errors' => null
```