Exemplo n.º 1
0
 public function index()
 {
     $this->load->model('checkout/order');
     $this->load->model('payment/paymentwall');
     $this->load->model('setting/setting');
     $defaultConfigs = $this->model_setting_setting->getSetting('config');
     // Init Paymentwall configs
     $this->model_payment_paymentwall->initPaymentwallConfig();
     $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
     $order = $this->model_checkout_order->getOrder($pingback->getProduct()->getId());
     if (!$order) {
         die('Order invalid!');
     }
     // Confirm order if status is null
     if (!$order['order_status']) {
         $this->model_checkout_order->addOrderHistory($order['order_id'], $defaultConfigs['config_order_status_id'], '', true);
     }
     if ($pingback->validate()) {
         if ($pingback->isDeliverable()) {
             $this->model_payment_paymentwall->callDeliveryApi($order, $pingback->getReferenceId());
             $this->model_checkout_order->addOrderHistory($pingback->getProduct()->getId(), $this->config->get('paymentwall_complete_status'), '', true);
         } elseif ($pingback->isCancelable()) {
             $this->model_checkout_order->addOrderHistory($pingback->getProduct()->getId(), $this->config->get('paymentwall_cancel_status'), '', true);
         }
         echo self::DEFAULT_PINGBACK_RESPONSE_SUCCESS;
     } else {
         echo $pingback->getErrorSummary();
     }
 }
<?php

require_once __DIR__ . '/include.php';
if ($settings['myorderbox']['status'] && isset($settings['myorderbox']['uni'][$_GET['ps']])) {
    date_default_timezone_set("UTC");
    $pingback = new Paymentwall_Pingback($_GET, $settings['global']['user_ip']);
    if (isset($_GET['origin_price']) && $_GET['origin_price'] > 0) {
        $price = $_GET['origin_price'];
    } else {
        $price = $_GET['product_price'] - $settings['myorderbox']['uni'][$_GET['ps']]['commission']($_GET['product_price'], $_GET['product_currency'], $_GET['usertype']);
    }
    if ($pingback->validate()) {
        $productId = $pingback->getProduct()->getId();
        $rkey = md5(microtime() . $_GET['uid'] . $key);
        $key = $settings['myorderbox']['uni'][$_GET['ps']]['key'];
        if ($pingback->isDeliverable()) {
            $checksum = generateChecksum($productId, $price, $price, 'Y', $rkey, $key);
            $post_data = 'transid=' . $productId . '&status=Y&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price;
            $find = $database['myorderbox']->findOne(['id' => $_GET['ref']], ['data']);
            if (isset($find['data'])) {
                $curl = ['code' => 200, 'data' => $find['data']];
            } else {
                $curl = curlPost($post_data, $redirect_url);
            }
            $date = date('Y/m/d H:i:s') . ' +0000';
            $mail = $_GET['email'];
            if (strstr($curl['data'], "transStatus=Success")) {
                $database['myorderbox']->insert(['id' => $_GET['ref'], 'data' => $curl['data']]);
                $success = true;
            }
        } else {
 function check_ipn_response()
 {
     if (isset($_GET['paymentwallListener']) && $_GET['paymentwallListener'] == 'paymentwall_IPN') {
         $this->paymentwall_init();
         unset($_GET['paymentwallListener']);
         $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
         if ($pingback->validate()) {
             $productId = $pingback->getProduct()->getId();
             $order = new jigoshop_order((int) $productId);
             if ($order->id) {
                 if ($pingback->isDeliverable()) {
                     $order->update_status('completed', __('Order completed!', 'jigoshop'));
                 } else {
                     if ($pingback->isCancelable()) {
                         $order->update_status('canceled', __('Order canceled by Paymentwall!', 'jigoshop'));
                     }
                 }
                 $order->add_order_note(__('IPN payment completed', 'jigoshop'));
                 echo 'OK';
                 // Paymentwall expects response to be OK, otherwise the pingback will be resent
             } else {
                 echo "Undefined order!";
             }
         } else {
             echo $pingback->getErrorSummary();
         }
         die;
     }
 }
Exemplo n.º 4
0
function edd_paymentwall_pingback()
{
    edd_initialize_paymentwall_lib();
    if (isset($_GET['edd-listener']) && $_GET['edd-listener'] != '') {
        unset($_GET['edd-listener']);
    }
    $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
    if ($pingback->validate()) {
        $payment_id = $pingback->getProduct()->getId();
        if ($pingback->isDeliverable()) {
            edd_update_payment_status($payment_id, 'publish');
        } else {
            if ($pingback->isCancelable()) {
                edd_update_payment_status($payment_id, 'refunded');
            } else {
                echo $pingback->getErrorSummary();
            }
        }
        echo 'OK';
    } else {
        echo $pingback->getErrorSummary();
    }
    die;
}
 function check_ipn_response()
 {
     $_REQUEST['ipn'] = true;
     $signatureParams = $_GET;
     //These parameters are not necessary for calculating signature
     if (isset($signatureParams['wc-api']) && $signatureParams['wc-api'] != '') {
         unset($signatureParams['wc-api']);
     }
     if (isset($signatureParams['paymentwallListener']) && $signatureParams['paymentwallListener'] != '') {
         unset($signatureParams['paymentwallListener']);
     }
     $pingback = new Paymentwall_Pingback($signatureParams, $_SERVER['REMOTE_ADDR']);
     if ($pingback->validate()) {
         $goodsId = $pingback->getProduct()->getId();
         $reason = $pingback->getParameter('reason');
         $order = new WC_Order((int) $goodsId);
         global $woocommerce;
         if ($order->get_order($goodsId)) {
             if ($pingback->isCancelable()) {
                 $order->update_status('cancelled', __('Reason: ' . $reason, 'woocommerce'));
             } else {
                 $order->add_order_note(__('Paymentwall payment completed', 'woocommerce'));
                 $order->payment_complete();
                 $woocommerce->cart->empty_cart();
             }
             echo 'OK';
         } else {
             echo 'Paymentwall IPN Request Failure';
         }
     } else {
         echo $pingback->getErrorSummary();
     }
     return;
 }