Skip to content

Commit

Permalink
Clearer log message on invalid Mycelium response. Log now includes my…
Browse files Browse the repository at this point in the history
…celium response
  • Loading branch information
jaimehgb committed Mar 11, 2017
1 parent 736f0dc commit b09762c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion upload/catalog/language/english/payment/mycelium.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
$_['back_button'] = 'Back to store';

// Log
$_['log_response_error'] = 'Invalid Mycelium response. If you see many of these it might be that your Gateway Secret is not correct.';
$_['log_response_error'] = 'Invalid Mycelium response. Caused by Invalid gateway secret, Mycelium timeout and invalid request.';

13 changes: 7 additions & 6 deletions upload/system/library/mycelium.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ public function createOrder($amount, $callback_data = '', $keychain_id = null)
if(!empty($callback_data))
$uri .= '&callback_data=' . $callback_data;

$res = @json_decode($this->apiCall($this->api_gateway_endpoint, $uri, 'POST'), true);
$res = $this->apiCall($this->api_gateway_endpoint, $uri, 'POST');
$json = @json_decode($res, true);

if(empty($res))
if(empty($json))
{
// maybe log this? :P
$this->log('error', $this->language->get('log_response_error'));
$this->log('error', $this->language->get('log_response_error') . " Data: " . $res);
throw new MyceliumException('Invalid json response from Mycelium');
}


// all should be good here
$res['pay_url'] = $this->api_pay_endpoint . $res['payment_id'];
$res['gateway_id'] = $this->gatewayId;
return $res;
$json['pay_url'] = $this->api_pay_endpoint . $json['payment_id'];
$json['gateway_id'] = $this->gatewayId;
return $json;
}

/**
Expand Down

0 comments on commit b09762c

Please sign in to comment.