Plugin Directory

Changeset 2956083


Ignore:
Timestamp:
08/21/2023 08:46:44 AM (3 years ago)
Author:
slimcd
Message:

testing whether the payment is success before updating status using api

Location:
slimcd-payment-gateway
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • slimcd-payment-gateway/tags/1.0.3/includes/class-slimcd-payment-gateway.php

    r2954016 r2956083  
    159159     * @return void
    160160     */
    161     public function slimcd_postback()
     161     public function slimcd_postback()
    162162    {
    163163        header('Content-Type: text/plain');
    164 
     164        $postBackStatus = "Not OK";
    165165        if (isset($_POST['approved']) && isset($_POST['order_id'])) {
    166 
     166            if ("Success" == $this->slimcd_payment_status(sanitize_key($_POST['sessionid']))) {
    167167            $order_id = wc_sanitize_order_id($_POST['order_id']);
    168168            $order = wc_get_order($order_id);
    169             if ($order->get_payment_method() == "slimcd_payment" && $_POST['approved'] == "Y" || $_POST['approved'] == "B") {
    170                 if (isset($_POST['surcharge']) && $_POST['surcharge'] != 0.00 || isset($_POST['conveniencefee']) && $_POST['conveniencefee'] != 0.00) {
    171 
    172                     include __DIR__ . '/convience-surcharge.php';
     169                if ($order->get_payment_method() == "slimcd_payment" && $_POST['approved'] == "Y" || $_POST['approved'] == "B") {
     170                    if (isset($_POST['surcharge']) && $_POST['surcharge'] != 0.00 || isset($_POST['conveniencefee']) && $_POST['conveniencefee'] != 0.00) {
     171                        include __DIR__ . '/convience-surcharge.php';
     172                    }
     173                    $this->slimcd_update_order_status($order_id);
     174                    add_post_meta($order_id, '_transaction_id', (int)$_POST['gateid']);
     175                    $postBackStatus = "OK";
    173176                }
    174                 $this->slimcd_update_order_status($order_id);
    175                 add_post_meta($order_id, '_transaction_id', (int)$_POST['gateid']);
    176                 echo "OK";
    177             } else {
    178                 echo "Not OK";
    179             }
    180         } else {
    181             echo "Not OK";
    182         }
    183 
    184 
     177            }
     178        }
     179        echo $postBackStatus;
    185180        die();
    186181    }
  • slimcd-payment-gateway/trunk/includes/class-slimcd-payment-gateway.php

    r2954026 r2956083  
    162162    {
    163163        header('Content-Type: text/plain');
    164 
     164        $postBackStatus = "Not OK";
    165165        if (isset($_POST['approved']) && isset($_POST['order_id'])) {
    166 
     166            if ("Success" == $this->slimcd_payment_status(sanitize_key($_POST['sessionid']))) {
    167167            $order_id = wc_sanitize_order_id($_POST['order_id']);
    168168            $order = wc_get_order($order_id);
    169             if ($order->get_payment_method() == "slimcd_payment" && $_POST['approved'] == "Y" || $_POST['approved'] == "B") {
    170                 if (isset($_POST['surcharge']) && $_POST['surcharge'] != 0.00 || isset($_POST['conveniencefee']) && $_POST['conveniencefee'] != 0.00) {
    171 
    172                     include __DIR__ . '/convience-surcharge.php';
     169                if ($order->get_payment_method() == "slimcd_payment" && $_POST['approved'] == "Y" || $_POST['approved'] == "B") {
     170                    if (isset($_POST['surcharge']) && $_POST['surcharge'] != 0.00 || isset($_POST['conveniencefee']) && $_POST['conveniencefee'] != 0.00) {
     171                        include __DIR__ . '/convience-surcharge.php';
     172                    }
     173                    $this->slimcd_update_order_status($order_id);
     174                    add_post_meta($order_id, '_transaction_id', (int)$_POST['gateid']);
     175                    $postBackStatus = "OK";
    173176                }
    174                 $this->slimcd_update_order_status($order_id);
    175                 add_post_meta($order_id, '_transaction_id', (int)$_POST['gateid']);
    176                 echo "OK";
    177             } else {
    178                 echo "Not OK";
    179             }
    180         } else {
    181             echo "Not OK";
    182         }
    183 
    184 
     177            }
     178        }
     179        echo $postBackStatus;
    185180        die();
    186181    }
Note: See TracChangeset for help on using the changeset viewer.