Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Improved status update handling, check better on types.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Dec 10, 2014
1 parent d654326 commit cdcb657
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
24 changes: 19 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,37 @@ public static function create_status_sha1( $transaction_id, $shop_id, $merchant_

//////////////////////////////////////////////////

/**
* Get the status of the specified transaction ID
*
* @param string $transaction_id
* @return boolean|Pronamic_WP_Pay_Gateways_Sisow_Transaction
*/
public function get_status( $transaction_id ) {
$parameters = array();
$result = null;

$parameters['merchantid'] = $this->merchant_id;
$parameters['trxid'] = $transaction_id;
$parameters['sha1'] = self::create_status_sha1( $transaction_id, '', $this->merchant_id, $this->merchant_key );
// Parameters
$parameters = array(
'merchantid' => $this->merchant_id,
'trxid' => $transaction_id,
'sha1' => self::create_status_sha1( $transaction_id, '', $this->merchant_id, $this->merchant_key ),
);

// Request
$result = $this->send_request( Pronamic_WP_Pay_Gateways_Sisow_Methods::STATUS_REQUEST, $parameters );

// XML
$xml = Pronamic_WP_Pay_Util::simplexml_load_string( $result );

if ( is_wp_error( $xml ) ) {
$this->error = $xml;
} else {
}

if ( $xml instanceof SimpleXMLElement ) {
$result = $this->parse_document( $xml );
}

// Return
return $result;
}
}
12 changes: 10 additions & 2 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@ public function update_status( Pronamic_Pay_Payment $payment ) {

if ( $result instanceof Pronamic_WP_Pay_Gateways_Sisow_Error ) {
$this->error = $this->client->get_error();
} elseif ( false === $result ) {

return;
}

if ( false === $result ) {
$this->error = $this->client->get_error();
} else {

return;
}

if ( $result instanceof Pronamic_WP_Pay_Gateways_Sisow_Transaction ) {
$transaction = $result;

$payment->set_status( $transaction->status );
Expand Down

0 comments on commit cdcb657

Please sign in to comment.