Skip to content

Commit

Permalink
Fix `Fatal error: Call to undefined method
Browse files Browse the repository at this point in the history
Pronamic_WP_Pay_Gateways_Buckaroo_Client::get_error()`
  • Loading branch information
rvdsteege committed Jul 19, 2016
1 parent 5029a83 commit c333bb6
Showing 1 changed file with 58 additions and 26 deletions.
84 changes: 58 additions & 26 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ class Pronamic_WP_Pay_Gateways_Buckaroo_Client {

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

/**
* Error
*
* @var WP_Error
*/
private $error;

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

/**
* Constructs and initialize a iDEAL kassa object
*/
Expand All @@ -206,6 +215,17 @@ public function __construct() {

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

/**
* Error
*
* @return WP_Error
*/
public function get_error() {
return $this->error;
}

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

/**
* Get the payment server URL
*
Expand Down Expand Up @@ -458,51 +478,63 @@ public function get_issuers() {
'body' => http_build_query( $data ),
) );

if ( 200 === wp_remote_retrieve_response_code( $result ) ) {
$body = wp_remote_retrieve_body( $result );
$body = wp_remote_retrieve_body( $result );

wp_parse_str( $body, $data );
wp_parse_str( $body, $data );

$data = Pronamic_WP_Pay_Gateways_Buckaroo_Util::transform_flat_response( $data );
$data = Pronamic_WP_Pay_Gateways_Buckaroo_Util::transform_flat_response( $data );

if ( ! isset( $data['BRQ_SERVICES'] ) ) {
$error_msg = __( 'Unable to retrieve issuers from Buckaroo.', 'pronamic_ideal' );

if ( 200 !== wp_remote_retrieve_response_code( $result ) ) {
$this->error = new WP_Error( 'buckaroo_error', $error_msg, $data );

return $issuers;
}

if ( isset( $data[ 'BRQ_APIRESULT' ] ) && 'Fail' === $data['BRQ_APIRESULT'] ) {
$this->error = new WP_Error( 'buckaroo_error', sprintf( '%s %s', $error_msg, $data[ 'BRQ_APIERRORMESSAGE' ] ), $data );

return $issuers;
}

if ( ! isset( $data[ 'BRQ_SERVICES' ] ) ) {
return $issuers;
}

foreach ( $data[ 'BRQ_SERVICES' ] as $service ) {
if ( ! isset( $service[ 'NAME' ], $service[ 'VERSION' ], $service[ 'ACTIONDESCRIPTION' ] ) ) {
return $issuers;
}

foreach ( $data['BRQ_SERVICES'] as $service ) {
if ( ! isset( $service['NAME'], $service['VERSION'], $service['ACTIONDESCRIPTION'] ) ) {
if ( Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::IDEAL !== $service[ 'NAME' ] ) {
continue;
}

foreach ( $service[ 'ACTIONDESCRIPTION' ] as $action ) {
if ( ! isset( $action[ 'NAME' ], $action[ 'REQUESTPARAMETERS' ] ) ) {
return $issuers;
}

if ( Pronamic_WP_Pay_Gateways_Buckaroo_PaymentMethods::IDEAL !== $service['NAME'] ) {
if ( 'Pay' !== $action[ 'NAME' ] ) {
continue;
}

foreach ( $service['ACTIONDESCRIPTION'] as $action ) {
if ( ! isset( $action['NAME'], $action['REQUESTPARAMETERS'] ) ) {
foreach ( $action[ 'REQUESTPARAMETERS' ] as $parameter ) {

if ( ! isset( $parameter[ 'NAME' ], $parameter[ 'LISTITEMDESCRIPTION' ] ) ) {
return $issuers;
}

if ( 'Pay' !== $action['NAME'] ) {
if ( 'issuer' !== $parameter[ 'NAME' ] ) {
continue;
}

foreach ( $action['REQUESTPARAMETERS'] as $parameter ) {

if ( ! isset( $parameter['NAME'], $parameter['LISTITEMDESCRIPTION'] ) ) {
return $issuers;
}

if ( 'issuer' !== $parameter['NAME'] ) {
continue;
}

foreach ( $parameter['LISTITEMDESCRIPTION'] as $issuer ) {
$issuers[ $issuer['VALUE'] ] = $issuer['DESCRIPTION'];
}

break;
foreach ( $parameter[ 'LISTITEMDESCRIPTION' ] as $issuer ) {
$issuers[ $issuer[ 'VALUE' ] ] = $issuer[ 'DESCRIPTION' ];
}

break;
}
}
}
Expand Down

0 comments on commit c333bb6

Please sign in to comment.