Changeset 3248078
- Timestamp:
- 02/27/2025 07:56:32 PM (13 months ago)
- Location:
- bulletproof-checkout-lite/trunk/includes
- Files:
-
- 2 edited
-
class-wc-bulletproof-shop-orders.php (modified) (2 diffs)
-
class-wc-bulletproof-webhook.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-shop-orders.php
r3247461 r3248078 228 228 echo "<td>" . $active_payment_gateway . "</td>"; 229 229 230 230 $billing_line = ""; 231 231 // Billing info line 232 232 if ($card_type != '') { 233 233 $billing_line = "Billing Name: " . $billing_first_name . " " . $billing_last_name . "<br>Credit Card Type: " . $card_type . "<br>Credit Card Number:" . $card_first6 . "******" . $card_last4 . "<br>"; 234 234 } else { 235 $billing_line = ""; 235 if ($billing_first_name != "") { 236 $billing_line = "Billing Name: " . $billing_first_name . " " . $billing_last_name . "<br>"; 237 if ($card_first6 != "") { 238 $billing_line .= "Credit Card Number:" . $card_first6 . "******" . $card_last4 . "<br>"; 239 } 240 } 236 241 } 237 242 echo "<td>" . $billing_line . "</td>"; … … 261 266 echo "<td>"; 262 267 // Add any cardholder authentication info 263 if ($cavv != "" && $cardholder_auth == "verified" && $eci !="") {268 if ($cavv != "" && $cardholder_auth == "verified" && $eci != "") { 264 269 echo "<label style='color:green;'>This transaction has received 3DS authentication</label>"; 265 270 } -
bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-webhook.php
r3247461 r3248078 119 119 * Update the order status from Pending Payment, pendingsettlement or completed to refund 120 120 */ 121 private function refund_order($data )121 private function refund_order($data, $status_after_order_completed) 122 122 { 123 123 if ((isset($data['order_id'])) && (is_numeric($data['order_id']))) { 124 124 $order = wc_get_order($data['order_id']); 125 if ($order && ($order->get_status() === 'pending' || $order->get_status() === 'Pending payment') || ($order->get_status() === 'completed') ) {125 if ($order && ($order->get_status() === 'pending' || $order->get_status() === 'Pending payment') || ($order->get_status() === 'completed') || ($order->get_status() === $status_after_order_completed)) { 126 126 // Only if the payment method used was the BulletProof Lite Plugin will update the status 127 127 $payment_method_used = $order->get_meta('_payment_method', true); 128 if ($payment_method_used == "bulletproof_bpcheckout_lite") { 129 $the_msg = 'Status updated to refund by the BulletProof Plugin'; 130 $order->update_status("refunded", __($the_msg, 'bulletproof-checkout-lite')); 128 if (($payment_method_used == "bulletproof_bpcheckout_lite") || ($payment_method_used == "bulletproof_bpcheckout")) { 129 // Check if the order amount matches (full refund) 130 if ((isset($data['requested_amount'])) && ($data['requested_amount'] != "")) { 131 // compares against the order amount 132 if (number_format($data['requested_amount'], 2, '.', '') == number_format($order->get_total(), 2, '.', '')) { 133 $valid_amount = true; 134 } else { 135 if ($data['requested_amount'] < $order->get_total()) { 136 $valid_amount = false; 137 } else { 138 $valid_amount = true; 139 } 140 } 141 } else { 142 // If no amount was received, potentially is a full refund 143 $valid_amount = true; 144 } 145 if ($valid_amount) { 146 $the_msg = 'Status updated to refund by the BulletProof Plugin'; 147 $order->update_status("refunded", __($the_msg, 'bulletproof-checkout-lite')); 148 } else { 149 // Partial refund was triggered, just leave a note, but do not update the order status 150 $currency_code = $order->get_currency(); 151 $currency_symbol = get_woocommerce_currency_symbol($currency_code); 152 $the_msg = "Partial refund issued by the BulletProof Gateway for " . $currency_symbol . number_format($data['requested_amount'], 2, '.', ''); 153 $order->add_order_note($the_msg); 154 } 131 155 $order->save(); 132 156 } … … 138 162 * Update the order status from Pending Payment, pendingsettlement or completed to cancelled 139 163 */ 140 private function cancel_order($data )164 private function cancel_order($data, $status_after_order_completed) 141 165 { 142 166 if ((isset($data['order_id'])) && (is_numeric($data['order_id']))) { 143 167 $order = wc_get_order($data['order_id']); 144 if ($order && ($order->get_status() === 'pending' || $order->get_status() === 'Pending payment') || ($order->get_status() === 'completed') ) {168 if ($order && ($order->get_status() === 'pending' || $order->get_status() === 'Pending payment') || ($order->get_status() === 'completed') || ($order->get_status() === $status_after_order_completed)) { 145 169 // Only if the payment method used was the BulletProof Lite Plugin will update the status 146 170 $payment_method_used = $order->get_meta('_payment_method', true); 147 if ( $payment_method_used == "bulletproof_bpcheckout_lite") {171 if (($payment_method_used == "bulletproof_bpcheckout_lite") || ($payment_method_used == "bulletproof_bpcheckout")) { 148 172 $the_msg = 'Status updated to cancelled by the BulletProof Plugin'; 149 173 $order->update_status("cancelled", __($the_msg, 'bulletproof-checkout-lite')); … … 276 300 $event_type = $data_json['event_type']; 277 301 $data = $data_json['event_body']; 302 // Status after order completed 303 if (isset($gateway_settings['status_after_order_completed'])) { 304 $next_status = $gateway_settings['status_after_order_completed']; 305 } else { 306 $next_status = ""; 307 } 278 308 switch ($event_type) { 279 309 case "transaction.sale.success": 280 // Status after order completed281 if (isset($gateway_settings['status_after_order_completed'])) {282 $next_status = $gateway_settings['status_after_order_completed'];283 } else {284 $next_status = "";285 }286 310 self::update_order($data, $next_status); 287 311 break; 288 312 case "transaction.void.success": 289 self::cancel_order($data );313 self::cancel_order($data, $next_status); 290 314 break; 291 315 case "transaction.refund.success": 292 self::refund_order($data );316 self::refund_order($data, $next_status); 293 317 break; 294 318 default:
Note: See TracChangeset
for help on using the changeset viewer.