コード例 #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
 /**
  * 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;
 }
コード例 #5
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;
    }
}
コード例 #6
0
<?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 {
コード例 #7
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());
     }
 }
コード例 #8
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;
     }
 }
コード例 #9
0
ファイル: paymentwall.php プロジェクト: fanytest/module-whmcs
<?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;
コード例 #10
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;
 }
コード例 #11
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;
     }
 }
コード例 #12
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();
     }
 }
コード例 #13
0
<?php

# Required File Includes
include "../../../dbconnect.php";
include "../../../includes/functions.php";
include "../../../includes/gatewayfunctions.php";
include "../../../includes/invoicefunctions.php";
require_once "../../../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']);
if ($pingback->validate()) {
    $invoiceid = checkCbInvoiceID($_GET['goodsid'], $gateway["name"]);
    $invoiceData = mysql_fetch_array(select_query("tblinvoices", "subtotal, paymentmethod", array("id" => $invoiceid)));
    $orderData = mysql_fetch_array(select_query('tblorders', 'userid', array("invoiceid" => $invoiceid)));
    $userData = mysql_fetch_array(select_query('tblclients', 'email, firstname, lastname, country, address1, state, phonenumber, postcode, city', array("id" => $orderData['userid'])));
    if ($pingback->isDeliverable()) {
        addInvoicePayment($invoiceid, $_GET['ref'], null, null, $invoiceData['paymentmethod']);
        if (isset($gateway['enableDeliveryApi']) && $gateway['enableDeliveryApi'] != '') {
            $delivery = new Paymentwall_GenerericApiObject('delivery');
            $response = $delivery->post(array('payment_id' => $_GET['ref'], 'type' => 'digital', 'status' => 'delivered', 'estimated_delivery_datetime' => date('Y/m/d H:i:s'), 'estimated_update_datetime' => date('Y/m/d H:i:s'), 'refundable' => 'yes', 'details' => 'Item will be delivered via email by ' . date('Y/m/d H:i:s'), 'shipping_address[email]' => $userData['email'], 'shipping_address[firstname]' => $userData['firstname'], 'shipping_address[lastname]' => $userData['lastname'], 'shipping_address[country]' => $userData['country'], 'shipping_address[street]' => $userData['address1'], 'shipping_address[state]' => $userData['state'], 'shipping_address[phone]' => $userData['phonenumber'], 'shipping_address[zip]' => $userData['postcode'], 'shipping_address[city]' => $userData['city'], 'reason' => 'none', 'is_test' => isset($gateway['isTest']) ? 1 : 0, 'product_description' => ''));
            if (isset($response['error'])) {
                var_dump($response['error'], $response['notices']);
            }
        }
    } else {
        $orderData = mysql_fetch_row(select_query("tblorders", "id", array("invoiceid" => $invoiceid)));
        localAPI("cancelorder", $orderData[0]);
コード例 #14
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));
 }
コード例 #15
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;
}
コード例 #16
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;
 }