Virtual Payment Client Example

 MasterCard Virtual Payment Client Example

PHP 3-Party Transaction

Simply input those required fields to change the functionality.

Virtual Payment Client URL: 

 Basic 3-Party Transaction Fields

VPC Version:
Command Type:
Merchant AccessCode:
Merchant Transaction Reference:
Transaction OrderInfo:
Purchase Amount:
Receipt ReturnURL:
Payment Server Display Language Locale:

Any information passed through the customer's browser can potentially be modified by the customer, or even by third parties to fraudulently alter the transaction data. Therefore all transactional information should not be passed through the browser in a way that could potentially be modified (e.g. hidden form fields). Transaction data should only be accepted once from a browser at the point of input, and then kept in a way that does not allow others to modify it (e.g. database, server session, etc.). Any transaction information displayed to a customer, such as amount, should be passed only as display information and the actual transactional data should be retrieved from the secure source last thing at the point of processing the transaction.

include('VPCPaymentConnection.php'); $conn = new VPCPaymentConnection(); // This is secret for encoding the SHA256 hash // This secret will vary from merchant to merchant $secureSecret = ""; // Set the Secure Hash Secret used by the VPC connection object $conn->setSecureSecret($secureSecret); // ******************************************* // START OF MAIN PROGRAM // ******************************************* // Sort the POST data - it's important to get the ordering right ksort ($_POST); // add the start of the vpcURL querystring parameters $vpcURL = $_POST["virtualPaymentClientURL"]; // This is the title for display $title = $_POST["Title"]; // Remove the Virtual Payment Client URL from the parameter hash as we // do not want to send these fields to the Virtual Payment Client. unset($_POST["virtualPaymentClientURL"]); unset($_POST["SubButL"]); unset($_POST["Title"]); // Add VPC post data to the Digital Order foreach($_POST as $key => $value) { if (strlen($value) > 0) { $conn->addDigitalOrderField($key, $value); } } // Add original order HTML so that another transaction can be attempted. $conn->addDigitalOrderField("AgainLink", $againLink); // Obtain a one-way hash of the Digital Order data and add this to the Digital Order $secureHash = $conn->hashAllFields(); $conn->addDigitalOrderField("Title", $title); $conn->addDigitalOrderField("vpc_SecureHash", $secureHash); $conn->addDigitalOrderField("vpc_SecureHashType", "SHA256"); // Obtain the redirection URL and redirect the web browser $vpcURL = $conn->getDigitalOrder($vpcURL); header("Location: ".$vpcURL); //echo "$vpcURL";