/** * Method for opting into the email service provider. * * @since 2.1.0 * * @param array $account The API account information * @param int $list_id The currently selected list ID * @param array $lead The lead info * * @return bool|object */ public function optin($account = array(), $list_id, $lead) { // Instantiate the Subscriber API $this->subscriber_api = new ML_Subscribers($account['api-key']); // Create the initial data array $data = array('email' => $lead['lead_email'], 'resubscribe' => 1); // Setup name if set if (isset($lead['lead_name']) && 'false' != $lead['lead_name']) { $names = explode(' ', $lead['lead_name']); if (isset($names[0])) { $data['name'] = $names[0]; } if (isset($names[1])) { $data['last_name'] = $names[1]; } } $data = apply_filters('optin_monster_pre_optin_mailerlite', $data, $lead, $list_id, $this->subscriber_api); // Save resubscribe value as it's own variable $resubscribe = $data['resubscribe']; unset($data['resubscribe']); // Now send the subscriber data to MailerLite try { $subscriber = $this->subscriber_api->setId($list_id)->add($data, $resubscribe); $response_info = $this->subscriber_api->getResponseInfo(); } catch (Exception $e) { return $this->error('list-error', __('There was an error saving your details.', 'optin-monster')); } // Return an error if something went wrong while sending the request if (200 != $response_info['http_code']) { return $this->error('list-error', __('There was an issue connecting to the MailerLite API. Please try again.', 'optin-monster')); } return true; }
public function payAction() { // See your keys here https://dashboard.stripe.com/account/apikeys $stripeSecretKey = $this->di->get('config')['stripe']['secret']; \Stripe\Stripe::setApiKey($stripeSecretKey); // stored on setup.php // Get the credit card details submitted by the form $token = $_POST['stripeToken']; $amount = $_POST['amount']; $email = $_POST['email']; // Create the charge on Stripe's servers - this will charge the user's card try { $charge = \Stripe\Charge::create(array("amount" => $amount, "currency" => "usd", "source" => $token, "description" => "Example charge")); } catch (\Stripe\Error\Card $e) { // The card has been declined die("Sorry, your card was declined. Please go back and try again."); } // get the path to the www folder $wwwroot = $this->di->get('path')['root']; // get the key from the config $mailerLiteKey = $this->di->get('config')['mailerlite']['key']; // adding the new Donor to the list include_once "{$wwwroot}/lib/mailerlite-api-php-v1/ML_Subscribers.php"; $ML_Subscribers = new ML_Subscribers($mailerLiteKey); $subscriber = array('email' => $email); $result = $ML_Subscribers->setId("2225307")->add($subscriber); // adding to Donors list // send email with the donor's info $dollarsAmount = $amount / 100; $today = date('l jS \\of F Y h:i:s A'); $message = "Date: {$today}<br/>Donor: {$email}<br/>Amount: {$dollarsAmount}"; $emailObj = new Email(); $emailObj->sendEmail("*****@*****.**", "Apretaste: New donation", $message); // Send to the ThankYou page return $this->response->redirect("welcome/thankyou&email={$email}&amount={$dollarsAmount}"); }
/** * Delete a subscriber from the email list in Mail Lite * * @author salvipascual * @param String email * */ public function unsubscribeFromEmailList($email) { // get the path to the www folder $di = \Phalcon\DI\FactoryDefault::getDefault(); $wwwroot = $di->get('path')['root']; // get the key from the config $mailerLiteKey = $di->get('config')['mailerlite']['key']; // adding the new subscriber to the list include_once "{$wwwroot}/lib/mailerlite-api-php-v1/ML_Subscribers.php"; $ML_Subscribers = new ML_Subscribers($mailerLiteKey); $ML_Subscribers->setId("1266487")->remove($email); }