Skip to content

Commit

Permalink
REST Credit Cards - Log Adjustment, ref #559
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Nov 16, 2016
1 parent 6e6ad66 commit 9323e08
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions angelleye-includes/paypal-rest-api-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,24 @@ public function create_payment($order, $card_data) {
global $woocommerce;
try {
$this->set_trnsaction_obj_value($order, $card_data);
$this->payment->create($this->getAuth());
try {
$this->add_log(print_r($this->payment, true));
$this->payment->create($this->getAuth());
} catch (PayPal\Exception\PayPalConnectionException $ex) {
wc_add_notice(__("Error processing checkout. Please try again. ", 'woo-paypal-plus'), 'error');
return array(
'result' => 'fail',
'redirect' => ''
);
} catch (Exception $ex) {
wc_add_notice(__("Error processing checkout. Please try again. ", 'woo-paypal-plus'), 'error');
$this->add_log($ex->getMessage());
return array(
'result' => 'fail',
'redirect' => ''
);
}

if ($this->payment->state == "approved") {
$transactions = $this->payment->getTransactions();
$relatedResources = $transactions[0]->getRelatedResources();
Expand Down Expand Up @@ -266,10 +283,10 @@ public function card_type_from_account_number($account_number) {
* @return ApiContext
*/
public function getAuth() {
$this->mode = $this->testmode == 'yes' ? 'SANDBOX' : 'LIVE';
$auth = new ApiContext(new OAuthTokenCredential($this->rest_client_id, $this->rest_secret_id));
$auth->setConfig(array('mode' => $this->mode, 'http.headers.PayPal-Partner-Attribution-Id' => 'AngellEYE_SP_WooCommerce', 'log.LogEnabled' => true, 'log.LogLevel' => ($this->mode == 'SANDBOX' ) ? 'DEBUG' : 'INFO', 'log.FileName' => wc_get_log_file_path('paypal_credit_card_rest'), 'cache.enabled' => true, 'cache.FileName' => wc_get_log_file_path('paypal_credit_card_rest_cache')));
$auth->setConfig(array('mode' => $this->mode, 'http.headers.PayPal-Partner-Attribution-Id' => 'AngellEYE_SP_WooCommerce', 'log.LogEnabled' => true, 'log.LogLevel' => ($this->mode == 'SANDBOX' ) ? 'DEBUG' : 'INFO', 'log.FileName' => wc_get_log_file_path('paypal_credit_card_rest')));
return $auth;

}

/**
Expand Down Expand Up @@ -374,7 +391,7 @@ public function add_paypal_rest_api_lib() {
* @param type $message
*/
public function add_log($message) {
if ($this->debug == 'yes') {
if ($this->debug == 'yes' && $this->mode == 'LIVE') {
if (empty($this->log)) {
$this->log = new WC_Logger();
}
Expand Down

0 comments on commit 9323e08

Please sign in to comment.