public function paymentAction() { $request = $this->getRequest(); if ($request->isPost()) { $subscriptionsession = new Container('subscriptionsession'); $session = new Container('frontend'); $bookingModel = new Bookings(); $trans = new Transactions(); $model = new Practitioners(); $common = new Common(); $consumer = new Consumers(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($request->getPost('usesavedcard') !== '1') { $data['name'] = $request->getPost('name_on_card'); $data['email'] = $request->getPost('emailid'); $card_type = $request->getPost('card_type'); $data['card_no'] = $request->getPost('card_no'); $data['month'] = $request->getPost('month'); $data['year'] = $request->getPost('year'); $data['cvv_no'] = $request->getPost('cvv_no'); $data['amount'] = $subscriptionsession->serviceprice; $data['rememberme'] = $request->getPost('rememberme'); $data['use_for_renew'] = $request->getPost('use_for_renew'); $data['currency'] = $subscriptionsession->currency; $result = $trans->processPayment($this->getServiceLocator()->get('Config'), $data); } else { $savedCard_details = $common->getUserCardDetails($api_url, array('user_id' => $session->userid)); $cardDetails = end($savedCard_details); /* get saved card details : statr */ $details = $trans->getcarddetails($this->getServiceLocator()->get('Config'), $cardDetails['creditCardDetails_token']); if (is_object($details) && isset($details->last4) && isset($details->cardType)) { $data['card_no'] = $details->last4; if ($details->cardType == "Visa") { $card_type = 1; } else { if ($details->cardType == "MasterCard") { $card_type = 2; } else { if ($details->cardType == "American Express") { $card_type = 3; } } } } /* get saved card details : statr */ $data['customerDetails_id'] = $cardDetails['customerDetails_id']; $data['paymentMethodToken'] = $cardDetails['creditCardDetails_token']; $data['amount'] = $subscriptionsession->serviceprice; $data['currency'] = $subscriptionsession->currency; $result = $trans->processPayment($this->getServiceLocator()->get('Config'), $data, '1'); } if ($result['status'] == 1) { // save user card details if ($data['rememberme'] == 1 || $data['use_for_renew'] == "1") { $usersCardDetails = array(); $usersCardDetails['user_id'] = $session->userid; $usersCardDetails['creditCardDetails_token'] = $result['creditCardDetails_token']; $usersCardDetails['customerDetails_id'] = $result['customerDetails_id']; $usersCardDetails['use_for_renew'] = $data['use_for_renew'] == 1 || $data['use_for_renew'] == "1" ? 1 : 0; $usersCardDetails['card_expiration_hash'] = md5($data['month'] . '-' . $data['year']); //$response = $bookingModel->addUsersCardDetails($api_url, $usersCardDetails); $response = $trans->updateCard($this->getServiceLocator()->get('Config'), $usersCardDetails); } $subscriptionData = array(); $subscriptionData['subscription_duration_id'] = $subscriptionsession->subscription_duration_id; $subscriptionData['payment_status_id'] = 7; $subscriptionData['site_commision'] = "0"; $subscriptionData['status_id'] = 1; $subscriptionData['user_id'] = $session->userid; $subscriptionData['invoice_total'] = str_replace(array('USD$', 'CAD$', '$'), array('', '', ''), $subscriptionsession->serviceprice); $subscriptionData['created_by'] = $session->userid; $subscriptionData['invoice_status'] = 1; $subscriptionData['amount'] = str_replace(array('USD$', 'CAD$', '$'), array('', '', ''), $subscriptionsession->serviceprice); $subscriptionData['currency'] = $subscriptionsession->currency; $subscriptionData['payment_date'] = date('Y-m-d H:i:s'); $subscriptionData['amount_paid'] = $subscriptionsession->serviceprice; $subscriptionData['transaction_id'] = $result['transaction_id']; $subscriptionData['payment_instrument_no'] = strlen($data['card_no']) > 4 ? substr($data['card_no'], strlen($data['card_no']) - 4, 4) : $data['card_no']; $subscriptionData['payment_method_id'] = $card_type; $subscriptionData['payment_status'] = 7; $subscriptionData['subscription_start_date'] = date('Y-m-d'); $subscriptionData['sale_type'] = 1; /* 1 for subscription */ $subscriptionData['subscription_end_date'] = $subscriptionsession->subscription_end_date; //$subscriptionData['user_card_id'] = $result['user_card_id']; $response = $bookingModel->addBooking($api_url, $subscriptionData); if ($response['status'] == 1 && isset($response['id'])) { /* Send email code starts here */ $common = new Common(); if ($template = $common->emailTemplate($api_url, 11)) { //$sp_details = $model->getSPDetails($api_url, $bookingsession->sp_id); //$user_details = $consumer->getConsumerdetails($api_url, $session->userid); $user_details = $model->getSPDetails($api_url, $session->userid); $user_details['address'] = json_decode($user_details['address'][0], true); $user_details['contact'] = json_decode($user_details['contact'][0], true); $data = $bookingModel->getBookings($api_url, '', '', '', '', '', '', $response['id'], 'subscription'); $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $user_details)); $view->setTemplate('application/membership/printinvoice.phtml'); $printData = $this->getServiceLocator()->get('viewrenderer')->render($view); // Store in PDF format $dompdf = new \DOMPDF(); $dompdf->load_html($printData); $dompdf->render(); $output = $dompdf->output(); $attachment = new MimePart($output); $attachment->type = 'application/pdf'; $attachment->filename = 'invoice.pdf'; $attachment->encoding = \Zend\Mime\Mime::ENCODING_BASE64; $attachment->disposition = \Zend\Mime\Mime::DISPOSITION_ATTACHMENT; $mail = new Message(); $transport = new \Zend\Mail\Transport\Sendmail(); $html = new MimePart(preg_replace('/{{user_name}}/i', '<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>', $template['content'])); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html, $attachment)); $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($user_details['email'], '')->setSubject($template['subject']); $transport->send($mail); /* Send email code ends here */ } // unset all sessions $subscriptionsession->offsetUnset('currency'); $subscriptionsession->offsetUnset('serviceprice'); $subscriptionsession->offsetUnset('subscription_duration_id'); $subscriptionsession->offsetUnset('subscription_end_date'); echo json_encode(array('status' => '1', 'msg' => 'Subscription updated successfully. <br /> Redirecting to invoice page..!!', 'subscription_id' => $response['id'])); } else { echo json_encode(array('status' => '0', 'msg' => 'Transaction completed successfully with Transaction Id <strong>' . $result['transaction_id'] . '</strong>. <br /> Failed to complete your request. Please contact to site admin..!!', 'errors' => $response['data'])); } } else { echo json_encode($result); } } exit; }
public function savepdfbusinesscardAction() { $api = new Api(); $model = new Practitioners(); $common = new Common(); $request = $this->getRequest(); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $imgname = $request->getQuery('imgurl') == 'verso' ? 'verso' : 'recto'; $url = './public'; $logo = $url . '/img/business-logo.png'; $profileurl = $this->getServiceLocator()->get('config')['basepath']['url'] . 'practitioner/view/' . $user_details['id']; $user_details = $model->getSPDetails($api_url, $session->userid); $address = $cellphone = 'Not Available'; // getting address if (isset($user_details['work_address']) && is_array($user_details['work_address']) && count($user_details['work_address']) > 0) { $mainAddress = json_decode($user_details['work_address'][0], true); $address = $mainAddress['city'] . ', ' . $mainAddress['state_name']; } // getting contact details if (isset($user_details['contact']) && is_array($user_details['contact']) && count($user_details['contact']) > 0) { $contactDetails = json_decode($user_details['contact'][0], true); $cellphone = $contactDetails['cellphone']; } $services_count = $this->getservicesdata($session->userid, $api, $api_url); // get all services list $parentService = isset($services_count['results'][0]['category_id']) ? $model->getParentService($api_url, $services_count['results'][0]['category_id']) : 'Not Available'; $bussCategoryName = $parentService ? $parentService['category_name'] : 'Not Avaialable'; //$bussCategoryName = isset($services_count['results'][0]['parent_category'])?$services_count['results'][0]['parent_category']:'Not Available'; $back_ground = $imgname == 'recto' ? '' : 'background: url(' . $url . '/img/bg_verso.jpg) no-repeat scroll center center transparent;'; $patterns = array('/{{id}}/i', '/{{card_logo}}/i', '/{{main_category}}/i', '/{{user_name}}/i', '/{{url}}/i', '/{{cellphone}}/i', '/{{address}}/i', '/{{profile_url}}/i', '/{{back_ground}}/i'); $replacements = array($session->userid, $logo, $bussCategoryName, $user_details['first_name'] . ' ' . $user_details['last_name'], $url, $cellphone, $address, $profileurl, $back_ground); $template = $imgname == 'recto' ? $common->emailTemplate($api_url, 25) : $common->emailTemplate($api_url, 24); $newtemp = preg_replace($patterns, $replacements, stripslashes($template['content'])); // Store in PDF format $dompdf = new \DOMPDF(); $dompdf->load_html($newtemp); $dompdf->render(); //$dompdf->Output('businesscard.pdf'); $dompdf->stream('businesscard.pdf', array('Attachment' => 0)); die; }
public function sendmailAction() { $sendcode = rand(); $session = new Container('frontend'); $api = new Api(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $model = new Practitioners(); $common = new Common(); if ($session->email == $this->getRequest()->getPost('email')) { if ($template = $common->emailTemplate($api_url, 8)) { $mail = new Message(); $transport = new \Zend\Mail\Transport\Sendmail(); $html = new MimePart(preg_replace('/{{code}}/i', '<strong>' . $sendcode . '</strong>', $template['content'])); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($session->email, '')->setSubject($template['subject']); try { $verify_session = new Container('verify'); $transport->send($mail); $api = new Api(); $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $data = array('user_id' => $session->userid, 'verification_type_id' => $verify_session->type, 'verification_code' => $sendcode, 'created_date' => date('Y-m-d H:i:s')); $getvalue = $this->checkuserexistence(); if (count($getvalue) > 0) { // verification code time out if ($getvalue['timeverification'] == false) { $url = $api_url . "/api/userverification/" . $getvalue['id'] . "/"; $type = "PUT"; } } else { // new user $url = $api_url . "/api/userverification/"; $type = "POST"; } $res = $api->curl($url, $data, $type); //$msg = ($res->getStatusCode()==201)? ('Your verified code was sent to your email'):('Error in create verified code'); //$error = ($res->getStatusCode()==201)? false: true; $msg = 'Your verification code was sent to your email'; $error = false; } catch (Exception $e) { $error = true; $msg = 'Unable to send email'; } } else { $error = true; $msg = 'Unable to find mail template..!!'; } } else { $error = true; $msg = 'Sorry this is not registered email id'; } echo json_encode(array('msg' => $msg, 'error' => $error)); exit; }
public function indexAction() { $api_url = $this->getServiceLocator()->get('Config')['api_url']['value']; $api = new Api(); $auth = new FrontEndAuth(); $error = ""; $redirectUrl = array('controller' => 'index'); if ($auth->hasIdentity()) { return $this->redirect()->toRoute(null, $redirectUrl); } $form = new ForgetPasswordForm(); $request = $this->getRequest(); if ($request->isPost()) { $model = new ForgetPassword(); $form->setInputFilter($model->getInputFilter()); $data = $request->getPost()->toArray(); $form->setData($data); if ($form->isValid()) { unset($data['submit']); $random_password = $model->generateRandomPassword(); $data['password'] = $random_password; $session = new Container('frontend'); $url = $api_url . "/api/useractivity/"; $data['op'] = 'forgotpassword'; $res = $api->curl($url, $data, "POST"); //var_dump($res); die; if ($res->getStatusCode() == 200) { $model = new Common(); if ($template = $model->emailTemplate($api_url, 3)) { $content = json_decode($res->getBody(), true); // '{{user_first_name}}', '{{username}}', '{{password}}' //$content['first_name'], $content['user_name'], $random_password), $template['content']); $patterns = array('/{{user_first_name}}/i', '/{{username}}/i', '/{{password}}/i'); $replacements = array($content['first_name'], '<strong>' . $content['user_name'] . '</strong>', '<strong>' . $random_password . '</strong>', '<strong>' . $getservices . '</strong>'); $mail = new Message(); $transport = new \Zend\Mail\Transport\Sendmail(); $html = new MimePart(preg_replace($patterns, $replacements, $template['content'])); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $url = $api_url . "/api/useractivity/"; $data = array('email' => $content['email'], 'password' => $random_password); $data['op'] = 'resetpassword'; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 200) { $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($content['email'], '')->setSubject($template['subject']); $transport->send($mail); $error = false; $msg = "A mail has been send to " . $content['email'] . " ,Please check "; } else { $error = true; $msg = "Unable to set password..!! "; } // echo json_encode(array('status' => 1, 'msg' => 'Business card sent to the email address..!!')); } else { $error = true; $msg = "Unable to find mail template..!!"; //echo json_encode(array('status' => 0, 'msg' => 'Unable to find mail template..!!')); } /* $content = json_decode($res->getBody(), true); $forget_pass_url = $api_url."/api/emailtemplate/3/"; $forget_pass_res = $api->curl($forget_pass_url, array(), "GET"); //print_r($forget_pass_res); die; if($forget_pass_res->getStatusCode() == 200) { $template = json_decode($forget_pass_res->getBody(), true); $template_data = str_replace(array('{{user_first_name}}', '{{username}}', '{{password}}' ), array($content['first_name'], $content['user_name'], $random_password), $template['content']); $wp_user_detail = $auth->wordpress_user_detail($content['user_name']); $auth->wordpress_set_password($random_password, $wp_user_detail->ID); $reset_data['op'] = 'resetpassword'; $reset_data['email'] = $content['email']; $reset_data['password'] = $random_password; $reset_res = $api->curl($url, $reset_data, "POST"); $mail = new \Zend\Mail\Message(); $html = new \Zend\Mime\Part($template_data); $html->type = "text/html"; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); //$content['email'] $mail->setBody($body) ->setFrom($template['fromEmail'], 'Ovessence') ->addTo('*****@*****.**', $content['first_name'].' '.$content['last_name']) ->setSubject($template['subject']); $transport = new \Zend\Mail\Transport\Sendmail($template['fromEmail']); $transport->send($mail); $error = "A mail has been send to ". $content['email'] ." ,Please check "; }*/ } else { if ($res->getStatusCode() == "404") { $error = true; $msg = "User with given email does not exist"; } else { $error = true; $msg = $res->getReasonPhrase(); } } } } $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg)); $view->setTemplate('application/forgetPassword/index.phtml'); return $view; }