COPY Transaction Examples

A guide for using the PayConex API to copy existing transactions between agent and sub-accounts.

Overview

The COPY transaction type allows you to duplicate an existing transaction from an agent account to one of its sub-accounts. This feature was specifically built for agent/sub-account structures and is particularly useful for scenarios where you need to replicate a transaction across different merchant accounts while maintaining transaction integrity.

API URLs

For the certification test environment:

https://cert.payconex.net/api/qsapi/3.8

For the production environment:

https://secure.payconex.net/api/qsapi/3.8

Basic COPY Transaction

At its most basic level, a COPY transaction requires the following parameters:

Required Parameters

ParameterTypeDescription
account_idStringThe agent account ID initiating the copy
api_accesskeyStringAPI access key for the agent account
dest_accountStringThe destination sub-account ID (must be a sub-account of the agent)
dest_apikeyStringAPI access key for the destination sub-account
transaction_typeStringMust be set to "COPY"
token_idStringThe transaction ID of the original transaction to copy
response_formatStringResponse format (JSON recommended)

Basic Example

curl --request POST \
  --url https://cert.payconex.net/api/qsapi/3.8 \
  --header 'Content-Type: application/json' \
  --data '{
    "account_id": "220614982061",
    "api_accesskey": "your_agent_api_key",
    "dest_account": "220614965201",
    "dest_apikey": "your_sub_account_api_key",
    "transaction_type": "COPY",
    "token_id": "000000001146",
    "response_format": "JSON"
  }'

Basic Response

{
  "transaction_id": "000000000226",
  "tender_type": "CARD",
  "transaction_timestamp": "2025-09-05 16:19:18",
  "card_brand": "VISA",
  "transaction_type": "STORE",
  "last4": "9990",
  "card_expiration": "1230",
  "authorization_message": "APPROVED",
  "request_amount": "0",
  "transaction_amount": "0",
  "error": false,
  "error_code": "0",
  "error_message": null,
  "error_msg": null,
  "dest_account": "220614965201"
}

Advanced COPY Transaction with Additional Data

To preserve customer information and other transaction data from the original transaction, you can include additional parameters in your COPY request.

Additional Optional Parameters

ParameterTypeDescription
first_nameStringCustomer's first name
last_nameStringCustomer's last name
street_address1StringCustomer's street address
cityStringCustomer's city
stateStringCustomer's state
zipStringCustomer's ZIP code
phoneStringCustomer's phone number
emailStringCustomer's email address
custom_dataStringBase64-encoded custom data

Advanced Example

curl --request POST \
  --url https://cert.payconex.net/api/qsapi/3.8 \
  --header 'Content-Type: application/json' \
  --data '{
    "account_id": "220614982061",
    "api_accesskey": "your_agent_api_key",
    "dest_account": "220614965201",
    "dest_apikey": "your_sub_account_api_key",
    "transaction_type": "COPY",
    "token_id": "000000001166",
    "response_format": "JSON",
    "first_name": "Ryan",
    "last_name": "Cox",
    "street_address1": "123 N Main St.",
    "city": "Tulsa",
    "state": "OK",
    "zip": "12345",
    "phone": "9182362857",
    "email": "[email protected]",
    "custom_data": "VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBjdXN0b20gZGF0YSBmaWVsZA=="
  }'

Advanced Response

{
  "transaction_id": "000000000226",
  "tender_type": "CARD",
  "transaction_timestamp": "2025-09-05 16:19:18",
  "card_brand": "VISA",
  "transaction_type": "STORE",
  "last4": "9990",
  "card_expiration": "1230",
  "authorization_message": "APPROVED",
  "request_amount": "0",
  "transaction_amount": "0",
  "first_name": "Ryan",
  "last_name": "Cox",
  "custom_data": "VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBjdXN0b20gZGF0YSBmaWVsZA==",
  "error": false,
  "error_code": "0",
  "error_message": null,
  "error_msg": null,
  "dest_account": "220614965201"
}

Preserving Data from Original Transaction

To automate the inclusion of additional data fields, you should capture the data from the original QSAPI transaction response when the transaction is first processed, then include that data in your subsequent COPY request.

Example: Original Transaction Response

When you first process a transaction, capture the response data for later use in COPY requests:

{
  "transaction_id": "000000001166",
  "tender_type": "CARD",
  "transaction_timestamp": "2025-09-05 14:02:48",
  "card_brand": "VISA",
  "transaction_type": "SALE",
  "last4": "9990",
  "card_bin": "41249399",
  "card_expiration": "1230",
  "authorization_code": "096674",
  "authorization_message": "APPROVED",
  "request_amount": 10,
  "transaction_amount": 10,
  "first_name": "Ryan",
  "last_name": "Cox",
  "keyed": true,
  "swiped": false,
  "entry_mode": "keyed",
  "transaction_approved": true,
  "custom_data": "VGhpcyBpcyBhIHRlc3QgZm9yIHRoZSBjdXN0b20gZGF0YSBmaWVsZA==",
  "currency": "USD",
  "program": "STANDARD",
  "program_card": "",
  "network_transaction_id": "014248124936674",
  "error": false,
  "error_code": 0,
  "error_message": null,
  "error_msg": null
}

Why Use Original QSAPI Response Data

  • Parameter Consistency: QSAPI responses use the same parameter names as QSAPI requests (e.g., first_name, last_name)
  • Data Accuracy: Captures the exact data that was processed in the original transaction
  • No Additional API Calls: Avoids the need for separate retrieval requests
  • Real-time Availability: Data is immediately available when the original transaction completes

Response Format

COPY Transaction Response Fields

FieldTypeDescription
transaction_idStringThe new transaction ID for the copied transaction
tender_typeStringThe tender type (typically "CARD")
transaction_timestampStringTimestamp when the copy was created
card_brandStringThe card brand (VISA, MASTERCARD, etc.)
transaction_typeStringWill be "STORE" for copied transactions
last4StringLast 4 digits of the card
card_expirationStringCard expiration date
authorization_messageStringAuthorization message (typically "APPROVED")
request_amountStringRequested amount (typically "0" for copies)
transaction_amountStringTransaction amount (typically "0" for copies)
first_nameStringCustomer first name (if included in request)
last_nameStringCustomer last name (if included in request)
custom_dataStringCustom data (if included in request)
errorBooleanIndicates if there was an error
error_codeStringError code (0 for success)
error_messageStringError message (null for success)
error_msgStringAlternative error message field
dest_accountStringThe destination account ID

Important Limitations

Data Preservation

  • Automatic Copying: Only basic transaction data (card info, amounts, etc.) is automatically copied
  • Manual Inclusion Required: Customer information, custom data, and other fields must be explicitly included in the COPY request

Account Structure Requirements

  • Agent/Sub-account Only: The destination account must be a sub-account of the agent account
  • Authentication: Both agent and sub-account API keys are required
  • Transaction Type: Copied transactions are created as "STORE" type transactions