$itemNode->appendChild($quantityNode); $unitNetAmountNode = $xml->createElement('unitNetAmount'); $unitNetAmountNode->nodeValue = '90.00'; $itemNode->appendChild($unitNetAmountNode); $unitTaxAmountNode = $xml->createElement('unitTaxAmount'); $unitTaxAmountNode->nodeValue = '10.00'; $itemNode->appendChild($unitTaxAmountNode); $unitGrossAmountNode = $xml->createElement('unitGrossAmount'); $unitGrossAmountNode->nodeValue = '100.00'; $itemNode->appendChild($unitGrossAmountNode); $totalGrossAmountNode = $xml->createElement('totalGrossAmount'); $totalGrossAmountNode->nodeValue = '100.00'; $itemNode->appendChild($totalGrossAmountNode); $basketNode->appendChild($itemNode); $xml->appendChild($basketNode); $sagePay->setBasketXML($xml->saveHTML()); $sagePay->setSuccessURL('https://www.yoururl.com/success.php'); $sagePay->setFailureURL('https://www.yoururl.org/fail.php'); ?> <form method="POST" id="SagePayForm" action="https://test.sagepay.com/gateway/service/vspform-register.vsp"> <input type="hidden" name="VPSProtocol" value= "3.00"> <input type="hidden" name="TxType" value= "PAYMENT"> <input type="hidden" name="Vendor" value= "YOURVERNODID"> <input type="hidden" name="Crypt" value= "<?php echo $sagePay->getCrypt(); ?> "> <input type="submit" value="continue to SagePay"> </form>
public function check_for_post() { if (isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) { // Validate all the datas self::validate_and_clean_post_array(); // If data validation fails then exit early if (is_array(self::$validation)) { // Validations errors are handled in `function show_donate_form()` return; // Otherwise the data is clean! Huzzah } else { // 0 | Set up ready for sagepay require_once 'lib/SagePay.php'; $sagePay = new SagePay(); self::$input_data['sage_vendortx'] = $sagePay->getVendorTxCode(); $sage_description = get_option('sd_payment_description'); // 1 | Save to database self::save_donation_to_db(); // 2 | Format for SagePay $amount = floatval(str_replace(array('€', '£', '$'), '', self::$input_data['amount'])); $currency = get_option('sd_currency', 'GBP'); $sagePay->setCurrency($currency); $sagePay->setAmount($amount); $sagePay->setDescription($sage_description); $sagePay->setBillingFirstnames(self::$input_data['name_first']); $sagePay->setBillingSurname(self::$input_data['name_last']); $sagePay->setBillingCity(self::$input_data['city']); $sagePay->setBillingPostCode(self::$input_data['postcode']); $sagePay->setBillingAddress1(self::$input_data['address1']); $sagePay->setBillingCountry(self::$input_data['country']); $sagePay->setAllowGiftAid(self::$input_data['giftaid']); $sagePay->setDeliverySameAsBilling(); $sagePay->setWebsite(site_url()); $sagePay->setSuccessURL(get_option('sd_success_url')); $sagePay->setFailureURL(get_option('sd_failure_url')); $crypt = $sagePay->getCrypt(); // 3 | Tell the user that we're going to redirect them to SagePay include sprintf("%s/templates/tpl_sage_redirect.php", dirname(__FILE__)); return TRUE; } } }