function paid() { $commsObject = new DpsPxPayComs(); $response = $commsObject->processRequestAndReturnResultsAsObject(); if ($payment = DpsPxPayStoredPayment::get()->byID($response->getMerchantReference())) { if ($payment->Status != 'Success') { if (1 == $response->getSuccess()) { $payment->Status = 'Success'; if ($response->DpsBillingId) { $existingCard = DpsPxPayStoredCard::get()->filter(array("BillingID" => $response->DpsBillingId))->First(); if ($existingCard == false) { $storedCard = new DpsPxPayStoredCard(); $storedCard->BillingID = $response->DpsBillingId; $storedCard->CardName = $response->CardName; $storedCard->CardHolder = $response->CardHolderName; $storedCard->CardNumber = $response->CardNumber; $storedCard->MemberID = $payment->Order()->MemberID; $storedCard->write(); } } } else { $payment->Status = 'Failure'; } if ($DpsTxnRef = $response->getDpsTxnRef()) { $payment->TxnRef = $DpsTxnRef; } if ($ResponseText = $response->getResponseText()) { $payment->Message = $ResponseText; } $payment->write(); } $payment->redirectToOrder(); } else { USER_ERROR("could not find payment with matching ID", E_USER_WARNING); } return; }
function paid() { $this->extend("DpsPxPayPayment_Handler_completion_start"); $commsObject = new DpsPxPayComs(); $response = $commsObject->processRequestAndReturnResultsAsObject(); if ($payment = DpsPxPayPayment::get()->byID($response->getMerchantReference())) { if (1 == $response->getSuccess()) { $payment->Status = 'Success'; } else { $payment->Status = 'Failure'; } if ($DpsTxnRef = $response->getDpsTxnRef()) { $payment->TxnRef = $DpsTxnRef; } if ($ResponseText = $response->getResponseText()) { $payment->Message = $ResponseText; } $payment->write(); $payment->redirectToOrder(); } else { USER_ERROR("could not find payment with matching ID", E_USER_WARNING); } return; }
function __construct() { if (!self::$alternative_thirdparty_folder) { self::$alternative_thirdparty_folder = Director::baseFolder() . '/payment_dps/code/thirdparty'; } require_once self::$alternative_thirdparty_folder . "/PxPay_Curl.inc.php"; if (!Config::inst()->get("DpsPxPayComs", "pxpay_url")) { user_error("error in DpsPxPayComs::__construct, self::{$pxpay_url} not set. ", E_USER_WARNING); } if (!Config::inst()->get("DpsPxPayComs", "pxpay_userid")) { user_error("error in DpsPxPayComs::__construct, self::{$pxpay_userid} not set. ", E_USER_WARNING); } if (!Config::inst()->get("DpsPxPayComs", "pxpay_encryption_key")) { user_error("error in DpsPxPayComs::__construct, self::{$pxpay_encryption_key} not set. ", E_USER_WARNING); } $this->PxPayObject = new PxPay_Curl(Config::inst()->get("DpsPxPayComs", "pxpay_url"), Config::inst()->get("DpsPxPayComs", "pxpay_userid"), Config::inst()->get("DpsPxPayComs", "pxpay_encryption_key")); }