Exemplo n.º 1
0
 function testSet()
 {
     if ($this->paypal_username) {
         $pp = new PaypalSeed($this->cash_user_id, $this->paypal_connection_id);
         $redirect_url = $pp->setExpressCheckout('13.26', 'order_sku', 'this is the best order ever', 'http://localhost', 'http://localhost');
         $this->assertTrue($redirect_url);
         //$redirect = CASHSystem::redirectToUrl($redirect_url);
         //echo $redirect;
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }