Exemple #1
0
 public function pay_with_amazon_button()
 {
     $pwacheckkout = new Pwacheckout();
     if ($pwacheckkout->get_option('enabled') == 'yes') {
         $merchantID = $pwacheckkout->get_option('merchant_id');
         $accessKeyID = $pwacheckkout->get_option('access_key');
         $secretKeyID = $pwacheckkout->get_option('secret_key');
         $pwa_btn_color = $pwacheckkout->get_option('pwa_btn_color');
         $pwa_btn_bkgd = $pwacheckkout->get_option('pwa_btn_bkgd');
         $pwa_btn_size = $pwacheckkout->get_option('pwa_btn_size');
         if (!defined('PWA_BTN_COLOR')) {
             define('PWA_BTN_COLOR', $pwa_btn_color);
         }
         if (!defined('PWA_BTN_BKGD')) {
             define('PWA_BTN_BKGD', $pwa_btn_bkgd);
         }
         if (!defined('PWA_BTN_SIZE')) {
             define('PWA_BTN_SIZE', $pwa_btn_size);
         }
         $cartFactory = new XMLCartFactory();
         $calculator = new SignatureCalculator();
         $cart = $cartFactory->getSignatureInput($merchantID, $accessKeyID);
         $signature = $calculator->calculateRFC2104HMAC($cart, $secretKeyID);
         $cartHtml = $cartFactory->getCartHTML($merchantID, $accessKeyID, $signature);
         echo $cartHtml;
     }
 }
Exemple #2
0
 public function notifications($param)
 {
     global $wpdb, $prefix;
     $prefix = $wpdb->prefix . 'pwa_';
     try {
         $uuid = urldecode($param['UUID']);
         $timestamp = urldecode($param['Timestamp']);
         $Signature = str_replace(' ', '+', urldecode($param['Signature']));
         $AWSAccessKeyId = urldecode($param['AWSAccessKeyId']);
         $NotificationType = urldecode($param['NotificationType']);
         $NotificationData = stripslashes(urldecode($param['NotificationData']));
         $wpdb->insert($prefix . 'iopn_records', array('uuid' => $uuid, 'timestamp' => $timestamp, 'notification_type' => $NotificationType));
         $iopn_record_id = $wpdb->insert_id;
         // Verify that the notification request is valid by verifying the Signature
         $concatenate = $uuid . $timestamp;
         $pwacheckkout = new Pwacheckout();
         $secretKeyID = $pwacheckkout->get_option('secret_key');
         $calculator = new SignatureCalculator();
         $generatedSignature = $calculator->calculateRFC2104HMAC($concatenate, $secretKeyID);
         if ($Signature == $generatedSignature) {
             // Verify the Timestamp
             //$this->time_difference($timestamp) > 15
             if (1) {
                 if ($NotificationType == 'NewOrderNotification') {
                     $new_order = new NewOrderNotification();
                     $new_order->update_order($NotificationData, $iopn_record_id);
                 }
                 if ($NotificationType == 'OrderReadyToShipNotification') {
                     $confirm_order = new OrderReadyToShipNotification();
                     $confirm_order->update_order_status($NotificationData, $iopn_record_id);
                 }
                 if ($NotificationType == 'OrderCancelledNotification') {
                     $cancel_order = new OrderCancelledNotification();
                     $cancel_order->cancel_order($NotificationData, $iopn_record_id);
                 }
             } else {
                 $param['message'] = 'IOPN Notifications : ' . $NotificationType . ' : IOPN function called and with wrong timestamp.';
                 $this->generate_log($param);
                 // Respond to the Request
                 header('HTTP/1.1 403 PERMISSION_DENIED');
             }
         } else {
             $param['message'] = 'IOPN Notifications : ' . $NotificationType . ' : IOPN function called and with wrong signature.';
             $this->generate_log($param);
             // Respond to the Request
             header('HTTP/1.1 403 PERMISSION_DENIED');
         }
     } catch (Exception $e) {
         $param['message'] = 'IOPN Notifications : Caught exception : ' . $e->getMessage() . '.';
         $this->generate_log($param);
     }
 }
 public function pay_with_amazon_button($type)
 {
     $merchantID = Configuration::get('PWAPRESTA_PWAPRESTA_MERCHANT_ID');
     $accessKeyID = Configuration::get('PWAPRESTA_PWAPRESTA_ACCESS_KEY');
     $secretKeyID = Configuration::get('PWAPRESTA_PWAPRESTA_SECRET_KEY');
     $pwa_btn_color = Configuration::get('PWAPRESTA_PWAPRESTA_BTN_COLOR');
     $pwa_btn_size = Configuration::get('PWAPRESTA_PWAPRESTA_BTN_SIZE');
     if (!defined('PWA_BTN_COLOR')) {
         define('PWA_BTN_COLOR', $pwa_btn_color);
     }
     if (!defined('PWA_BTN_SIZE')) {
         define('PWA_BTN_SIZE', $pwa_btn_size);
     }
     $cartFactory = new XMLCartFactory();
     $calculator = new SignatureCalculator();
     $cart = $cartFactory->getSignatureInput($merchantID, $accessKeyID);
     $signature = $calculator->calculateRFC2104HMAC($cart, $secretKeyID);
     $cartHtml = $cartFactory->getCartHTML($merchantID, $accessKeyID, $signature, $type);
     return $cartHtml;
 }
Exemple #4
0
 public function index()
 {
     //ini_set('include_path','../..');
     /*
     $this->load->library('signature/merchant/cart/html/MerchantHTMLCartFactory');
     $this->load->library('signature/common/cart/xml/XMLCartFactory');
     $this->load->library('signature/common/signature/SignatureCalculator');
     */
     $this->load->library('signature/MerchantHTMLCartFactory');
     $this->load->library('signature/XMLCartFactory');
     $this->load->library('signature/SignatureCalculator');
     $hashqid = $_GET['qid'];
     $data = array();
     $this->load->model('quotationmodel');
     $status = $this->quotationmodel->statusDetails($hashqid);
     if ($status != 'Initiated') {
         $data['status'] = 'Processing';
         $this->load->view('admin/error', $data);
     } else {
         $quotationdetails = $this->quotationmodel->fetchQuotationDetails($hashqid);
         // seller credentials - enter your own here
         $merchantID = "ALLF7QV9XOHDI";
         $accessKeyID = "AKIAJU37QL3EGT44PQFQ";
         $secretKeyID = "ABok3jwHNgQSZMtho8yu5iHZm45QY0Hq4v3dwMKN";
         /////////////////////////////////////////////////////////
         // XML cart demo
         // Create the cart and the signature
         /////////////////////////////////////////////////////////
         $cartFactory = new XMLCartFactory();
         $calculator = new SignatureCalculator();
         $cart = $cartFactory->getSignatureInput($merchantID, $accessKeyID, $quotationdetails, $hashqid);
         $signature = $calculator->calculateRFC2104HMAC($cart, $secretKeyID);
         $cartHtml = $cartFactory->getCartHTML($merchantID, $accessKeyID, $signature, $quotationdetails, $hashqid);
         $data['cartHtml'] = $cartHtml;
         $data['data'] = json_encode($this->quotationmodel->fetchQuotationDetails($hashqid));
         $this->load->view('admin/onlinepayment', $data);
     }
 }
Exemple #5
0
 public function notifications($param)
 {
     $prefix = _DB_PREFIX_;
     try {
         if (isset($param['UUID']) && $param['UUID'] != '') {
             $uuid = urldecode($param['UUID']);
         } else {
             $uuid = '';
         }
         if (isset($param['Timestamp']) && $param['Timestamp'] != '') {
             $timestamp = urldecode($param['Timestamp']);
         } else {
             $timestamp = '';
         }
         if (isset($param['Signature']) && $param['Signature'] != '') {
             $Signature = str_replace(' ', '+', urldecode($param['Signature']));
         } else {
             $Signature = '';
         }
         if (isset($param['AWSAccessKeyId']) && $param['AWSAccessKeyId'] != '') {
             $AWSAccessKeyId = urldecode($param['AWSAccessKeyId']);
         } else {
             $AWSAccessKeyId = '';
         }
         $NotificationType = urldecode($param['NotificationType']);
         $NotificationData = stripslashes(urldecode($param['NotificationData']));
         if ($uuid != '') {
             $sql = 'INSERT into `' . $prefix . 'pwa_iopn_records` (`uuid`,`timestamp`,`notification_type`) VALUES("' . $uuid . '" , "' . $timestamp . '" , "' . $NotificationType . '") ';
             Db::getInstance()->Execute($sql);
             $iopn_record_id = Db::getInstance()->Insert_ID();
         }
         // Verify that the notification request is valid by verifying the Signature
         $concatenate = $uuid . $timestamp;
         $secretKeyID = Configuration::get('PWAPRESTA_PWAPRESTA_SECRET_KEY');
         $calculator = new SignatureCalculator();
         $generatedSignature = $calculator->calculateRFC2104HMAC($concatenate, $secretKeyID);
         if ($Signature != '' && $Signature == $generatedSignature || $Signature == '') {
             // Verify the Timestamp
             //$this->time_difference($timestamp) > 15
             if (1) {
                 if ($NotificationType == 'NewOrderNotification') {
                     $new_order = new NewOrderNotification();
                     $new_order->update_order($NotificationData, $iopn_record_id);
                 }
                 if ($NotificationType == 'OrderReadyToShipNotification') {
                     if ($Signature == '') {
                         $xml = simplexml_load_string($NotificationData);
                         $AmazonOrderID = (string) $xml->ProcessedOrder->AmazonOrderID;
                         $obj = new Pwapresta();
                         if ($obj->pwa_order_exist($AmazonOrderID)) {
                             $confirm_order = new OrderReadyToShipNotification();
                             $confirm_order->update_order_status($NotificationData, $iopn_record_id);
                             header('HTTP/1.1 200 OK');
                         } else {
                             echo 'Sorry! it seems that this order is a fake order.';
                         }
                     } else {
                         $confirm_order = new OrderReadyToShipNotification();
                         $confirm_order->update_order_status($NotificationData, $iopn_record_id);
                         header('HTTP/1.1 200 OK');
                     }
                 }
                 if ($NotificationType == 'OrderCancelledNotification') {
                     $cancel_order = new OrderCancelledNotification();
                     $cancel_order->cancel_order($NotificationData, $iopn_record_id);
                     header('HTTP/1.1 200 OK');
                 }
             } else {
                 $param['message'] = 'IOPN Notifications : ' . $NotificationType . ' : IOPN function called and with wrong timestamp.';
                 $obj = new Pwapresta();
                 $obj->generate_log($param);
                 // Respond to the Request
                 header('HTTP/1.1 403 PERMISSION_DENIED');
             }
         } else {
             $param['message'] = 'IOPN Notifications : ' . $NotificationType . ' : IOPN function called and with wrong signature.';
             $obj = new Pwapresta();
             $obj->generate_log($param);
             // Respond to the Request
             header('HTTP/1.1 403 PERMISSION_DENIED');
         }
     } catch (Exception $e) {
         $param['message'] = 'IOPN Notifications : Caught exception : ' . $e->getMessage() . '.';
         $obj = new Pwapresta();
         $obj->generate_log($param);
     }
 }
echo "<b>--------------------- Initialization ------------------------</b><br/>\n";
echo "Initialized program with arguments:<br/>\n";
echo "Merchant ID: " . $merchantID . "</br>\n";
echo "Access Key ID: " . $accessKeyID . "</br>\n";
echo "Secret Key ID: " . $secretKeyID . "</br>\n";
/////////////////////////////////////////////////////////
// HTML cart demo
// Create the cart and the signature
/////////////////////////////////////////////////////////
$cartFactory = new MerchantHTMLCartFactory();
$calculator = new SignatureCalculator();
$cart = $cartFactory->getSignatureInput($merchantID, $accessKeyID);
$signature = $calculator->calculateRFC2104HMAC($cart, $secretKeyID);
$cartHtml = $cartFactory->getCartHTML($merchantID, $accessKeyID, $signature);
echo "<b>--------------------- HTML Cart Example ---------------------</b><br/>\n";
echo "1a. Merchant signature input: <pre>" . htmlspecialchars($cart, ENT_QUOTES) . "</pre>\n";
echo "1b. Generated signature: <pre>" . $signature . "</pre>\n";
echo "1c. Generated cart html:<br/> <pre>" . htmlspecialchars($cartHtml, ENT_QUOTES) . "</pre>\n";
/////////////////////////////////////////////////////////
// XML cart demo
// Create the cart and the signature
/////////////////////////////////////////////////////////
$cartFactory = new XMLCartFactory();
$calculator = new SignatureCalculator();
$cart = $cartFactory->getSignatureInput($merchantID, $accessKeyID);
$signature = $calculator->calculateRFC2104HMAC($cart, $secretKeyID);
$cartHtml = $cartFactory->getCartHTML($merchantID, $accessKeyID, $signature);
echo "<b>--------------------- XML Cart Example ---------------------</b><br/>\n";
echo "1a. Merchant signature input: <pre>" . htmlspecialchars($cart, ENT_QUOTES) . "</pre>\n";
echo "1b. Generated signature: <pre>" . $signature . "</pre>\n";
echo "1c. Generated cart html:<br/> <pre>" . htmlspecialchars($cartHtml, ENT_QUOTES) . "</pre>\n";