/**
  * 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;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $order
  */
 public function callDeliveryApi($order, $ref)
 {
     if ($this->config->get('paymentwall_delivery')) {
         // Delivery Confirmation
         $delivery = new Paymentwall_GenerericApiObject('delivery');
         $response = $delivery->post($this->prepareDeliveryData($order, $ref));
     }
 }
Ejemplo n.º 3
0
/**
 * @param $invoiceid
 * @param $hosting
 * @param $userData
 * @param $orderData
 * @param $pingback
 */
function sendDeliveryApiRequest($invoiceid, $hosting, $userData, $orderData, $pingback)
{
    // Get Delivery data from DB
    $deliveryData = mysql_fetch_assoc(select_query('pw_delivery_data', '*', array("package_id" => $hosting['packageid'], "user_id" => $userData['id'], "username" => $hosting['username'], "order_id" => $orderData['id'], "status" => "unsent")));
    if ($deliveryData) {
        $data = array_merge(array('payment_id' => $pingback->getReferenceId(), 'status' => 'delivered', 'estimated_delivery_datetime' => date('Y/m/d H:i:s'), 'estimated_update_datetime' => date('Y/m/d H:i:s'), 'details' => 'Item will be delivered via email by ' . date('Y/m/d H:i:s')), json_decode($deliveryData['data'], true));
        $delivery = new Paymentwall_GenerericApiObject('delivery');
        $response = $delivery->post($data);
        // Update status
        updateDeliveryStatus($deliveryData['id'], 'sent', $data, $invoiceid, $pingback->getReferenceId());
    }
}
Ejemplo 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();
     }
 }
Ejemplo n.º 5
0
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]);
    }
    echo 'OK';
} else {
    echo $pingback->getErrorSummary();
}
die;