> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://ixopay.ferndocs.com/developer-hub/documentation/guides/payments/saving-payment-information/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://ixopay.ferndocs.com/_mcp/server. # Saving payment information When it comes to handling payments, it can be convenient to save payment details for future transactions. This guide will cover how to save payment information for later use, including setting up future payments, saving payment details during payments, and deleting saved payment information. ```mermaid graph LR R("Register") --> S["store uuid"] D("Debit withRegister") --> S P("Preauthorize withRegister") --> S S --> U["use saved payment"] U --> DE("Deregister") ``` ## Set up future payments To save payment information for future payments, you can use the [register](https://documentation.ixopay.com/api/transaction/register) transaction API call. This type of transaction just stores payment information without holding or transferring funds. You can use this option to set up future payments for your customers. Steps to use: 1. Create a [register transaction](https://documentation.ixopay.com/api/transaction/register), providing as many customer details as you can. Choose one of the integration methods described in the getting started guide on [accepting payments](https://documentation.ixopay.com/docs/guides/getting-started/accept-payments) for completing the transaction. * curl * Python * PHP * Java ```sh curl --request POST -sL \ --url "https://gateway.ixopay.com/api/v3/transaction/${API_KEY}/register" \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header "Authorization: Basic $(echo -n "$USERNAME:$PASSWORD" | base64)" \ --data-raw '{ "merchantTransactionId": "your-unique-identifier", "transactionToken": "$CC_TOKEN", "successUrl": "https://shop.example.org/checkout/success", "cancelUrl": "https://shop.example.org/checkout/cancelled", "errorUrl": "https://shop.example.org/checkout/error", "callbackUrl": "https://api.example.org/callback" }' ``` ```python import requests import json import base64 import os url = "https://gateway.ixopay.com/api/v3/transaction/{apiKey}/register".format( apiKey=os.environ["API_KEY"] ) auth = base64.b64encode("%s:%s" % (os.environ["USERNAME"], os.environ["PASSWORD"])) cc_token = os.environ["CC_TOKEN"] payload = json.dumps( { "merchantTransactionId": "your-unique-identifier", "transactionToken": cc_token, "successUrl": "https://shop.example.org/checkout/success", "cancelUrl": "https://shop.example.org/checkout/cancelled", "errorUrl": "https://shop.example.org/checkout/error", "callbackUrl": "https://api.example.org/callback" } ) headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": "Basic {auth}".format(auth=auth), } response = requests.request("POST", url, headers=headers, data=payload) ``` ```php "https://gateway.ixopay.com/api/v3/transaction/$API_KEY/register", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => << array( 'Content-Type: application/json', 'Accept: application/json', "Authorization: Basic $auth" ), )); $response = curl_exec($curl); curl_close($curl); ``` ```java String transactionToken = req.getParameter("cctoken"); OkHttpClient client = new OkHttpClient().newBuilder().build(); RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{" + "\"merchantTransactionId\": \"your-unique-identifier\"," + "\"transactionToken\": \"" + transactionToken + "\"," + "\"description\": \"Purchase description shown on credit card statement.\"," + "\"amount\": \"9.99\"," + "\"currency\": \"EUR\"," + "\"successUrl\": \"https://shop.example.org/checkout/success\"," + "\"cancelUrl\": \"https://shop.example.org/checkout/cancelled\"," + "\"errorUrl\": \"https://shop.example.org/checkout/error\"," + "\"callbackUrl\": \"https://api.example.org/callback\"" "}" ); String auth = Base64.getEncoder().encodeToString( "%s:%s".format(System.getenv("USERNAME"), System.getenv("PASSWORD"))); Request request = new Request.Builder() .url("https://gateway.ixopay.com/api/v3/transaction/%s/register" .format(System.getenv("API_KEY"))) .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic %s".format(auth)) .build(); Response response = client.newCall(request).execute(); ``` 2. Store the `uuid` of the response in your database. 3. When it's time to charge the customer, use either [debit](https://documentation.ixopay.com/api/transaction/debit), [incremental authorization](https://documentation.ixopay.com/api/transaction/incremental-authorization) or [payout](https://documentation.ixopay.com/api/transaction/payout) transaction API calls. Provide the stored `uuid` in the `referenceUuid` field. Choose a transaction indicator based on whether the follow-up payment is [customer initiated](https://documentation.ixopay.com/docs/guides/payments/customer-initiated) or [merchant initiated](https://documentation.ixopay.com/docs/guides/payments/merchant-initiated). ## Save payment details during payment Another way to save payment information is to use debit or preauthorize while simultaneously saving payment information for future payments. Debit transactions immediately transfer funds while preauthorize transactions [place a hold](https://documentation.ixopay.com/docs/guides/payments/holding-funds) on funds. The debit or preauthorize transactions must be created with the flag `withRegister` set to `true`. Steps to use: 1. Create a [debit](https://documentation.ixopay.com/api/transaction/debit) or [preauthorize](https://documentation.ixopay.com/api/transaction/preauthorize) transaction, providing as many customer details as you can. Make sure to set the `withRegister` flag to `true`. Choose one of the integration methods described in the getting started guide on [accepting payments](https://documentation.ixopay.com/docs/guides/getting-started/accept-payments) for completing the transaction. * curl * Python * PHP * Java ```sh curl --request POST -sL \ --url "https://gateway.ixopay.com/api/v3/transaction/${API_KEY}/debit" \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header "Authorization: Basic $(echo -n "$USERNAME:$PASSWORD" | base64)" \ --data-raw '{ "merchantTransactionId": "your-unique-identifier", "transactionToken": "$CC_TOKEN", "description": "Purchase description shown on credit card statement.", "amount": "9.99", "currency": "EUR", "withRegister": true, "successUrl": "https://shop.example.org/checkout/success", "cancelUrl": "https://shop.example.org/checkout/cancelled", "errorUrl": "https://shop.example.org/checkout/error", "callbackUrl": "https://api.example.org/callback" }' ``` ```python import requests import json import base64 import os url = "https://gateway.ixopay.com/api/v3/transaction/{apiKey}/debit".format( apiKey=os.environ["API_KEY"] ) auth = base64.b64encode("%s:%s" % (os.environ["USERNAME"], os.environ["PASSWORD"])) cc_token = os.environ["CC_TOKEN"] payload = json.dumps( { "merchantTransactionId": "your-unique-identifier", "transactionToken": cc_token, "description": "Purchase description shown on credit card statement.", "amount": "9.99", "currency": "EUR", "withRegister": true, "successUrl": "https://shop.example.org/checkout/success", "cancelUrl": "https://shop.example.org/checkout/cancelled", "errorUrl": "https://shop.example.org/checkout/error", "callbackUrl": "https://api.example.org/callback" } ) headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": "Basic {auth}".format(auth=auth), } response = requests.request("POST", url, headers=headers, data=payload) ``` ```php "https://gateway.ixopay.com/api/v3/transaction/$API_KEY/debit", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => << array( 'Content-Type: application/json', 'Accept: application/json', "Authorization: Basic $auth" ), )); $response = curl_exec($curl); curl_close($curl); ``` ```java String transactionToken = req.getParameter("cctoken"); OkHttpClient client = new OkHttpClient().newBuilder().build(); RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{" + "\"merchantTransactionId\": \"your-unique-identifier\"," + "\"transactionToken\": \"" + transactionToken + "\"," + "\"description\": \"Purchase description shown on credit card statement.\"," + "\"amount\": \"9.99\"," + "\"currency\": \"EUR\"," + "\"withRegister\": true," + "\"successUrl\": \"https://shop.example.org/checkout/success\"," + "\"cancelUrl\": \"https://shop.example.org/checkout/cancelled\"," + "\"errorUrl\": \"https://shop.example.org/checkout/error\"," + "\"callbackUrl\": \"https://api.example.org/callback\"" "}" ); String auth = Base64.getEncoder().encodeToString( "%s:%s".format(System.getenv("USERNAME"), System.getenv("PASSWORD"))); Request request = new Request.Builder() .url("https://gateway.ixopay.com/api/v3/transaction/%s/debit" .format(System.getenv("API_KEY"))) .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic %s".format(auth)) .build(); Response response = client.newCall(request).execute(); ``` 2. Store the `uuid` of the response in your database. 3. When it's time to charge the customer, use either [debit](https://documentation.ixopay.com/api/transaction/debit), [incremental authorization](https://documentation.ixopay.com/api/transaction/incremental-authorization) or [payout](https://documentation.ixopay.com/api/transaction/payout) transaction API calls. Provide the stored `uuid` in the `referenceUuid` field. Choose a transaction indicator based on whether the follow-up payment is [customer initiated](https://documentation.ixopay.com/docs/guides/payments/customer-initiated) or [merchant initiated](https://documentation.ixopay.com/docs/guides/payments/merchant-initiated). ## Deleting saved payment information Saved payment information can be deleted using a [deregister transaction](https://documentation.ixopay.com/api/transaction/deregister). This transaction removes the payment information from the system, ensuring that it can no longer be used for future transactions. Send the `uuid` of a previously saved transaction in the `referenceUuid` field. * curl * Python * PHP * Java ```sh curl --request POST -sL \ --url "https://gateway.ixopay.com/api/v3/transaction/${API_KEY}/deregister" \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header "Authorization: Basic $(echo -n "$USERNAME:$PASSWORD" | base64)" \ --data-raw '{ "merchantTransactionId": "your-unique-identifier", "referenceUuid": "$STORED_TRANSACTION_ID" }' ``` ```python import requests import json import base64 import os url = "https://gateway.ixopay.com/api/v3/transaction/{apiKey}/deregister".format( apiKey=os.environ["API_KEY"] ) auth = base64.b64encode("%s:%s" % (os.environ["USERNAME"], os.environ["PASSWORD"])) payload = json.dumps( { "merchantTransactionId": "your-unique-identifier", "referenceUuid": os.environ["STORED_TRANSACTION_ID"], } ) headers = { "Content-Type": "application/json", "Accept": "application/json", "Authorization": "Basic {auth}".format(auth=auth), } response = requests.request("POST", url, headers=headers, data=payload) ``` ```php "https://gateway.ixopay.com/api/v3/transaction/$API_KEY/deregister", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => << array( 'Content-Type: application/json', 'Accept: application/json', "Authorization: Basic $auth" ), )); $response = curl_exec($curl); curl_close($curl); ``` ```java OkHttpClient client = new OkHttpClient().newBuilder().build(); RequestBody body = RequestBody.create( MediaType.parse("application/json"), "{" + "\"merchantTransactionId\": \"your-unique-identifier\"," + "\"referenceUuid\": \"" + req.getParameter("STORED_TRANSACTION_ID"); + "\"" + "}" ); String auth = Base64.getEncoder().encodeToString( "%s:%s".format(System.getenv("USERNAME"), System.getenv("PASSWORD"))); Request request = new Request.Builder() .url("https://gateway.ixopay.com/api/v3/transaction/%s/deregister" .format(System.getenv("API_KEY"))) .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic %s".format(auth)) .build(); Response response = client.newCall(request).execute(); ```