I have a client who has signed up for a sagepay account. His current website runs off wordpress 3.0 and currently doesn't have any sort of ecommerce functionality.
He's needing a button that lets users submit a deposit of £300 through sagepay (this amount never changes). (Usually, I would suggest using paypal for something like this, but apparently due to the travel nature of his business, paypal won't let my client have a pro account)
I've looked at the method described in a similar thread on here back in March (How Do I Make a SagePay BuyNow Button?), but I'm not really sure how to implement this within a page on wordpress, not hugely knowledgeable on php bar basic template editing, so I got totally lost at the $PAYMENT_CRYPT part.
If anyone could provide the steps I need to take to implement a basic button that submits the same amount each time, and then collects all the card details/customer details once it's sent them to sagepay gateway, it would be hugely appreciated!
In short, no. These is no easy way to approach this. Unless you link to a Payment form to SagePay and use the new IFRAME feature. You can have certain information within WordPress that allows PHP code on your template pages or your template files.
1 - IFRAME the form within your PHP server and code the form on its own that way the CSS will become like the CSS on the WordPress page
2 - Create a payment module for it
3 - Use an existing Payment eCommerce server module for WordPress - there are plenty of plugins already
4 - Create a payment button hyper link, once clicked, it goes to a PHP form on your server for the £300 amount..
5 - Use Nochex or another payment vendor, Google Wallet etc (this is not an easy option for the client)
With the FORM, you could have:
<?
# Define your vars
$serverLive="https://live.sagepay.com/gateway/service/vspform-register.vsp"
//$serverLive="https://test.sagepay.com/gateway/service/vspform-register.vsp"
$YOUR_VENDOR_LOGIN_NAME="";
$VendorTxCode="406227821909";
$Amount="350.00";
$Currency="GBP";
$Description="1 ACME Widget";
$SuccessURL="http://example.com/success.php";
$FailureURL="http://example.com/fail.php";
$BillingSurname="Smith";
$BillingFirstnames="John";
$BillingAddress1="123 Main Street";
$BillingCity="Anywhere";
$BillingPostCode="29555";
$BillingCountry="USA";
$DeliverySurname="Smith";
$DeliveryFirstnames="John";
$DeliverAddress1="123 Main Street";
$DeliveryCity="Anywhere";
$DeliveryPostCode="29555";
$DeliveryCountry="GBP";
# The address information can be done via jQuery on your page or get some defaults
?>
<form action="<?=$serverLive?>" method="POST" id="SagePayForm" name="SagePayForm">
<input type="hidden" name="VPSProtocol" value="2.23" />
<input type="hidden" name="TxType" value="PAYMENT" />
<input type="hidden" name="Vendor" value="<?= $YOUR_VENDOR_LOGIN_NAME ?>" />
<input type="hidden" name="Crypt" value="<?= $PAYMENT_CRYPT ?>">
<input type="image" src="images/buynow-sagepay.png" />
</form>
<script type="text/javascript">
function submitform()
{
document.SagePayForm.submit();
}
submitform();
</script>
Even with this code you would still need to use some SagePay libraries, such as the XOR and Crypt functions:
// Crypt and XOR functions
private function simpleXor($string, $password) {
$data=array();
for ($i=0; $i < utf8_strlen($password); $i++) {
$data[$i]=ord(substr($password, $i, 1));
}
$output='';
for ($i=0; $i < utf8_strlen($string); $i++) {
$output .= chr(ord(substr($string, $i, 1)) ^ ($data[$i % utf8_strlen($password)]));
}
return $output;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With