コード例 #1
0
 function get_request_url($order_id)
 {
     $user = learn_press_get_current_user();
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $order = LP_Order::instance($order_id);
     $custom = array('order_id' => $order_id, 'order_key' => $order->order_key);
     $query = array('cmd' => '_xclick', 'amount' => learn_press_get_cart_total(), 'quantity' => '1', 'business' => $this->paypal_email, 'item_name' => learn_press_get_cart_description(), 'return' => add_query_arg(array('learn-press-transaction-method' => 'paypal-standard', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url()), 'currency_code' => learn_press_get_currency(), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal-standard') . '=1', 'no_note' => '1', 'shipping' => '0', 'email' => $user->user_email, 'rm' => '2', 'cancel_return' => learn_press_get_cart_course_url(), 'custom' => json_encode($custom), 'no_shipping' => '1');
     $query = apply_filters('learn_press_paypal_standard_query', $query);
     $paypal_payment_url = $this->paypal_url . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
コード例 #2
0
 function get_paypal_basic_request_url($order)
 {
     $settings = get_option('_lpr_settings_payment');
     if (empty($settings['paypal'])) {
         return;
     }
     $paypal_settings = $settings['paypal'];
     $user = learn_press_get_current_user();
     $paypal_args = array('cmd' => '_xclick', 'amount' => learn_press_get_cart_total(), 'quantity' => '1');
     $transaction = learn_press_generate_transaction_object();
     $temp_id = learn_press_uniqid();
     $xxx = @file_get_contents(LPR_PLUGIN_PATH . '/temp.txt');
     learn_press_set_transient_transaction('lpps', $temp_id, $user->ID, $transaction);
     file_put_contents(LPR_PLUGIN_PATH . '/temp.txt', $xxx . "=" . $temp_id);
     /*$order_id = LearnPress()->session->get( 'learn_press_user_order' );
     
             $order_id = learn_press_add_transaction(
                 array(
                     'method'        => $this->method,
                     'method_id'     => '',
                     'status'        => '',
                     'user_id'       => null,
                     'order_id'      => $order_id,
                     'parent'        => 0,
                     'transaction_object' => $transaction
                 )
             );
     
             //LearnPress()->session->set( 'learn_press_user_order', $order_id );
     
             $order = new LPR_Order( $order_id );*/
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $paypal_email = $paypal_settings['sandbox'] ? $paypal_settings['paypal_sandbox_email'] : $paypal_settings['paypal_email'];
     $query = array('business' => $paypal_email, 'item_name' => learn_press_get_cart_description(), 'return' => add_query_arg(array('learn-press-transaction-method' => 'paypal-standard', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url()), 'currency_code' => learn_press_get_currency(), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal-standard') . '=1', 'no_note' => '1', 'shipping' => '0', 'email' => $user->user_email, 'rm' => '2', 'cancel_return' => learn_press_get_cart_course_url(), 'custom' => $temp_id, 'no_shipping' => '1');
     $query = array_merge($paypal_args, $query);
     $query = apply_filters('it_exchange_paypal_standard_query', $query);
     $paypal_payment_url = ($paypal_settings['sandbox'] ? $this->paypal_payment_sandbox_url : $this->paypal_payment_live_url) . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
コード例 #3
0
 function get_request_url($order_id)
 {
     $user = learn_press_get_current_user();
     $sandbox = LP()->settings->get('paypal_sandbox') == 'yes';
     $payment_form = '';
     $paypal_api_url = $sandbox ? $this->paypal_nvp_api_sandbox_url : $this->paypal_nvp_api_live_url;
     // PAYPAL_NVP_API_SANDBOX_URL : PAYPAL_NVP_API_LIVE_URL;
     $paypal_payment_url = $sandbox ? $this->paypal_payment_sandbox_url : $this->paypal_payment_sandbox_url;
     //'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
     $paypal_email = $sandbox ? LP()->settings->get('paypal_sandbox_email') : LP()->settings->get('paypal_email');
     $paypal_api_username = $sandbox ? LP()->settings->get('paypal_sandbox_api_username') : LP()->settings->get('paypal_api_username');
     $paypal_api_password = $sandbox ? LP()->settings->get('paypal_sandbox_api_password') : LP()->settings->get('paypal_api_password');
     $paypal_api_signature = $sandbox ? LP()->settings->get('paypal_sandbox_api_signature') : LP()->settings->get('paypal_api_signature');
     if (!empty($paypal_email) && !empty($paypal_api_username) && !empty($paypal_api_password) && !empty($paypal_api_signature)) {
         remove_filter('the_title', 'wptexturize');
         // remove this because it screws up the product titles in PayPal
         $temp_id = learn_press_uniqid();
         $button_request = array('USER' => trim($paypal_api_username), 'PWD' => trim($paypal_api_password), 'SIGNATURE' => trim($paypal_api_signature), 'VERSION' => '96.0', 'METHOD' => 'BMCreateButton', 'BUTTONCODE' => 'ENCRYPTED', 'BUTTONIMAGE' => 'REG', 'BUYNOWTEXT' => 'PAYNOW');
         $button_request['BUTTONTYPE'] = 'BUYNOW';
         //$L_BUTTONVARS[]               = 'amount=' . learn_press_get_cart_total();
         //$L_BUTTONVARS[]               = 'quantity=1';
         $nonce = wp_create_nonce('learn-press-paypal-nonce');
         $L_BUTTONVARS[] = 'business=' . $paypal_email;
         //$L_BUTTONVARS[] = 'item_name=' . learn_press_get_cart_description();
         $L_BUTTONVARS[] = 'return=' . add_query_arg(array('learn-press-transaction-method' => 'paypal-standard-secure', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url());
         $L_BUTTONVARS[] = 'currency_code=' . learn_press_get_currency();
         //$general_settings['default-currency'];
         $L_BUTTONVARS[] = 'notify_url=' . learn_press_get_web_hook('paypal-standard-secure');
         //http://lessbugs.com/paypal/paypal_ipn.php';// . get_site_url() . '/?paypal-stardard-secure=1' ;
         $L_BUTTONVARS[] = 'no_note=1';
         $L_BUTTONVARS[] = 'shipping=0';
         $L_BUTTONVARS[] = 'email=' . $user->user_email;
         $L_BUTTONVARS[] = 'rm=2';
         //Return  Method - https://developer.paypal.com/webapps/developer/docs/classic/button-manager/integration-guide/ButtonManagerHTMLVariables/
         $L_BUTTONVARS[] = 'cancel_return=' . learn_press_get_cart_course_url();
         $L_BUTTONVARS[] = 'custom=' . $temp_id;
         $L_BUTTONVARS[] = 'no_shipping=1';
         foreach ($this->get_item_lines() as $k => $v) {
             $L_BUTTONVARS[] = "{$k}={$v}";
         }
         $L_BUTTONVARS = apply_filters('learn_press_paypal_standard_secure_button_vars', $L_BUTTONVARS);
         $count = 0;
         foreach ($L_BUTTONVARS as $L_BUTTONVAR) {
             $button_request['L_BUTTONVAR' . $count] = $L_BUTTONVAR;
             $count++;
         }
         //print_r($button_request);die();
         $button_request = apply_filters('learn_press_paypal_standard_secure_button_request', $button_request);
         $response = wp_remote_post($paypal_api_url, array('body' => $button_request));
         if (!is_wp_error($response)) {
             parse_str(wp_remote_retrieve_body($response), $response_array);
             if (!empty($response_array['ACK']) && 'Success' === $response_array['ACK']) {
                 if (!empty($response_array['WEBSITECODE'])) {
                     $payment_form = str_replace(array("\r\n", "\r", "\n"), '', stripslashes($response_array['WEBSITECODE']));
                 }
             }
         } else {
             print_r($response);
         }
         if (preg_match('/-----BEGIN PKCS7-----.*-----END PKCS7-----/i', $payment_form, $matches)) {
             $query = array('cmd' => '_s-xclick', 'encrypted' => $matches[0]);
             $paypal_payment_url = $paypal_payment_url . '?' . http_build_query($query);
             return $paypal_payment_url;
         } else {
             echo $payment_form;
         }
     }
     return false;
 }
コード例 #4
0
 function get_paypal_args($order)
 {
     $this->prepare_line_items();
     $user = learn_press_get_current_user();
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $custom = array('order_id' => $order->id, 'order_key' => $order->order_key);
     $args = array_merge(array('cmd' => '_cart', 'business' => $this->paypal_email, 'no_note' => 1, 'currency_code' => learn_press_get_currency(), 'charset' => 'utf-8', 'rm' => is_ssl() ? 2 : 1, 'upload' => 1, 'return' => esc_url($this->get_return_url($order)), 'cancel_return' => esc_url(learn_press_is_enable_cart() ? learn_press_get_page_link('cart') : get_site_url()), 'bn' => 'LearnPress_Cart', 'custom' => json_encode($custom), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal') . '=1', 'email' => $user->user_email), $this->get_item_lines());
     //print_r($args);die();
     return apply_filters('learn_press_paypal_args', $args);
 }