Пример #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();
     }
 }
 /**
  * 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
 /**
  * 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;
 }
Пример #4
0
 public function pingback($getData)
 {
     $this->_helper->getInitConfig();
     $pingback = new \Paymentwall_Pingback($getData, $_SERVER['REMOTE_ADDR']);
     if ($pingback->validate()) {
         $orderModel = $this->_objectManager->get('Magento\\Sales\\Model\\Order');
         $orderIncrementId = $pingback->getProductId();
         $orderModel->loadByIncrementId($orderIncrementId);
         $orderStatus = $orderModel::STATE_CANCELED;
         if ($pingback->isDeliverable()) {
             $orderStatus = $orderModel::STATE_PROCESSING;
             $this->createOrderInvoice($orderModel, $pingback);
         } elseif ($pingback->isCancelable()) {
             $orderStatus = $orderModel::STATE_CANCELED;
         }
         $orderModel->setStatus($orderStatus);
         $orderModel->save();
         $result = self::PINGBACK_OK;
     } else {
         $result = $pingback->getErrorSummary();
     }
     return $result;
 }
<?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 {
Пример #6
0
 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
 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;
 }
 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;
     }
 }
Пример #9
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();
     }
 }
Пример #10
0
 /**
  * Process Pingback Request
  *
  * Validates the incoming POST/GET response from the gateway to ensure it is
  * legitimate and can be trusted.
  *
  * @param array $get The GET data for this request
  * @param array $post The POST data for this request
  * @return array An array of transaction data, sets any errors using Input if the data fails to validate
  *  - client_id The ID of the client that attempted the payment
  *  - amount The amount of the payment
  *  - currency The currency of the payment
  *  - invoices An array of invoices and the amount the payment should be applied to (if any) including:
  *    - id The ID of the invoice to apply to
  *    - amount The amount to apply to the invoice
  *    - status The status of the transaction (approved, declined, void, pending, reconciled, refunded, returned)
  *    - reference_id The reference ID for gateway-only use with this transaction (optional)
  *    - transaction_id The ID returned by the gateway to identify this transaction
  *    - parent_transaction_id The ID returned by the gateway to identify this transaction's original transaction (in the case of refunds)
  */
 public function validate(array $get, array $post)
 {
     $status = "error";
     $amount = 0;
     $currency = '';
     $this->initPaymentwallConfigs();
     $pingback = new Paymentwall_Pingback($_GET, $this->getRealClientIP());
     list($type, $client_id, $amount, $currency, $gateway_id, $company_id) = explode('|', $pingback->getProductId());
     if (!$amount or !$currency) {
         $this->Input->setErrors($this->getCommonError("invalid"));
     }
     if ($pingback->validate()) {
         if ($pingback->isDeliverable()) {
             $status = 'approved';
         } elseif ($pingback->isCancelable()) {
             $status = 'declined';
         }
     } else {
         $status = 'error';
     }
     // Log the response
     $this->log($this->ifSet($_SERVER['REQUEST_URI']), serialize($get), "output", true);
     // Clone function processNotification in class GatewayPayments
     // Process transaction after validate
     $this->processTransaction(array('client_id' => $pingback->getUserId(), 'amount' => $amount, 'currency' => $currency, 'status' => $status, 'reference_id' => null, 'transaction_id' => $pingback->getReferenceId(), 'parent_transaction_id' => null, 'invoices' => $this->unserializeInvoices($pingback->getParameter('invoice')), 'gateway_id' => $gateway_id, 'company_id' => $company_id));
 }
Пример #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;
}