{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Tokenised Remote Storage","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"tokenised-remote-storage","__idx":0},"children":["Tokenised Remote Storage"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["+++"," ","next = \"/payment-gateways/installation-activation\""," ","prev = \"/payment-gateways/3d-secure\""," ","title = \"Tokenised Remote Storage\""," ","toc = true"," ","weight = 100"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["+++"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tokenisation is the replacement of sensitive payment information with a unique identifier (a token)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Therefore in WHMCS, a tokenised payment gateway module is one where the sensitive payment data is stored remotely by the payment gateway. This reduces the risk of data breaches because it means that unauthorized access to the local system does not risk exposing customer's sensitive payment information."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"creating-a-token-gateway","__idx":1},"children":["Creating a Token Gateway"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Payment gateways can operate tokenisation platforms in a variety of ways."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"capture-token-exchange","__idx":2},"children":["Capture Token Exchange"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["At its simplest, a payment gateway may exchange or return a token for you to use for future charges following a regular capture being performed."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For payment gateways that function in this way, you should return the token along with the result from the capture function. WHMCS will then automatically purge the locally stored payment details and replace them with the token."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following return parameters are supported."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["status"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One of either ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pending"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["declined"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["declinereason"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The reason for a decline"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["transid"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The Transaction ID returned by the payment gateway"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["fee"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["float"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The transaction fee returned by the payment gateway"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["rawdata"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string or array"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The raw data returned by the payment gateway for logging to the gateway log to aid in debugging"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["gatewayid"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The token returned by the payment gateway"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example","__idx":3},"children":["Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"function yourmodulename_capture($params) {\n    $gatewayid = $params['gatewayid'];\n    $cardnum = $params['cardnum'];\n    \n    if ($gatewayid) {\n        // Make API call to perform capture using the token here\n        // Dummy response assumed below in $response variable.        \n\n        return [\n            'status' => 'success',\n            'transid' => $response['transaction_id']\n            // Return a value in gatewayid to update the token only if required\n            'gatewayid' => $response['token'],\n            'rawdata' => $response,\n        ];\n    } else {\n        // Make API call to perform capture using the card number here\n        // Dummy response assumed below in $response variable.\n        $response = [];\n\n        return [\n            'status' => 'success',\n            'transid' => $response['transaction_id']\n            'gatewayid' => $response['token'],\n            'rawdata' => $response,\n        ];\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"remote-storage","__idx":4},"children":["Remote Storage"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For payment gateways where tokens have to be created and managed separately from capture attempts, you should use the remote storage method within your WHMCS gateway module."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This function will override the default behaviour when entering new, updating an existing, or deleting credit card details."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following parameters are passed into the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["storeremote"]}," function."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["action"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One of either ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update"]},", or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["gatewayid"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The token for the pay method to be updated"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cardtype"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The card type (Visa, MasterCard, etc..)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cardnum"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The card number"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cardexp"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["int"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The card expiry date (Format: MMYY)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cardstart"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["int"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The card start date (Format: MMYY)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["cardissuenum"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["int"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The card issue number"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following return parameters are supported."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["status"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One of either ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["success"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["error"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["rawdata"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string or array"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The raw data returned by the payment gateway for logging to the gateway log to aid in debugging"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["gatewayid"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The token returned by the payment gateway"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"example-1","__idx":5},"children":["Example"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"function yourmodulename_storeremote($params) {\n    $action = $params['action'];\n    $gatewayid = $params['gatewayid'];\n    $cardtype = $params['cardtype'];\n    $cardnum = $params['cardnum'];\n    $cardexp = $params['cardexp'];\n    $cardstart = $params['cardstart'];\n    $cardissuenum = $params['cardissuenum'];\n\n    switch ($action) {\n        case 'create':\n            // Make API call to create a token here\n            $postfields = [\n                'cardnumber' => $cardnum,\n                'cardexpiry' => $cardexp,\n                'cardcvv' => $params['cccvv'],\n            ];\n        \n            $ch = curl_init();\n            curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/api/store');\n            curl_setopt($ch, CURLOPT_POST, 1);\n            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));\n            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n            $response = curl_exec($ch);\n            curl_close($ch);\n        \n            $data = json_decode($response);\n\n            return [\n                'status' => 'success',\n                'gatewayid' => $data->remote_id,\n            ];\n            break;\n        case 'update':\n            // Make API call to update a token here\n            $postfields = [\n                'remote_id' => $gatewayid,\n                'cardexpiry' => $cardexp,\n            ];\n        \n            $ch = curl_init();\n            curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/api/update');\n            curl_setopt($ch, CURLOPT_POST, 1);\n            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));\n            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n            $response = curl_exec($ch);\n            curl_close($ch);\n        \n            $data = json_decode($response);\n            return [\n                'status' => 'success',\n                'gatewayid' => $data->remote_id,\n            ];\n            break;\n        case 'delete':\n            // Make API call to delete a token here\n            $postfields = [\n                'remote_id' => $gatewayid,\n            ];\n        \n            $ch = curl_init();\n            curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/api/delete');\n            curl_setopt($ch, CURLOPT_POST, 1);\n            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));\n            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n            $response = curl_exec($ch);\n            curl_close($ch);\n        \n            $data = json_decode($response);\n            return [\n                'status' => 'success',\n            ];\n            break;\n    }\n}\n"},"children":[]}]},"headings":[{"value":"Tokenised Remote Storage","id":"tokenised-remote-storage","depth":1},{"value":"Creating a Token Gateway","id":"creating-a-token-gateway","depth":2},{"value":"Capture Token Exchange","id":"capture-token-exchange","depth":3},{"value":"Example","id":"example","depth":4},{"value":"Remote Storage","id":"remote-storage","depth":3},{"value":"Example","id":"example-1","depth":4}],"frontmatter":{"title":"Tokenised Remote Storage","seo":{"title":"Tokenised Remote Storage"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/payment-gateways/tokenised-remote-storage","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}