public function paypalExpressCheckout() { $form_id = $this->getParameter('form_id'); if ($form_id) { // create a paypal object $paypal = new AB_PayPal(); $userData = new AB_UserBookingData($form_id); $userData->load(); if ($userData->get('service_id')) { $service = $userData->getService(); // get the products information from the $_POST and create the Product objects $product = new stdClass(); $product->name = $service->get('title'); $product->desc = $service->getTitleWithDuration(); $product->price = $userData->getFinalServicePrice(); $product->qty = $userData->get('number_of_persons'); $paypal->addProduct($product); // and send the payment request try { $paypal->send_EC_Request($form_id); } catch (Exception $e) { $userData->setPayPalStatus('error', $this->getParameter('error_msg')); @wp_redirect(remove_query_arg(array('action', 'token', 'PayerID'), AB_Utils::getCurrentPageURL())); exit; } } } }