Firstly, make a copy of 'control/classes/gateways/class.new.php' and rename it to something else. Save in same folder. You can refer to
any other payment gateway file for reference.
This class has 4 functions:
validate() = Validates successful postback. Returns 'ok' or 'err'.
callback() = Assigns callback parameters to standard variables.
fields() = Assigns the POST data to send TO the payment gateway.
mailtemplates() = The preferred mail templates for this gateway. You can leave this as it is.
1 Sending POST Data to Payment Gateway
This is done via the 'fields()' function. Refer to the payment gateway API to see what post vars should be sent. Add key => value pairs, the key
being the post field name, the value is the field value. The gateway must support a custom field, where you can send any data and this field MUST contain
the buy code, sale id and 'mswmusic' value separated with a dash. See file for reference.
To get any data from the sale or from gateway parameters created in admin, you can use the following:
$order = $this->getsale($this->order['id'],$this->order['code']);
print_r($order);
$params = $this->params();
print_r($params);
The $this->order['id'] & $this->order['code'] vars are created at runtime and contain the buycode and sale ID respectively.
Parameters will be key => value pairs as created in admin, so if you created a var called 'name' and it's value was 'joe bloggs', you would us the following to reference the value:
$params['name'];
2 Validating Payment from Payment Gateway
After a payment has occurred you need to verify it was valid, this is done via the 'validate()' and 'callback()' functions.
First you should assign the POST vars returned for further processing in the 'callback()' function. The field that held the custom data
MUST be assigned to the 'code-id' parameter in the 'callback()' function. Only 'trans-id,amount,currency,pay-status & code-id' are required values, the rest ONLY if you are
doing further processing afterwards in the processing file (see below)
It is
important the 'pay-status' value is one of the following:
completed = completed payment
refund = refunded payment
pending = pending payment
Not all gateways support refunded and pending payments.
The 'validate()' function determines if the sale was valid and you should refer to the payment gateway API to see how they require validation
to be done. Payment gateways vary. You should add your own code. You may use the above functions to get any sale or parameter data.
Note that this function should ONLY return one of the following values:
ok = valid payment
err = invalid payment
Please refer to other payment gateway files for reference and to see how data is assigned. Not all gateways behave in the same way and you'll
see differing code in many of the gateway files. Some only require the 'validate()' function to return 'ok' because validation is confirmed elsewhere.