/**
  * 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;
     }
 }
示例#2
0
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;
    }
}
示例#3
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;
 }
示例#4
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());
     }
 }
示例#5
0
<?php

# Required File Includes
include "../../../init.php";
$whmcs->load_function('gateway');
$whmcs->load_function('invoice');
define('PW_WHMCS_ITEM_TYPE_HOSTING', 'Hosting');
require_once ROOTDIR . "/includes/api/paymentwall_api/lib/paymentwall.php";
$gateway = getGatewayVariables("paymentwall");
if (!$gateway["type"]) {
    die("Module Not Activated");
}
Paymentwall_Config::getInstance()->set(array('api_type' => Paymentwall_Config::API_GOODS, 'public_key' => $gateway['appKey'], 'private_key' => $gateway['secretKey']));
$pingback = new Paymentwall_Pingback($_GET, $_SERVER['REMOTE_ADDR']);
$invoiceid = checkCbInvoiceID($pingback->getProductId(), $gateway["name"]);
if ($invoiceid && $pingback->validate()) {
    $orderData = mysql_fetch_assoc(select_query('tblorders', 'userid,id', array("invoiceid" => $invoiceid)));
    $userData = mysql_fetch_assoc(select_query('tblclients', 'email, firstname, lastname, country, address1, state, phonenumber, postcode, city, id', array("id" => $orderData['userid'])));
    if ($pingback->isDeliverable()) {
        processDeliverable($invoiceid, $pingback, $gateway, $userData, $orderData);
    } elseif ($pingback->isCancelable()) {
        // WHMCS not supported
        logTransaction($gateway["name"], $_GET, "Not Supported");
        die("Not Supported");
    } else {
        switch ($pingback->getType()) {
            /*
            case Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_EXPIRED:
            case Paymentwall_Pingback::PINGBACK_TYPE_SUBSCRIPTION_PAYMENT_FAILED:
                // Do not process transaction
                break;
 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;
 }
示例#7
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));
 }