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
- 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.
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.
- 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 ("")
- username (string)
- Send the struct as an argument to an XML-RPC method. The following methods may be used:
- charge the card
- refund the card
- Your response will be an XML-RPC struct containing the following.
- the unique transaction reference earlier passed
- the response code from the payment server
- either APPROVED or DECLINED
- short description of the response
- raw data from the payment vendor
How to perform a heartbeat
Hearbeats are good for determining whether the payment gateway is up or not.
- Construct an XML-RPC struct as above containing the only the value pair (name="action", value="HEARTBEAT")
- Send the struct to the method heartbeat_v1.
- You will receive a struct with a status response of either "ALIVE" or "DB DISCONNECTED".