Пример #1
0
 function get_authorize_url($order_id = false)
 {
     //Check cart is not empty
     if (STCart::check_cart() and STCart::get_total()) {
         $gateway = Omnipay::create('PayPal_Express');
         $gateway->setUsername(st()->get_option('paypal_api_username'));
         $gateway->setPassword(st()->get_option('paypal_api_password'));
         $gateway->setSignature(st()->get_option('paypal_api_signature'));
         if (st()->get_option('paypal_enable_sandbox', 'on') == 'on') {
             $gateway->setTestMode(true);
         }
         $amount = TravelHelper::convert_money(STCart::get_total());
         $order_token_code = get_post_meta($order_id, 'order_token_code', true);
         if (!$order_token_code) {
             $array = array('gateway_name' => 'st_paypal', 'order_code' => $order_id, 'status' => 'success');
             $array_error = array('gateway_name' => 'st_paypal', 'order_code' => $order_id, 'status' => 'error');
         } else {
             $array = array('gateway_name' => 'st_paypal', 'order_token_code' => $order_token_code, 'status' => 'success');
             $array_error = array('gateway_name' => 'st_paypal', 'order_token_code' => $order_token_code, 'status' => 'error');
         }
         $purchase = array('amount' => (double) STCart::get_total(), 'currency' => TravelHelper::get_current_currency('name'), 'description' => __('Traveler Booking', ST_TEXTDOMAIN), 'returnUrl' => add_query_arg($array, STCart::get_success_link()), 'cancelUrl' => add_query_arg($array_error, STCart::get_success_link()), 'items' => $this->get_line_items($order_id), 'taxAmount' => STCart::get_tax_amount());
         //                var_dump($purchase);
         $response = $gateway->purchase($purchase)->send();
         //                var_dump($purchase);
         if ($response->isSuccessful()) {
             // payment is complete
             return array('status' => true);
         } elseif ($response->isRedirect()) {
             //$response->redirect(); // this will automatically forward the customer
             return array('status' => false, 'redirect_url' => $response->getRedirectUrl(), '');
             //                    return ;
         } else {
             // not successful
             return array('status' => false, 'message' => $response->getMessage(), 'data' => $purchase);
         }
     } else {
         return array('status' => false, 'message' => __('Your cart is currently empty', ST_TEXTDOMAIN));
     }
 }
Пример #2
0
    ?>
" type="text"
                                           class="form-control" name="coupon_code">
                                </div>
                                <button class="btn btn-primary"
                                        type="submit"><?php 
    _e('Apply Coupon', ST_TEXTDOMAIN);
    ?>
</button>
                            </form>
                        </div>
                        <div class="booking-item-payment-total text-right">
                            <?php 
    /*if(st()->get_option('tax_enable','off')=='on'):*/
    $tax = st()->get_option('tax_value', 0);
    $tax_money = STCart::get_tax_amount();
    $total_without_tax = STCart::get_total_with_out_tax();
    if (STCart::is_tax_included_listing_page()) {
        $tax_money = $total_without_tax / 100 * STCart::get_tax(true);
        $total_without_tax -= $tax_money;
    }
    ?>
                            <table border="0" class="table_checkout">
                                <tr>
                                    <td class="text-left title"><?php 
    st_the_language('sub_total:');
    ?>
 </td>
                                    <td class="text-right "><?php 
    echo TravelHelper::format_money($total_without_tax);
    ?>