APG XML-RPC Client Guide

Building XML-RPC clients for the Anchor Payment Gateway is fairly easy. All you have to do is send an XML file containing your APG credentials and APG command paramenters then wait for an XML response. It's that simple!

Before we start with the tutorial, these should have been provided to you by our friendly Anchor staff:

  • username and password for test APG transactions
  • username and password for live APG transactions
  • hostname and port of the APG server

How to perform a charge or refund

  1. Make sure your XML-RPC client supports SSL. The APG server only listens with SSL enabled. Most modern languages that implement XML-RPC API's have the option to use SSL seamlessly with little or no further configuration.
  2. Construct an XML-RPC struct to put your data in. Now the term 'struct' is used in the XML-RPC specifications (http://www.xmlrpc.com/spec/). Different language implementations of XML-RPC sometimes do not explicitly refer to them as structs so you might have to do a bit of research on this.

  3. Your struct must contain the following value pairs.
    • username (string)
      • username provided by Anchor
    • password (string)
      • password provided by Anchor
    • reference_number (string)
      • this actually a string and not a number and will accept alphanumeric characters
      • a unique transaction number that must be preceded by letters (preferably by your company name or initials) followed by sequential numbers (e.g. IBM00001, IBM00002, IBM00003, etc.)
      • transaction numbers are unique across the APG server so if you get an error claiming that the reference/transaction number has been used, try using a different string format
    • ip_address (string)
      • IP address of the paying customer
    • order_amount (string)
      • order amount in cents
    • order_currency (string)
      • only accepts "AUD"
      • do not put any other currency
    • cc_name (string)
      • cardholder's full name
    • cc_number (string)
      • card number with no spaces
    • cc_expiry_month (string)
      • 2-digit expiry month
    • cc_expiry_year (string)
      • 2-digit expiry year
    • cc_cvd (string)
      • not currently in use but value must still be sent as an empty string ("")
  4. Send the struct as an argument to an XML-RPC method. The following methods may be used:
    • charge_v1
      • charge the card
    • refund_v1
      • refund the card
  5. Your response will be an XML-RPC struct containing the following.
    • reference_number
      • the unique transaction reference earlier passed
    • response_code
      • the response code from the payment server
    • response_summary
      • either APPROVED or DECLINED
    • response_text
      • short description of the response
    • response_detail
      • raw data from the payment vendor

How to perform a heartbeat

Hearbeats are good for determining whether the payment gateway is up or not.

  1. Construct an XML-RPC struct as above containing the only the value pair (name="action", value="HEARTBEAT")
  2. Send the struct to the method heartbeat_v1.
  3. You will receive a struct with a status response of either "ALIVE" or "DB DISCONNECTED".