SagePayPayment
Questions answered by this recipe
This recipe is intended, when complete, to answer how to integrate SagePay (previously known as Protx) into PmWiki.
Description
The SagePay Payment recipe provides SagePay (previously known as Protx) payment integration into PmWiki. This is not intended to be a shopping cart, but could be used for purchase of single items, services or donations.
Notes
- I'd be keen to get feedback or ideas from other PmWiki users and devs.
- There is a demo online using the Sagepay Simulator, have a look at [(approve links) edit diff]
Advanttages
- Sagepay has no percentage fee, so may be better for larger $ turnover sites.
- No https or ssl is required on your site.
- You don't store payment details.
Limitations
- Sagepay has a monthly fee, so has fixed costs
- There is no shopping cart, as per online shop type e-commerce systems.
- A customer can only pay for one item at a time.
- There is no built in way for the customer to remove an item from the payment process. However if the user closes their web browser, any un-completed transactions will be cancelled.
- I'm sure some of the notes and / or comments in the code are a bit ropey.
- The product markup is for use in the travel industry, so may not be suitable. It is easy to change though.
About SagePay
SagePay (previously know as Protx) is an online payment handling system. It is similar in some senses, to PayPal, however the main advantage is that cost is fixed monthly rather than being a percentage of the sale. Protx is pretty popular in the UK and is commonly in in SME's online shops. There are several payment systems and seller packages offered by SagePay. The payment system this recipe uses is the "Form" type, which requires no database on your server. More info can be found on [(approve links) edit diff]. Protx was bought by Sage in 2009 and re-branded as SagePay. As an aside AndyG has no affiliation to Sage or Protx.
Use
The online payment system using SagePay allows users to pay sums of money to you via the SagePay secure payment system. This consists of six elements.
The first element is the product, which allows the user to initiate a payment in relation to an individual product. It can be placed on any page on the site and multiple products can be placed on a page. It is added to a page by editing the page and adding the following text:
(:SagepayProduct name="Product name here" value="product value here":)
The two value are the name, which should include all information required to understand the order, and the price in UK sterling. These two values are used throughout the payment process. First, the product name is shown. This is followed by an email link which, when clicked, creates an email with the subject and body pre-filled to enquire about the product. Next is a link, which when clicked initiates a payment in relation to the product.
The second element is the customer details page. This is shown when a customer clicks on the Book this trip link on a product. It allows the customer to enter their personal (not payment) details. Once they have done so, they can click confirm order. The URL of this page needs to be set in the the config.php. The markup (:SagepayCustomerDetails var="test":)
needs to be added to the page.
The third element is the review and confirm page, this is shown next. It allows the customer to review their details before confirming the order. Once they have done so, they can click the complete payment button. The URL of this page needs to be set in the the config.php. The markup (:SagepayOrderConfirmation var="test":)
needs to be added to the page.
They are then taken to the SagePay payment page, the forth element in the process. This uses secure socket layer (SSL, https) encryption to enable the customer to safely provide their credit card details. Once they have entered their payment details, their payment is processed and they are taken back to your site, either to the successful payment page, or the failed payment page.
The fifth element is the successful payment page, it confirms the transaction to the customer and gives them an order reference number. It also sends a confirmation email to the admin email address. The URL of this page needs to be set in the the config.php. The markup (:SagepayOrderSuccessful testvar="test":)
needs to be added to the page.
The sixth element is the failed payment page. It confirms the transaction to the customer and gives them an order number. The message varies depending on the nature of the failure. It also sends a confirmation email to the admin email address. The URL of this page needs to be set in the the config.php. The markup (:SagepayOrderFailed testvar="test":)
needs to be added to the page.
Instructions
Installation
- Upload sagepay.phpΔ to your /cookbook/ folder.
- Add include_once("
$FarmD
/cookbook/sagepay.php"); to your /local/config.php or /local/farmconfig.php. - Copy sagepay_configuration_example.phpΔ into your config.php
Configuration
- Decide on a shop name
- Apply for a simulator account for use during development, visit [(approve links) edit diff] for more info.
- Read through the commented code in sagepay_configuration_example.phpΔ setting the variables as per your details add it to your config.php and change it as appropriate.
Release Notes
See Also
Contributors
- AndyG Adaptation of Protx code and porting to PmWiki recipe standard.
- Simon Wolfe, Protx, original VSP code, Updated for VSP protocol 2.23
- Nick Selby, Protx, original VSP code, New kit version
Comments
See discussion at SagePayPayment-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.