Skip to content

Commit

Permalink
Issue #6: isPaymentSuccess can return undefined property error
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Aug 14, 2013
1 parent cc05d1c commit dfe42e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/Academe/SagePay/Model/TransactionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,13 @@ public function makeVendorTxCode()

public function isPaymentSuccess()
{
if ($this->Status == 'OK' || $this->Status == 'AUTHENTICATED' || $this->Status == 'REGISTERED') {
return true;
} else {
return false;
}
// There may be no status at all during testing, so account for that.
// Credit https://github.com/phillbrown

return (
isset($this->Status)
&& ($this->Status == 'OK' || $this->Status == 'AUTHENTICATED' || $this->Status == 'REGISTERED')
);
}
}

8 changes: 6 additions & 2 deletions src/Academe/SagePay/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Register extends Model\XmlAbstract
* cancel.vsp for CANCEL
*
* The services are different for SagePay Direct
*
* CHECKME: The v3.0 protocal documentation lists, in some places, the service for transaction
* registration as "server-register.vsp" rather than "vspserver-register.vsp". But it does
* contractict itself in a number of other places too.
*/

protected $sagepay_server_url_service = array(
Expand Down Expand Up @@ -615,15 +619,15 @@ public function postSagePay($sagepay_url, $query_string, $timeout = 30)
/**
* Send the registration to SagePay and save the reply.
* TODO: make sure the transaction type is valid (one of three allowed):
* PAYMENT, DEFERRED (not taken until RELEASE or ABORT) or AUTHENTICATE.
* PAYMENT, DEFERRED (payment not taken until RELEASE or there is an ABORT) or AUTHENTICATE.
*/

public function sendRegistration()
{
// Construct the query string from data in the model.
$query_string = $this->queryData();

// Get the URL, which is derived from the platform and the xxx
// Get the URL, which is derived from the platform and the service.
$sagepay_url = $this->getUrl();

// Post the request to SagePay
Expand Down

0 comments on commit dfe42e1

Please sign in to comment.