示例#1
0
 public function set_express_checkout($app, $cart)
 {
     $paypal_data = '';
     $i = $subtotal = $total = 0;
     foreach ($cart['cart_items'] as $row) {
         $price = \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_QTY' . $i . '=' . urlencode($row['quantity']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_AMT' . $i . '=' . urlencode(number_format($price, 2));
         $paypal_data .= '&L_PAYMENTREQUEST_0_NAME' . $i . '=' . urlencode($row['name']);
         $paypal_data .= '&L_PAYMENTREQUEST_0_NUMBER' . $i . '=' . urlencode($row['id']);
         $subtotal = $price * $row['quantity'];
         $total = $total + $subtotal;
         $i += 1;
     }
     $padata = '&PAYMENTREQUEST_0_PAYMENTACTION=Sale' . '&PAYMENTREQUEST_0_CURRENCYCODE=' . urlencode('USD') . '&PAYMENTREQUEST_0_AMT=' . urlencode(number_format($cart['total'], 2)) . '&PAYMENTREQUEST_0_TAXAMT=' . urlencode(number_format($cart['tax'], 2)) . '&PAYMENTREQUEST_0_ITEMAMT=' . urlencode(number_format($total, 2)) . '&ALLOWNOTE=1' . $paypal_data . '&RETURNURL=' . urlencode($app->view()->url_secure('/shop/expresscheckout/return')) . '&CANCELURL=' . urlencode($app->view()->url_secure('/shop/expresscheckout/cancel'));
     $httpParsedResponseAr = $this->pp_http_post('SetExpressCheckout', $padata);
     if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
         $paypalmode = $this->config['paypal.environment'] == 'sandbox' ? '.sandbox' : '';
         //Redirect user to PayPal store with Token received.
         $paypalurl = 'https://www' . $paypalmode . '.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $httpParsedResponseAr["TOKEN"] . '';
         header('Location: ' . $paypalurl);
         exit;
     } else {
         throw new \Exception('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
     }
 }
示例#2
0
 public static function parse_wish_list_items($wish_list_items)
 {
     $subtotal = 0;
     $ids = array();
     foreach ($wish_list_items as $row) {
         $ids[] = $row['id'];
         $price = \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
         $subtotal += $price * $row['quantity'];
     }
     $count = count($wish_list_items);
     $tax = $subtotal * 0.07000000000000001;
     // tax = 7%
     $total = $subtotal + $tax;
     return array('count' => $count, 'subtotal' => $subtotal, 'total' => $total, 'tax' => $tax, 'ids' => implode(',', $ids), 'wish_list_items' => $wish_list_items);
 }
示例#3
0
            echo $this->url('/products/' . $rp['cname'] . '/' . $rp['id']);
            ?>
" class="link tip" title="View Detail"></a>&nbsp;
                </p>
              </article>
            </div>
          </div>
          <h3><a href="<?php 
            echo $this->url('/products/accessories/' . $rp['id']);
            ?>
"><?php 
            echo $rp['name'];
            ?>
</a></h3>
          <span>$<?php 
            echo \Helpers\Util::get_just_price($rp['price'], $rp['sale_price']);
            ?>
</span>
        </div>
      <?php 
        }
        ?>
    </div>
  <?php 
    }
    ?>

  <div style="clear:both; display:block; height:40px"></div>
<?php 
} else {
    ?>
        echo $this->url('/products/' . $row['cname'] . '/' . $row['id']);
        ?>
"><?php 
        echo $row['name'];
        ?>
</a></td>
        <td class="quantity"><?php 
        echo $row['quantity'];
        ?>
</td>
        <td class="price">$<?php 
        echo \Helpers\Util::get_just_price($row['price'], $row['sale_price']);
        ?>
</td>
        <td class="total">$<?php 
        echo number_format($row['quantity'] * \Helpers\Util::get_just_price($row['price'], $row['sale_price']), 2);
        ?>
</td>
      </tr>
    <?php 
    }
    ?>
  </table>
    <div class="contentbox">
      <div class="cartoptionbox one-half first">
      <?php 
    if (isset($cart['messages']) && count($cart['messages'])) {
        echo '<table class="alltotal">';
        foreach ($cart['messages'] as $message) {
            echo '<tr><td><span>' . $message . '</span></td></tr>';
        }