コード例 #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();
     }
 }
コード例 #2
0
 /**
  * Process pingback request
  */
 function check_ipn_response()
 {
     if (isset($_GET['paymentwallListener']) && $_GET['paymentwallListener'] == 'paymentwall_IPN') {
         $this->init_paymentwall_configs();
         $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
         if ($pingback->validate()) {
             $order = new jigoshop_order($pingback->getProductId());
             // Check order exist and payment method is paymentwall
             if ($order->id && $order->payment_method == $this->id) {
                 $order->add_order_note(__('IPN payment completed', PW_JIGO_TEXT_DOMAIN));
                 if ($pingback->isDeliverable()) {
                     // Call Delivery Confirmation API
                     if ($this->delivery == 'yes') {
                         // Delivery Confirmation
                         $delivery = new Paymentwall_GenerericApiObject('delivery');
                         $response = $delivery->post($this->prepare_delivery_confirmation_data($order, $pingback->getReferenceId()));
                     }
                     $order->update_status('processing', __('Order approved! Transaction ID: #' . $pingback->getReferenceId(), PW_JIGO_TEXT_DOMAIN));
                     $order->payment_complete();
                 } elseif ($pingback->isCancelable()) {
                     $order->update_status(PW_JIGO_ORDER_STATUS_CANCELED, __('Order canceled by Paymentwall!', PW_JIGO_TEXT_DOMAIN));
                 }
                 echo PW_JIGO_DEFAULT_SUCCESS_PINGBACK_VALUE;
                 // Paymentwall expects response to be OK, otherwise the pingback will be resent
             } else {
                 echo __("Undefined order or Payment method is invalid!", PW_JIGO_TEXT_DOMAIN);
             }
         } else {
             echo $pingback->getErrorSummary();
         }
         die;
     }
 }
コード例 #3
0
ファイル: func.php プロジェクト: vukhacdiep/module-cscart
function fn_paymentwall_handlePingback($configs)
{
    fn_paymentwall_initPaymentwallSdk($configs['key'], $configs['secret']);
    $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
    if ($pingback->validate()) {
        if ($pingback->getType() == PW_CREDIT_TYPE_CHARGEBACK) {
            // Update order status: Canceled
            fn_paymentwall_updateOrderStatus($pingback->getProductId(), PW_ORDER_STATUS_CANCELED);
        } else {
            // Update order status: Processed
            fn_paymentwall_updateOrderStatus($pingback->getProductId(), PW_ORDER_STATUS_PROCESSED);
        }
        return true;
    } else {
        echo $pingback->getErrorSummary();
        return false;
    }
}
コード例 #4
0
 /**
  * Authorize Payment
  */
 public function auth($donation)
 {
     /* Get any gateway settings */
     $settings = json_decode($this->settings, true);
     self::initPaymentwall($settings['api_key'], $settings['api_secretkey']);
     $params = $_GET;
     $pingback = new \Paymentwall_Pingback($params, $_SERVER['REMOTE_ADDR']);
     $result = array();
     if ($pingback->validate(true)) {
         if ($pingback->isDeliverable()) {
             //$result = array( 'id' => $params['id'], 'status' => 'okay', 'amount' => $params['amount'], 'gw_id' => $params['ref'] );
         } elseif ($pingback->isCancelable()) {
         }
         echo "OK";
     } else {
         echo $pingback->getErrorSummary();
         die;
     }
     return $params;
 }
コード例 #5
0
                $database['myorderbox']->insert(['id' => $_GET['ref'], 'data' => $curl['data']]);
                $success = true;
            }
        } else {
            if ($pingback->isCancelable()) {
                $checksum = generateChecksum($productId, $price, $price, 'N', $rkey, $key);
                $post_data = 'transid=' . $productId . '&status=N&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price;
                $curl = curlPost($post_data, $redirect_url);
                $curl['code'] = 1001;
            }
        }
        header('HTTP/1.1 ' . $curl['code']);
        $insert = apc_store('transid-' . $productId, $curl['data'], 3600);
        if ($curl['code'] == 200 && $success) {
            if ($insert) {
                echo 'OK';
            } else {
                print_r($insert);
            }
        } elseif ($curl['code'] == 1001) {
            echo 'OK';
        } else {
            print_r($response);
            echo $curl['code'];
        }
    } else {
        echo $pingback->getErrorSummary();
    }
} else {
    echo "Unsupported";
}
コード例 #6
0
ファイル: paymentwall.php プロジェクト: helenseo/pay
 public function pingback()
 {
     $get_data = array();
     foreach ($_GET as $key => $value) {
         $get_data[$key] = $value;
     }
     $this->_log($get_data, 'paymentwall callback value');
     $temp_order = $this->pay_model->get_recharge_order($get_data['goodsid']);
     $merchant_info = $this->pay_model->get_merchant_data_by_pay_type($temp_order->pay_type_id, $temp_order->method_id);
     $appkey = $merchant_info['merchant_key'];
     $secretkey = $merchant_info['merchant_key2'];
     Paymentwall_Base::setApiType(Paymentwall_Base::API_GOODS);
     Paymentwall_Base::setAppKey($appkey);
     // available in your Paymentwall merchant area
     Paymentwall_Base::setSecretKey($secretkey);
     // available in your Paymentwall merchant area
     $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
     if ($pingback->validate(true)) {
         if ($pingback->isDeliverable()) {
             $test = "success";
             // deliver the virtual currency
             $pay_order = array('order_sn' => $pingback->getProductId(), 'tradeseq' => $pingback->getReferenceId());
             $ret = $this->payorder->update_order_to_recharging($pay_order);
             if (false === $ret) {
                 $this->_log('update order to status 2 false: update params is ' . json_encode($pay_order));
             }
             $order_info = $this->pay_model->get_recharge_order($pay_order['order_sn']);
             if (empty($order_info)) {
                 $this->_log('the callback order_sn does not exist');
                 echo 'OK';
                 return;
             }
             if ($order_info->offer_yuanbao == 1) {
                 $this->_log('before offer service, order_status offer_yuanbao is already 1!');
                 echo 'OK';
                 return;
             }
             $delivery_order = array('uid' => $order_info->pay_user_id, 'yuanbao_amount' => $order_info->yuanbao_amount, 'server_id' => $order_info->server_id, 'order_sn' => $order_info->order_sn, 'game_id' => $order_info->game_id);
             $ret = $this->payorder->update_order_to_get_payment(array('order_sn' => $pay_order['order_sn']));
             if (true !== $ret) {
                 $this->_log('update order to get payment false');
             }
             $offer_ret = $this->_complete_order($delivery_order);
             if (true === $offer_ret) {
                 $ret = $this->payorder->update_order_to_offer_service(array('order_sn' => $pay_order['order_sn']));
             }
         } else {
             if ($pingback->isCancelable()) {
                 $test = "failed";
                 $ret = $this->payorder->update_order_to_recharging($pay_order);
                 if (false === $ret) {
                     $this->_log('update order to status 2 false: update params is ' . json_encode($pay_order) . '!');
                 }
             }
         }
         echo 'OK';
     } else {
         echo $pingback->getErrorSummary();
         $this->_log($pingback->getErrorSummary());
     }
 }
コード例 #7
0
 /**
  * Validates the callback request is valid. If failure happens, the response should
  * tell the processor to retry.
  * @return bool
  *
  */
 public function validateRequest()
 {
     initPaymentwallConfigs($this->options->get('Paymentwall_appKey'), $this->options->get('Paymentwall_appSecret'));
     $pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
     if ($pingback->validate()) {
         return true;
     } else {
         $this->logMessages[] = $pingback->getErrorSummary();
         return false;
     }
 }
コード例 #8
0
 public function pingBack($getData)
 {
     unset($getData['controller']);
     $pingback = new Paymentwall_Pingback($getData, $_SERVER['REMOTE_ADDR']);
     $orderId = $pingback->getProductId();
     if ($pingback->validate()) {
         $history = new OrderHistory();
         $history->id_order = $orderId;
         if ($pingback->isDeliverable()) {
             $history->changeIdOrderState(Configuration::get('PAYMENTWALL_ORDER_STATUS'), $orderId);
             $history->addWithemail(true, array());
         } elseif ($pingback->isCancelable()) {
             $history->changeIdOrderState(self::ORDER_CANCEL, $orderId);
         }
         $result = "OK";
     } else {
         $result = $pingback->getErrorSummary();
     }
     return $result;
 }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 public function handlerPingback(\IPS\nexus\Transaction $transaction)
 {
     $settings = $this->getSettings();
     self::initPaymentwall($settings['project_key'], $settings['secret_key']);
     $pingback = new \Paymentwall_Pingback($_GET, $this->getRealClientIP());
     if ($pingback->validate()) {
         $invoice = $transaction->get_invoice();
         if ($pingback->isDeliverable()) {
             // Call Delivery Confirmation API
             if ($settings['delivery']) {
                 // Delivery Confirmation
                 $delivery = new \Paymentwall_GenerericApiObject('delivery');
                 $response = $delivery->post($this->prepareDeleveryData($transaction, $settings['test_mode']), $pingback->getReferenceId());
             }
             $transaction->approve();
         } else {
             if ($pingback->isCancelable()) {
                 if ($invoice->status == \IPS\nexus\Invoice::STATUS_PAID) {
                     $transaction->refund();
                     // Update invoice status
                     $invoice->markUnpaid(\IPS\nexus\Invoice::STATUS_CANCELED);
                 }
             }
         }
         return self::DEFAULT_PINGBACK_RESPONSE;
         // Paymentwall expects response to be OK, otherwise the pingback will be resent
     } else {
         return $pingback->getErrorSummary();
     }
 }
コード例 #11
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;
}
コード例 #12
0
 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;
 }