/**
  * 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;
     }
 }
Exemplo n.º 2
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();
     }
 }
Exemplo n.º 3
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());
     }
 }
Exemplo n.º 4
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();
     }
 }
Exemplo n.º 5
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));
 }