@@ -95,7 +95,7 @@ class PaymentMethod extends \Magento\Payment\Model\Method\Cc
95
95
* @var bool
96
96
*/
97
97
protected $ _canRefundInvoicePartial = true ;
98
-
98
+
99
99
/**
100
100
* @var string
101
101
*/
@@ -289,7 +289,7 @@ public function validate()
289
289
throw new LocalizedException ($ error );
290
290
}
291
291
}
292
-
292
+
293
293
return $ this ;
294
294
}
295
295
@@ -474,7 +474,7 @@ protected function braintreeAuthorize(InfoInterface $payment, $amount, $capture,
474
474
$ this ->_debug ($ transactionParams );
475
475
try {
476
476
$ result = $ this ->braintreeTransaction ->sale ($ transactionParams );
477
- $ this ->_debug ($ result );
477
+ $ this ->_debug ($ this -> _convertObjToArray ( $ result) );
478
478
} catch (\Exception $ e ) {
479
479
$ this ->_logger ->critical ($ e );
480
480
throw new LocalizedException (__ ('Please try again later ' ));
@@ -589,8 +589,8 @@ public function capture(InfoInterface $payment, $amount)
589
589
$ this ->partialCapture ($ payment , $ amount );
590
590
} else {
591
591
$ result = $ this ->braintreeTransaction ->submitForSettlement ($ payment ->getCcTransId (), $ amount );
592
- $ this ->_debug ($ payment ->getCcTransId ().' - ' .$ amount );
593
- $ this ->_debug ($ result );
592
+ $ this ->_debug ([ $ payment ->getCcTransId ().' - ' .$ amount] );
593
+ $ this ->_debug ($ this -> _convertObjToArray ( $ result) );
594
594
if ($ result ->success ) {
595
595
$ payment ->setIsTransactionClosed (0 )
596
596
->setShouldCloseParentTransaction (false );
@@ -621,8 +621,8 @@ public function refund(InfoInterface $payment, $amount)
621
621
$ transactionId = $ this ->braintreeHelper ->clearTransactionId ($ payment ->getRefundTransactionId ());
622
622
try {
623
623
$ transaction = $ this ->braintreeTransaction ->find ($ transactionId );
624
- $ this ->_debug ($ payment ->getCcTransId ());
625
- $ this ->_debug ($ transaction );
624
+ $ this ->_debug ([ $ payment ->getCcTransId ()] );
625
+ $ this ->_debug ($ this -> _convertObjToArray ( $ transaction) );
626
626
if ($ transaction ->status === \Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT ) {
627
627
if ($ transaction ->amount != $ amount ) {
628
628
$ message = __ ('This refund is for a partial amount but the Transaction has not settled. ' )
@@ -641,7 +641,7 @@ public function refund(InfoInterface $payment, $amount)
641
641
$ result = $ canVoid
642
642
? $ this ->braintreeTransaction ->void ($ transactionId )
643
643
: $ this ->braintreeTransaction ->refund ($ transactionId , $ amount );
644
- $ this ->_debug ($ result );
644
+ $ this ->_debug ($ this -> _convertObjToArray ( $ result) );
645
645
if ($ result ->success ) {
646
646
$ payment ->setIsTransactionClosed (1 );
647
647
} else {
@@ -711,9 +711,9 @@ public function void(InfoInterface $payment)
711
711
}
712
712
$ errors = '' ;
713
713
foreach ($ transactionIds as $ transactionId ) {
714
- $ this ->_debug ('void- ' . $ transactionId );
714
+ $ this ->_debug ([ 'void- ' . $ transactionId] );
715
715
$ result = $ this ->braintreeTransaction ->void ($ transactionId );
716
- $ this ->_debug ($ result );
716
+ $ this ->_debug ($ this -> _convertObjToArray ( $ result) );
717
717
if (!$ result ->success ) {
718
718
$ errors .= ' ' . $ this ->errorHelper ->parseBraintreeError ($ result )->getText ();
719
719
} elseif ($ message ) {
@@ -853,7 +853,7 @@ protected function getChannel()
853
853
*/
854
854
protected function cloneTransaction ($ amount , $ transactionId )
855
855
{
856
- $ this ->_debug ('clone- ' . $ transactionId . ' amount= ' . $ amount );
856
+ $ this ->_debug ([ 'clone- ' . $ transactionId . ' amount= ' . $ amount] );
857
857
$ result = $ this ->braintreeTransaction ->cloneTransaction (
858
858
$ transactionId ,
859
859
[
@@ -863,7 +863,7 @@ protected function cloneTransaction($amount, $transactionId)
863
863
]
864
864
]
865
865
);
866
- $ this ->_debug ($ result );
866
+ $ this ->_debug ($ this -> _convertObjToArray ( $ result) );
867
867
return $ result ;
868
868
}
869
869
@@ -907,28 +907,6 @@ public function canVoid()
907
907
return $ this ->_canVoid ;
908
908
}
909
909
910
- /**
911
- * Log debug data to file
912
- *
913
- * @param mixed $debugData
914
- * @return $this
915
- */
916
- protected function _debug ($ debugData )
917
- {
918
- if (!$ this ->config ->isDebugEnabled ()) {
919
- return $ this ;
920
- }
921
- if (!is_array ($ debugData )) {
922
- if (is_object ($ debugData )) {
923
- $ debugData = var_export ($ debugData , true );
924
- } else {
925
- $ debugData = [$ debugData ];
926
- }
927
- }
928
- parent ::_debug ((array )$ debugData );
929
- return $ this ;
930
- }
931
-
932
910
/**
933
911
* Return replace keys for debug data
934
912
*
@@ -957,4 +935,14 @@ public function getConfigData($field, $storeId = null)
957
935
}
958
936
return $ this ->config ->getConfigData ($ field , $ storeId );
959
937
}
938
+
939
+ /**
940
+ * Convert response from Braintree to array
941
+ * @param \Braintree_Result_Successful|\Braintree_Result_Error|\Braintree_Transaction $data
942
+ * @return array
943
+ */
944
+ protected function _convertObjToArray ($ data )
945
+ {
946
+ return json_decode (json_encode ($ data ), true );
947
+ }
960
948
}
0 commit comments