Plugin Directory

Changeset 3248078


Ignore:
Timestamp:
02/27/2025 07:56:32 PM (13 months ago)
Author:
bulletproofcheckout
Message:

Update the Billing information live

Location:
bulletproof-checkout-lite/trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-shop-orders.php

    r3247461 r3248078  
    228228                echo "<td>" . $active_payment_gateway . "</td>";
    229229
    230 
     230                $billing_line = "";
    231231                // Billing info line
    232232                if ($card_type != '') {
    233233                    $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>";
    234234                } 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                    }
    236241                }
    237242                echo "<td>" . $billing_line . "</td>";
     
    261266                echo "<td>";
    262267                // Add any cardholder authentication info
    263                 if ($cavv != "" && $cardholder_auth == "verified" && $eci!="") {
     268                if ($cavv != "" && $cardholder_auth == "verified" && $eci != "") {
    264269                    echo "<label style='color:green;'>This transaction has received 3DS authentication</label>";
    265270                }
  • bulletproof-checkout-lite/trunk/includes/class-wc-bulletproof-webhook.php

    r3247461 r3248078  
    119119     * Update the order status from Pending Payment, pendingsettlement or completed to refund
    120120     */
    121     private function refund_order($data)
     121    private function refund_order($data, $status_after_order_completed)
    122122    {
    123123        if ((isset($data['order_id'])) && (is_numeric($data['order_id']))) {
    124124            $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)) {
    126126                // Only if the payment method used was the BulletProof Lite Plugin will update the status
    127127                $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                    }
    131155                    $order->save();
    132156                }
     
    138162     * Update the order status from Pending Payment, pendingsettlement or completed to cancelled
    139163     */
    140     private function cancel_order($data)
     164    private function cancel_order($data, $status_after_order_completed)
    141165    {
    142166        if ((isset($data['order_id'])) && (is_numeric($data['order_id']))) {
    143167            $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)) {
    145169                // Only if the payment method used was the BulletProof Lite Plugin will update the status
    146170                $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")) {
    148172                    $the_msg = 'Status updated to cancelled by the BulletProof Plugin';
    149173                    $order->update_status("cancelled", __($the_msg, 'bulletproof-checkout-lite'));
     
    276300                                $event_type = $data_json['event_type'];
    277301                                $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                                }
    278308                                switch ($event_type) {
    279309                                    case "transaction.sale.success":
    280                                         // Status after order completed
    281                                         if (isset($gateway_settings['status_after_order_completed'])) {
    282                                             $next_status = $gateway_settings['status_after_order_completed'];
    283                                         } else {
    284                                             $next_status = "";
    285                                         }
    286310                                        self::update_order($data, $next_status);
    287311                                        break;
    288312                                    case "transaction.void.success":
    289                                         self::cancel_order($data);
     313                                        self::cancel_order($data, $next_status);
    290314                                        break;
    291315                                    case "transaction.refund.success":
    292                                         self::refund_order($data);
     316                                        self::refund_order($data, $next_status);
    293317                                        break;
    294318                                    default:
Note: See TracChangeset for help on using the changeset viewer.