@@ -1431,6 +1431,13 @@ public function angelleye_get_transactionDetails($transaction_id) {
14311431 }
14321432 $ this ->add_ec_angelleye_paypal_php_library ();
14331433
1434+ // Avoid fatal errors when gateway context could not be resolved and
1435+ // PayPal client was not initialized.
1436+ if (!is_object ($ this ->paypal )) {
1437+ $ this ->ec_add_log ('GetTransactionDetails skipped: PayPal client not initialized. ' , 'error ' );
1438+ return false ;
1439+ }
1440+
14341441 if ($ this ->payment_method != 'paypal_pro_payflow ' ) {
14351442 $ GTDFields = array (
14361443 'transactionid ' => $ transaction_id
@@ -1584,14 +1591,54 @@ public function angelleye_set_payment_method() {
15841591
15851592 public function angelleye_set_payment_method_using_transaction_id ($ transaction ) {
15861593 if (empty ($ this ->payment_method ) || $ this ->payment_method == false ) {
1594+ // Primary path: resolve paypal_transaction post by transaction ID.
1595+ $ transaction_post_id = $ this ->get_post_by_title ($ transaction );
1596+ if (!empty ($ transaction_post_id )) {
1597+ $ transaction_post = get_post ($ transaction_post_id );
1598+ if (!empty ($ transaction_post ) && !empty ($ transaction_post ->post_parent )) {
1599+ $ order = wc_get_order ($ transaction_post ->post_parent );
1600+ if (!empty ($ order )) {
1601+ $ this ->payment_method = $ order ->get_payment_method ();
1602+ $ this ->order_id = $ order ->get_id ();
1603+ return ;
1604+ }
1605+ }
1606+
1607+ $ order_id = get_post_meta ($ transaction_post_id , 'order_id ' , true );
1608+ if (!empty ($ order_id )) {
1609+ $ order = wc_get_order ($ order_id );
1610+ if (!empty ($ order )) {
1611+ $ this ->payment_method = $ order ->get_payment_method ();
1612+ $ this ->order_id = $ order ->get_id ();
1613+ return ;
1614+ }
1615+ }
1616+ }
1617+
1618+ // Fallback for legacy/meta-only mappings.
15871619 global $ wpdb ;
15881620 $ results = $ wpdb ->get_results ($ wpdb ->prepare ("SELECT post_id FROM {$ wpdb ->prefix }postmeta WHERE meta_value = %s ORDER BY meta_id " , $ transaction ));
15891621 if (!empty ($ results [0 ]->post_id )) {
1590- $ order = wc_get_order ($ results [0 ]->post_id );
1591- if (empty ($ order )) {
1592- return false ;
1622+ $ candidate_post_id = (int ) $ results [0 ]->post_id ;
1623+ $ candidate_post = get_post ($ candidate_post_id );
1624+ $ order_id = 0 ;
1625+
1626+ if (!empty ($ candidate_post ) && 'paypal_transaction ' === $ candidate_post ->post_type ) {
1627+ $ order_id = (int ) $ candidate_post ->post_parent ;
1628+ if (empty ($ order_id )) {
1629+ $ order_id = (int ) get_post_meta ($ candidate_post_id , 'order_id ' , true );
1630+ }
1631+ } else {
1632+ $ order_id = $ candidate_post_id ;
1633+ }
1634+
1635+ if (!empty ($ order_id )) {
1636+ $ order = wc_get_order ($ order_id );
1637+ if (!empty ($ order )) {
1638+ $ this ->payment_method = $ order ->get_payment_method ();
1639+ $ this ->order_id = $ order ->get_id ();
1640+ }
15931641 }
1594- $ this ->payment_method = $ order ->get_payment_method ();
15951642 }
15961643 }
15971644 }
@@ -2107,6 +2154,7 @@ public function angelleye_wc_braintree_docapture($order) {
21072154 $ request_data ['paymentMethodToken ' ] = $ transaction_id ;
21082155 $ request_data ['amount ' ] = $ AMT ;
21092156 $ request_data ['options ' ] = array ('submitForSettlement ' => true );
2157+ $ request_data ['channel ' ] = PAYPAL_PARTNER_ATTRIBUTION_ID ;
21102158 $ result = $ gateway_obj ->pfw_braintree_do_capture ($ order , $ request_data );
21112159 if ($ result != false ) {
21122160 $ maybe_settled_later = array (
0 commit comments