예제 #1
0
 /**
  * Reads asset details and redirects to the file directly. The success
  * Response is set here rather than in processRequest(), allowing it to
  * exist in the session
  *
  * @param {integer} $id - the asset you are trying to retrieve
  * @return string
  */
 protected function redirectToAsset($id, $element_id = 0)
 {
     if ($this->getUnlockedStatus($id)) {
         $asset = $this->getAssetInfo($id);
         $final_asset_location = $this->getFinalAssetLocation($asset['connection_id'], $asset['user_id'], $asset['location']);
         if ($final_asset_location !== false) {
             $this->pushSuccess(array('asset' => $id), 'redirect executed successfully');
             $this->recordAnalytics($id, $element_id);
             CASHSystem::redirectToUrl($final_asset_location);
             die;
         } else {
             return $this->response->pushResponse(500, $this->request_type, $this->action, $this->request, 'unknown asset type, please as an admin to check the asset type');
         }
     }
 }
예제 #2
0
 protected function initiatePaymentRedirect($order_id, $element_id = false, $price_addition = 0, $url_only = false, $finalize_url = false, $session_id = false)
 {
     $order_details = $this->getOrder($order_id);
     $transaction_details = $this->getTransaction($order_details['transaction_id']);
     $order_totals = $this->getOrderTotals($order_details['order_contents']);
     $connection_type = $this->getConnectionType($transaction_details['connection_id']);
     $currency = $this->getCurrencyForUser($order_details['user_id']);
     if ($finalize_url) {
         $r = new CASHRequest();
         $r->startSession(false, $session_id);
         $r->sessionSet('payment_finalize_url', $finalize_url);
     }
     if ($order_totals['price'] + $price_addition < 0.35) {
         // basically a zero dollar transaction. hard-coding a 35¢ minimum for now
         // we can add a system minimum later, or a per-connection minimum, etc...
         return 'force_success';
     }
     switch ($connection_type) {
         case 'com.paypal':
             $pp = new PaypalSeed($order_details['user_id'], $transaction_details['connection_id']);
             if (!$finalize_url) {
                 $finalize_url = CASHSystem::getCurrentURL();
             }
             $return_url = $finalize_url . '?cash_request_type=commerce&cash_action=finalizepayment&order_id=' . $order_id . '&creation_date=' . $order_details['creation_date'];
             if ($element_id) {
                 $return_url .= '&element_id=' . $element_id;
             }
             $require_shipping = false;
             $allow_note = false;
             if ($order_details['physical']) {
                 $require_shipping = true;
                 $allow_note = true;
             }
             $redirect_url = $pp->setExpressCheckout($order_totals['price'] + $price_addition, 'order-' . $order_id, $order_totals['description'], $return_url, $return_url, $require_shipping, $allow_note, $currency, 'Sale', false, $price_addition);
             if (!$url_only) {
                 $redirect = CASHSystem::redirectToUrl($redirect_url);
                 // the return will only happen if headers have already been sent
                 // if they haven't redirectToUrl() will handle it and call exit
                 return $redirect;
             } else {
                 return $redirect_url;
             }
             break;
         default:
             return false;
     }
     return false;
 }
예제 #3
0
 protected function initiatePaymentRedirect($order_id, $element_id = false)
 {
     $order_details = $this->getOrder($order_id);
     $transaction_details = $this->getTransaction($order_details['transaction_id']);
     $order_totals = $this->getOrderTotals($order_details['order_contents']);
     $connection_type = $this->getConnectionType($transaction_details['connection_id']);
     switch ($connection_type) {
         case 'com.paypal':
             $pp = new PaypalSeed($order_details['user_id'], $transaction_details['connection_id']);
             $return_url = CASHSystem::getCurrentURL() . '?cash_request_type=commerce&cash_action=finalizepayment&order_id=' . $order_id . '&creation_date=' . $order_details['creation_date'];
             if ($element_id) {
                 $return_url .= '&element_id=' . $element_id;
             }
             $redirect_url = $pp->setExpressCheckout($order_totals['price'], 'order-' . $order_id, $order_totals['description'], $return_url, $return_url);
             $redirect = CASHSystem::redirectToUrl($redirect_url);
             // the return will only happen if headers have already been sent
             // if they haven't redirectToUrl() will handle it and call exit
             return $redirect;
             break;
         default:
             return false;
     }
     return $final_redirect;
 }