XML-RPC |
![]() |
[XML-PRC index]
-> XML-RPC with PHP
Below is an example of how to use the SECVPN XML-RPC API with the Edd Dumbill PHP-XMLRPC client to
place a test transaction on the SECPay server.
In order to run the code below you will need:
Simple XMLRPC Client Example
<?php
/*
Include the client library.
Note: in this example the extension of the library is '.php' rather than '.inc'
*/
include("xmlrpc.php");
/*
Declare the method, validateCardFull, of the SECVPN object to be used via XML RPC.
Other methods like this one can be added to handle other methods of the SECVPN object.
*/
$f=new xmlrpcmsg('SECVPN.validateCardFull');
/*
Add the test parameters in the order specified
by the SECVPN.validateCardFull() method
*/
$f->addParam(new xmlrpcval("secpay", "string")) ; // Test MerchantId
$f->addParam(new xmlrpcval("secpay", "string")) ; // VPN password
$f->addParam(new xmlrpcval("trans_id", "string")) ; // merchants transaction id
$f->addParam(new xmlrpcval("123.132.321.132", "string")) ; // The ip of the original caller
$f->addParam(new xmlrpcval("Mr Joseph Bloggs", "string")) ; // Card Holders Name
$f->addParam(new xmlrpcval("4444333322221111", "string")) ; // Card number
$f->addParam(new xmlrpcval("10.51", "string")) ; // Amount
$f->addParam(new xmlrpcval("12/04", "string")) ; // Expiry Date
$f->addParam(new xmlrpcval("", "string")) ; // Issue (Switch/Solo only)
$f->addParam(new xmlrpcval("", "string")) ; // Start Date
$f->addParam(new xmlrpcval("", "string")) ; // Order Item String
$f->addParam(new xmlrpcval("", "string")) ; // Shipping Address
$f->addParam(new xmlrpcval("", "string")) ; // Billing Address
$f->addParam(new xmlrpcval("test_status=true,dups=false", "string")) ; // Options String
print "<pre>sending data ...\n" . htmlentities($f->serialize()) . "... end of send\n</pre>";
/*
Create the XMLRPC client, using the server 'make_call', on the host 'www.secpay.com', via the https port '443'
*/
$c=new xmlrpc_client("/secxmlrpc/make_call", "www.secpay.com", 443);
/*
Debugging is enabled for testing purposes
*/
$c->setDebug(1);
/*
Send the request using the 'https' protocol.
*/
$r=$c->send($f,20,"https");
/*
Ensure that a response has been received from SECPay
*/
if (!$r) {
die(" failed");
}
$v=$r->value();
/*
Display response or fault information
*/
if (!$r->faultCode()) {
$v->scalarval()."<BR>";
htmlentities($r->serialize())."</PRE><HR>\n";
}
else {
print "Fault: ";
print "Code: ".$r->faultCode()." Reason '".$r->faultString()."'<BR>";
}
?>
Further Information
Details of the XML-RPC protocol can be found at www.xmlrpc.org.
(c)Copyright 2002 SECPay Ltd., All Rights Reserved.