コード例 #1
0
ファイル: ECard.php プロジェクト: blacktire/DIY
 public function getData()
 {
     switch ($this->status_uid) {
         case 'people_signup_200' || 'people_verifyaddress_200':
             // successful submit, return messaging and optionally an asset link
             $show_final_message = true;
             if ($this->status_uid == 'people_signup_200' && !$this->options['do_not_verify']) {
                 // if this is a first submit and we're verifying the email, first check to see if it's been verified already
                 $verification_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'checkverification', 'address' => $this->original_response['payload']['address'], 'list_id' => $this->options['email_list_id']));
                 if (!$verification_request->response['payload']) {
                     // not verified, so do not show the final message, and instead give a "you must verify" jam
                     $show_final_message = false;
                     $this->setTemplate('mustverify');
                 }
             }
             if ($show_final_message) {
                 $all_friends = array($this->original_request['friend1'], $this->original_request['friend2'], $this->original_request['friend3']);
                 if (!empty($this->original_request['main_name'])) {
                     $from_name = $this->original_request['main_name'];
                 } else {
                     $from_name = $this->original_request['address'];
                 }
                 if (!empty($this->options['email_html_message'])) {
                     $html_message = str_replace('</body>', '<br /><br /><br /><small>This e-card was sent from <a href="' . CASHSystem::getCurrentURL() . '">' . CASHSystem::getCurrentURL() . '</a></small></body>', $this->options['email_html_message']);
                 } else {
                     $html_message = false;
                 }
                 foreach ($all_friends as $friend) {
                     if (filter_var($friend, FILTER_VALIDATE_EMAIL)) {
                         CASHSystem::sendEmail(trim($this->options['email_subject']) . ' ' . $from_name, CASHSystem::getDefaultEmail(), $friend, $this->options['email_message'] . "\n\n\nThis e-card was sent from " . CASHSystem::getCurrentURL(), '', $html_message);
                     }
                 }
                 if ($this->options['asset_id'] != 0) {
                     // first we "unlock" the asset, telling the platform it's okay to generate a link for non-private assets
                     $unlock_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'unlock', 'id' => $this->options['asset_id']));
                     // next we make the link
                     $asset_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'getasset', 'id' => $this->options['asset_id']));
                     $this->element_data['asset_title'] = $asset_request->response['payload']['title'];
                     $this->element_data['asset_description'] = $asset_request->response['payload']['description'];
                 }
                 $this->setTemplate('success');
             }
             break;
         case 'people_signup_400':
             // error, likely in the email format. error message + default form
             $this->element_data['error_message'] = $this->options['message_invalid_email'];
             break;
     }
     return $this->element_data;
 }
コード例 #2
0
ファイル: CommercePlant.php プロジェクト: jmcclenon/platform
 protected function sendOrderReceipt($id = false, $order_details = false, $finalize_url = false)
 {
     if (!$id && !$order_details) {
         return false;
     }
     if (!$order_details) {
         $order_details = $this->getOrder($id, true);
     }
     $order_totals = $this->getOrderTotals($order_details['order_contents']);
     try {
         $personalized_message = '';
         if ($order_details['element_id']) {
             $element_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getelement', 'id' => $order_details['element_id']));
             if ($element_request->response['payload']) {
                 if (isset($element_request->response['payload']['options']['message_email'])) {
                     if ($element_request->response['payload']['options']['message_email']) {
                         $personalized_message = $element_request->response['payload']['options']['message_email'] . "\n\n";
                     }
                 }
             }
         }
         if ($order_details['digital']) {
             $addcode_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addlockcode', 'element_id' => $order_details['element_id']));
             if (!$finalize_url) {
                 $finalize_url = CASHSystem::getCurrentURL();
             }
             return CASHSystem::sendEmail('Thank you for your order', $order_details['user_id'], $order_details['customer_details']['email_address'], $personalized_message . "Your order is complete. Here are some details:\n\n**Order #" . $order_details['id'] . "**  \n" . $order_totals['description'] . "  \n Total: " . CASHSystem::getCurrencySymbol($order_details['currency']) . number_format($order_details['gross_price'], 2) . "\n\n" . "\n\n" . '[View your receipt and any downloads](' . $finalize_url . '?cash_request_type=element&cash_action=redeemcode&code=' . $addcode_request->response['payload'] . '&element_id=' . $order_details['element_id'] . '&email=' . urlencode($order_details['customer_details']['email_address']) . '&order_id=' . $order_details['id'] . ')', 'Thank you.');
         } else {
             return CASHSystem::sendEmail('Thank you for your order', $order_details['user_id'], $order_details['customer_details']['email_address'], $personalized_message . "Your order is complete. Here are some details:\n\n**Order #" . $order_details['id'] . "**  \n" . $order_totals['description'] . "  \n Total: " . CASHSystem::getCurrencySymbol($order_details['currency']) . number_format($order_details['gross_price'], 2) . "\n\n", 'Thank you.');
         }
     } catch (Exception $e) {
         // TODO: handle the case where an email can't be sent. maybe display the download
         //       code on-screen? that plus storing it with the order is probably enough
         return false;
     }
 }
コード例 #3
0
ファイル: CommercePlant.php プロジェクト: hubub/platform
 protected function finalizeRedirectedPayment($order_id, $creation_date, $direct_post_details = false, $session_id = false)
 {
     $order_details = $this->getOrder($order_id);
     $transaction_details = $this->getTransaction($order_details['transaction_id']);
     $connection_type = $this->getConnectionType($transaction_details['connection_id']);
     $r = new CASHRequest();
     $r->startSession(false, $session_id);
     $finalize_url = $r->sessionGet('payment_finalize_url');
     if ($finalize_url) {
         $r->sessionClear('payment_finalize_url');
     }
     switch ($connection_type) {
         case 'com.paypal':
             if (isset($_GET['token'])) {
                 if (isset($_GET['PayerID'])) {
                     $pp = new PaypalSeed($order_details['user_id'], $transaction_details['connection_id'], $_GET['token']);
                     $initial_details = $pp->getExpressCheckout();
                     if ($initial_details['ACK'] == 'Success') {
                         $order_totals = $this->getOrderTotals($order_details['order_contents']);
                         if ($initial_details['AMT'] >= $order_totals['price']) {
                             $final_details = $pp->doExpressCheckout();
                             if ($final_details) {
                                 // look for a user to match the email. if not present, make one
                                 $user_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getuseridforaddress', 'address' => $initial_details['EMAIL']));
                                 $user_id = $user_request->response['payload'];
                                 if (!$user_id) {
                                     $user_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $initial_details['EMAIL'], 'password' => time(), 'is_admin' => 0, 'display_name' => $initial_details['FIRSTNAME'] . ' ' . $initial_details['LASTNAME'], 'first_name' => $initial_details['FIRSTNAME'], 'last_name' => $initial_details['LASTNAME'], 'address_country' => $initial_details['COUNTRYCODE']));
                                     $user_id = $user_request->response['payload'];
                                 }
                                 // deal with physical quantities
                                 if ($order_details['physical'] == 1) {
                                     $order_items = json_decode($order_details['order_contents'], true);
                                     if (is_array($order_items)) {
                                         foreach ($order_items as $i) {
                                             if ($i['available_units'] > 0 && $i['physical_fulfillment'] == 1) {
                                                 $item = $this->getItem($i['id']);
                                                 if ($i['variant']) {
                                                     $variant_id = 0;
                                                     $variant_qty = 0;
                                                     if ($item['variants']) {
                                                         foreach ($item['variants']['quantities'] as $q) {
                                                             if ($q['key'] == $i['variant']) {
                                                                 $variant_id = $q['id'];
                                                                 $variant_qty = $q['value'];
                                                                 break;
                                                             }
                                                         }
                                                         if ($variant_id) {
                                                             $this->editItemVariant($variant_id, max($variant_qty - $i['qty'], 0), $i['id']);
                                                         }
                                                     }
                                                 } else {
                                                     $available_units = $this->editItem($i['id'], false, false, false, false, false, max($item['available_units'] - $i['qty'], 0));
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 // record all the details
                                 if ($order_details['digital'] == 1 && $order_details['physical'] == 0) {
                                     // if the order is 100% digital just mark it as fulfilled
                                     $is_fulfilled = 1;
                                 } else {
                                     // there's something physical. sorry dude. gotta deal with it still.
                                     $is_fulfilled = 0;
                                 }
                                 $this->editOrder($order_id, $is_fulfilled, 0, false, $initial_details['COUNTRYCODE'], $user_id);
                                 $this->editTransaction($order_details['transaction_id'], strtotime($final_details['TIMESTAMP']), $final_details['CORRELATIONID'], json_encode($initial_details), json_encode($final_details), 1, $final_details['PAYMENTINFO_0_AMT'], $final_details['PAYMENTINFO_0_FEEAMT'], 'complete');
                                 // empty the cart at this point
                                 $this->emptyCart($session_id);
                                 // TODO: add code to order metadata
                                 // bit of a hack, hard-wiring the email bits:
                                 try {
                                     $personalized_message = '';
                                     if ($order_details['element_id']) {
                                         $element_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'getelement', 'id' => $order_details['element_id']));
                                         if ($element_request->response['payload']) {
                                             if (isset($element_request->response['payload']['options']['message_email'])) {
                                                 if ($element_request->response['payload']['options']['message_email']) {
                                                     $personalized_message = $element_request->response['payload']['options']['message_email'] . "\n\n";
                                                 }
                                             }
                                         }
                                     }
                                     if ($order_details['digital']) {
                                         $addcode_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addlockcode', 'element_id' => $order_details['element_id']));
                                         if (!$finalize_url) {
                                             $finalize_url = CASHSystem::getCurrentURL();
                                         }
                                         CASHSystem::sendEmail('Thank you for your order', $order_details['user_id'], $initial_details['EMAIL'], $personalized_message . "Your order is complete. Here are some details:\n\n**Order #" . $order_details['id'] . "**  \n" . $initial_details['PAYMENTREQUEST_0_DESC'] . "  \n Total: " . CASHSystem::getCurrencySymbol($order_details['currency']) . number_format($final_details['PAYMENTINFO_0_AMT'], 2) . "\n\n" . "\n\n" . '[View your receipt and any downloads](' . $finalize_url . '?cash_request_type=element&cash_action=redeemcode&code=' . $addcode_request->response['payload'] . '&element_id=' . $order_details['element_id'] . '&email=' . urlencode($initial_details['EMAIL']) . '&order_id=' . $order_details['id'] . ')', 'Thank you.');
                                     } else {
                                         CASHSystem::sendEmail('Thank you for your order', $order_details['user_id'], $initial_details['EMAIL'], $personalized_message . "Your order is complete. Here are some details:\n\n**Order #" . $order_details['id'] . "**  \n" . $initial_details['PAYMENTREQUEST_0_DESC'] . "  \n Total: " . CASHSystem::getCurrencySymbol($order_details['currency']) . number_format($final_details['PAYMENTINFO_0_AMT'], 2) . "\n\n", 'Thank you.');
                                     }
                                 } catch (Exception $e) {
                                     // TODO: handle the case where an email can't be sent. maybe display the download
                                     //       code on-screen? that plus storing it with the order is probably enough
                                 }
                                 return $order_details['id'];
                             } else {
                                 // make sure this isn't an accidentally refreshed page
                                 if ($initial_details['CHECKOUTSTATUS'] != 'PaymentActionCompleted') {
                                     $initial_details['ERROR_MESSAGE'] = $pp->getErrorMessage();
                                     // there was an error processing the transaction
                                     $this->editOrder($order_id, 0, 1);
                                     $this->editTransaction($order_details['transaction_id'], strtotime($initial_details['TIMESTAMP']), $initial_details['CORRELATIONID'], false, json_encode($initial_details), 0, false, false, 'error processing payment');
                                     return false;
                                 } else {
                                     // this is a successful transaction with the user hitting refresh
                                     // as long as it's within 30 minutes of the original return true, otherwise
                                     // call it false and allow the page to expire
                                     if (time() - strtotime($initial_details['TIMESTAMP']) < 180) {
                                         return true;
                                     } else {
                                         return false;
                                     }
                                 }
                             }
                         } else {
                             // insufficient funds — user changed amount?
                             $this->editOrder($order_id, 0, 1);
                             $this->editTransaction($order_details['transaction_id'], strtotime($initial_details['TIMESTAMP']), $initial_details['CORRELATIONID'], false, json_encode($initial_details), 0, false, false, 'incorrect amount');
                             return false;
                         }
                     } else {
                         // order reporting failure
                         $this->editOrder($order_id, 0, 1);
                         $this->editTransaction($order_details['transaction_id'], strtotime($initial_details['TIMESTAMP']), $initial_details['CORRELATIONID'], false, json_encode($initial_details), 0, false, false, 'payment failed');
                         return false;
                     }
                 } else {
                     // user canceled transaction
                     $this->editOrder($order_id, 0, 1);
                     $this->editTransaction($order_details['transaction_id'], time(), false, false, false, 0, false, false, 'canceled');
                     return false;
                 }
             }
             break;
         default:
             return false;
     }
 }
コード例 #4
0
ファイル: login.php プロジェクト: JamesLinus/platform
            }
        } else {
            AdminHelper::formFailure('Make sure you have agreed to the terms of service.', '/');
        }
    }
    $cash_admin->page_data['ui_title'] = 'Sign up now';
    $cash_admin->setPageContentTemplate('signup');
} else {
    if (substr(trim($_REQUEST['p'], '/'), 0, 13) == 'resetpassword') {
        if (isset($_POST['dopasswordreset'])) {
            if (filter_var($_POST['address'], FILTER_VALIDATE_EMAIL)) {
                $reset_key = $cash_admin->requestAndStore(array('cash_request_type' => 'system', 'cash_action' => 'setresetflag', 'address' => $_POST['address']));
                $reset_key = $reset_key['payload'];
                if ($reset_key) {
                    $reset_message = 'A password reset was requested for this email address. If you didn\'t request the ' . 'reset simply ignore this message and no change will be made. To reset your password ' . 'follow this link: ' . "\n\n" . '[Password reset](' . CASH_ADMIN_URL . '/setpassword?key=' . $reset_key . '&address=' . urlencode($_POST['address']) . ')' . "\n\n" . 'Thank you.';
                    CASHSystem::sendEmail('A password reset has been requested', false, $_POST['address'], $reset_message, 'Reset your password?');
                    AdminHelper::formSuccess('Thanks. Check your inbox for instructions.', '/');
                } else {
                    AdminHelper::formFailure('Please check the address and try again.', '/');
                }
            } else {
                AdminHelper::formFailure('Please check the address and try again.', '/');
            }
        }
        if (isset($_POST['key'])) {
        }
        $cash_admin->page_data['ui_title'] = 'Reset password';
        $cash_admin->setPageContentTemplate('resetpassword');
    } else {
        // this for returning password reset people:
        if (substr(trim($_REQUEST['p'], '/'), 0, 11) == 'setpassword') {
コード例 #5
0
ファイル: PeoplePlant.php プロジェクト: JamesLinus/platform
 /**
  * Adds a user to a list. If no user exists for the email address passed, a
  * new user will be created then added to the list.
  *
  * @param {string} $address -           the email address in question
  * @param {int} $list_id -              the id of the list
  * @param {bool} $verified -            0 for unverified, 1 to skip verification and mark ok
  * @param {string} $initial_comment -   a comment passed with the list signup
  * @param {string} $additional_data -   any extra data (JSON, etc) a dev might pass with signup for later use
  * @param {string} $name -              if the user doesn't exist in the system this will be used as their display name
  * @return bool
  */
 protected function addAddress($address, $list_id, $do_not_verify = false, $initial_comment = '', $additional_data = '', $name = 'Anonymous', $force_verification_url = false, $request_from_service = false, $service_opt_in = true, $extra_querystring = '', $first_name = '', $last_name = '', $additional_data = '')
 {
     if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
         // first check to see if the email is already on the list
         $take_action = false;
         $user_id = $this->getUserIDForAddress($address);
         if ($user_id) {
             $user_info = $this->getAddressListInfo($address, $list_id);
             if (!$user_info) {
                 $take_action = 'addandemail';
             } else {
                 if (!$user_info['verified']) {
                     $take_action = 'onlyemail';
                 }
             }
         } else {
             $take_action = 'addandemail';
         }
         if ($take_action) {
             $initial_comment = strip_tags($initial_comment);
             $name = strip_tags($name);
             //$user_id = $this->getUserIDForAddress($address);
             if (!$user_id) {
                 if ($name = 'Anonymous' && (!empty($first_name) || !empty($last_name))) {
                     $name = trim($first_name . ' ' . $last_name);
                 }
                 $addlogin_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $address, 'password' => md5(rand(23456, 9876541)), 'display_name' => $name, 'first_name' => $first_name, 'last_name' => $last_name));
                 if ($addlogin_request->response['status_code'] == 200) {
                     $user_id = $addlogin_request->response['payload'];
                 } else {
                     return false;
                 }
             }
             if ($user_id) {
                 if ($take_action != 'onlyemail') {
                     $result = $this->db->setData('list_members', array('user_id' => $user_id, 'list_id' => $list_id, 'initial_comment' => $initial_comment, 'additional_data' => $additional_data, 'verified' => 0, 'active' => 1));
                 } else {
                     $result = true;
                 }
                 if ($result && !$request_from_service) {
                     if ($do_not_verify) {
                         $api_connection = $this->getConnectionAPI($list_id);
                         if ($api_connection) {
                             // connection found, api instantiated
                             switch ($api_connection['connection_type']) {
                                 case 'com.mailchimp':
                                     $mc = $api_connection['api'];
                                     // mailchimp found. subscribe user and request opt-in
                                     // error_log(json_encode($mc));
                                     $rc = $mc->listSubscribe($address, array('double_optin' => $service_opt_in));
                                     // error_log(json_encode($rc));
                                     break;
                             }
                         }
                     } else {
                         $list_details = $this->getList($list_id);
                         $verification_code = $this->setAddressVerification($address, $list_id);
                         $verification_url = $force_verification_url;
                         if (!$verification_url) {
                             $verification_url = CASHSystem::getCurrentURL();
                         }
                         $verification_url .= '?cash_request_type=people&cash_action=verifyaddress&address=' . urlencode($address) . '&list_id=' . $list_id . '&verification_code=' . $verification_code . $extra_querystring;
                         CASHSystem::sendEmail('Complete sign-up for: ' . $list_details['name'], $list_details['user_id'], $address, 'You requested to join the ' . $list_details['name'] . ' list. If this message has been sent in error ignore it.' . 'To complete your sign-up: ' . "\n\n [Verify your email address](" . $verification_url . ") \n\nNote to iOS users: you can only download on your computers, then sync to your device. Downloads will not work if on your iPhone or iPad.", 'Please confirm your membership');
                     }
                 }
                 return $result;
             }
         } else {
             // address already present, do nothing but return true
             return true;
         }
     }
     return false;
 }
コード例 #6
0
ファイル: ECard.php プロジェクト: nodots/DIY
 public function getMarkup()
 {
     // define $markup to store all screen output
     $markup = '';
     // the default form and basic elements:
     $default_markup = '<p class="cash_element_intro">' . $this->options->message_instructions . '</p>';
     if (!empty($this->options->image_url)) {
         $default_markup .= '<img src="' . $this->options->image_url . '" alt="E-Card" class="cash_image_ecard" />';
     }
     $default_markup .= '<form id="cash_' . self::type . '_form_' . $this->element_id . '" class="cash_form ' . self::type . '" method="post" action="">' . '<div class="cash_main_name_container"><label for="address">Your Name: (The \'from\' for the card)</label>' . '<input type="text" name="main_name" value="" class="cash_input cash_input_address cash_main_name" /></div>' . '<div class="cash_main_address_container"><label for="address">Your Email:</label>' . '<input type="email" name="address" value="" class="cash_input cash_input_address cash_main_address" /></div>' . '<div class="cash_friends">' . '<label for="address">Email Addresses For Up To 3 Friends:</label>' . '<input type="email" name="friend1" value="" class="cash_input cash_input_address cash_friend_address1" />' . '<input type="email" name="friend2" value="" class="cash_input cash_input_address cash_friend_address2" />' . '<input type="email" name="friend3" value="" class="cash_input cash_input_address cash_friend_address3" />' . '</div>' . '<input type="hidden" name="cash_request_type" value="people" />' . '<input type="hidden" name="cash_action" value="signup" />' . '<input type="hidden" name="list_id" value="' . $this->options->email_list_id . '" class="cash_input cash_input_list_id" />' . '<input type="hidden" name="element_id" value="' . $this->element_id . '" class="cash_input cash_input_element_id" />' . '<input type="hidden" name="comment" value="" class="cash_input cash_input_comment" />' . '<input type="submit" value="send the cards" class="button" /><br />' . '</form>';
     switch ($this->status_uid) {
         case 'people_signup_200' || 'people_verifyaddress_200':
             // successful submit, return messaging and optionally an asset link
             $markup = '<div class="cash_success ' . self::type . '">';
             $show_final_message = true;
             if ($this->status_uid == 'people_signup_200' && !$this->options->do_not_verify) {
                 // if this is a first submit and we're verifying the email, first check to see if it's been verified already
                 $verification_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'checkverification', 'address' => $this->original_response['payload']['address'], 'list_id' => $this->options->email_list_id));
                 if (!$verification_request->response['payload']) {
                     // not verified, so do not show the final message, and instead give a "you must verify" jam
                     $show_final_message = false;
                     $markup .= 'You must verify your email address to continue. An email has been sent. Click the link provided and you will be brought back here.<br /><br />(If you do not see the message, check your SPAM folder.)';
                 }
             }
             if ($show_final_message) {
                 $all_friends = array($this->original_request['friend1'], $this->original_request['friend2'], $this->original_request['friend3']);
                 if (!empty($this->original_request['main_name'])) {
                     $from_name = $this->original_request['main_name'];
                 } else {
                     $from_name = $this->original_request['address'];
                 }
                 if (!empty($this->options->email_html_message)) {
                     $html_message = str_replace('</body>', '<br /><br /><br /><small>This e-card was sent from <a href="' . CASHSystem::getCurrentURL() . '">' . CASHSystem::getCurrentURL() . '</a></small></body>', $this->options->email_html_message);
                 } else {
                     $html_message = false;
                 }
                 foreach ($all_friends as $friend) {
                     if (filter_var($friend, FILTER_VALIDATE_EMAIL)) {
                         CASHSystem::sendEmail(trim($this->options->email_subject) . ' ' . $from_name, CASHSystem::getDefaultEmail(), $friend, $this->options->email_message . "\n\n\nThis e-card was sent from " . CASHSystem::getCurrentURL(), '', $html_message);
                     }
                 }
                 $markup .= $this->options->message_success;
                 if ($this->options->asset_id != 0) {
                     // first we "unlock" the asset, telling the platform it's okay to generate a link for non-private assets
                     $unlock_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'unlock', 'id' => $this->options->asset_id));
                     // next we make the link
                     $asset_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'getasset', 'id' => $this->options->asset_id));
                     $asset_title = $asset_request->response['payload']['title'];
                     $asset_description = $asset_request->response['payload']['description'];
                     $markup .= '<br /><br />' . '<a href="?cash_request_type=asset&cash_action=claim&id=' . $this->options->asset_id . '&element_id=' . $this->element_id . '" class="download">' . $asset_title . '</a>' . '<div class="description">' . $asset_description . '</div>';
                 }
             }
             if (!empty($this->options->image_url)) {
                 $markup .= '<img src="' . $this->options->image_url . '" alt="E-Card" class="cash_image_ecard" />';
             }
             $markup .= '</div>';
             break;
         case 'people_signup_400':
             // error, likely in the email format. error message + default form
             $markup = '<div class="cash_error ' . self::type . '">' . $this->options->message_invalid_email . '</div>' . $default_markup;
             break;
         default:
             // default form
             $markup = $default_markup;
     }
     return $markup;
 }
コード例 #7
0
ファイル: PeoplePlant.php プロジェクト: nodots/DIY
 /**
  * Adds a user to a list. If no user exists for the email address passed, a
  * new user will be created then added to the list.
  *
  * @param {string} $address -           the email address in question
  * @param {int} $list_id -              the id of the list
  * @param {bool} $verified -            0 for unverified, 1 to skip verification and mark ok
  * @param {string} $initial_comment -   a comment passed with the list signup
  * @param {string} $additional_data -   any extra data (JSON, etc) a dev might pass with signup for later use
  * @param {string} $name -              if the user doesn't exist in the system this will be used as their display name
  * @return bool
  */
 protected function addAddress($address, $list_id, $do_not_verify = false, $initial_comment = '', $additional_data = '', $name = 'Anonymous', $force_verification_url = false, $request_from_service = false, $service_opt_in = true)
 {
     if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
         // first check to see if the email is already on the list
         $user_id = $this->getUserIDForAddress($address);
         if (!$this->getAddressListInfo($address, $list_id)) {
             $initial_comment = strip_tags($initial_comment);
             $name = strip_tags($name);
             $user_id = $this->getUserIDForAddress($address);
             if (!$user_id) {
                 $addlogin_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $address, 'password' => rand(23456, 9876541), 'display_name' => $name));
                 if ($addlogin_request->response['status_code'] == 200) {
                     $user_id = $addlogin_request->response['payload'];
                 } else {
                     return false;
                 }
             }
             if ($user_id) {
                 $result = $this->db->setData('list_members', array('user_id' => $user_id, 'list_id' => $list_id, 'initial_comment' => $initial_comment, 'verified' => 0, 'active' => 1));
                 if ($result && !$request_from_service) {
                     if ($do_not_verify) {
                         $api_connection = $this->getConnectionAPI($list_id);
                         if ($api_connection) {
                             // connection found, api instantiated
                             switch ($api_connection['connection_type']) {
                                 case 'com.mailchimp':
                                     $mc = $api_connection['api'];
                                     // mailchimp found. subscribe user and request opt-in
                                     // error_log(json_encode($mc));
                                     $rc = $mc->listSubscribe($address, null, null, $service_opt_in);
                                     // error_log(json_encode($rc));
                                     break;
                             }
                         }
                     } else {
                         $list_details = $this->getList($list_id);
                         $verification_code = $this->setAddressVerification($address, $list_id);
                         $verification_url = $force_verification_url;
                         if (!$verification_url) {
                             $verification_url = CASHSystem::getCurrentURL();
                         }
                         $verification_url .= '?cash_request_type=people&cash_action=verifyaddress&address=' . urlencode($address) . '&list_id=' . $list_id . '&verification_code=' . $verification_code;
                         CASHSystem::sendEmail('Complete sign-up for: ' . $list_details['name'], CASHSystem::getDefaultEmail(), $address, 'You requested to join the ' . $list_details['name'] . ' email list. If this message has been sent in error ignore it.' . 'To complete your sign-up simply visit: ' . "\n\n" . $verification_url, 'Please confirm your membership');
                     }
                 }
                 return $result;
             }
         } else {
             // address already present, do nothing but return true
             return true;
         }
     }
     return false;
 }
コード例 #8
0
ファイル: CommercePlant.php プロジェクト: blacktire/DIY
 protected function finalizeRedirectedPayment($order_id, $creation_date, $direct_post_details = false)
 {
     $order_details = $this->getOrder($order_id);
     $transaction_details = $this->getTransaction($order_details['transaction_id']);
     $connection_type = $this->getConnectionType($transaction_details['connection_id']);
     switch ($connection_type) {
         case 'com.paypal':
             if (isset($_GET['token'])) {
                 if (isset($_GET['PayerID'])) {
                     $pp = new PaypalSeed($order_details['user_id'], $transaction_details['connection_id'], $_GET['token']);
                     $initial_details = $pp->getExpressCheckout();
                     if ($initial_details['ACK'] == 'Success') {
                         $order_totals = $this->getOrderTotals($order_details['order_contents']);
                         if ($initial_details['AMT'] >= $order_totals['price']) {
                             $final_details = $pp->doExpressCheckout();
                             if ($final_details) {
                                 // look for a user to match the email. if not present, make one
                                 $user_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getuseridforaddress', 'address' => $initial_details['EMAIL']));
                                 $user_id = $user_request->response['payload'];
                                 if (!$user_id) {
                                     $user_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $initial_details['EMAIL'], 'password' => time(), 'is_admin' => 0, 'display_name' => $initial_details['FIRSTNAME'] . ' ' . $initial_details['LASTNAME'], 'first_name' => $initial_details['FIRSTNAME'], 'last_name' => $initial_details['LASTNAME'], 'address_country' => $initial_details['COUNTRYCODE']));
                                     $user_id = $user_request->response['payload'];
                                 }
                                 // record the details to the order/transaction where appropriate
                                 $this->editOrder($order_id, 1, 0, false, $initial_details['COUNTRYCODE'], $user_id);
                                 $this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($final_details['TIMESTAMP']), $service_transaction_id = $final_details['CORRELATIONID'], $data_sent = json_encode($initial_details), $data_returned = json_encode($final_details), $successful = 1, $gross_price = $final_details['PAYMENTINFO_0_AMT'], $service_fee = $final_details['PAYMENTINFO_0_FEEAMT'], $status = 'complete');
                                 $addcode_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addlockcode', 'element_id' => $order_details['element_id']));
                                 // bit of a hack, hard-wiring the email bits:
                                 CASHSystem::sendEmail('Your download is ready', CASHSystem::getDefaultEmail(), $initial_details['EMAIL'], 'Your download of "' . $initial_details['L_PAYMENTREQUEST_0_NAME0'] . '" is ready and can be found at: ' . CASHSystem::getCurrentURL() . '?cash_request_type=element&cash_action=redeemcode&code=' . $addcode_request->response['payload'] . '&element_id=' . $order_details['element_id'] . '&email=' . urlencode($initial_details['EMAIL']), 'Thank you');
                                 return true;
                             } else {
                                 // make sure this isn't an accidentally refreshed page
                                 if ($initial_details['CHECKOUTSTATUS'] != 'PaymentActionCompleted') {
                                     $initial_details['ERROR_MESSAGE'] = $pp->getErrorMessage();
                                     // there was an error processing the transaction
                                     $this->editOrder($order_id, 0, 1);
                                     $this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'error processing payment');
                                     return false;
                                 } else {
                                     // this is a successful transaction with the user hitting refresh
                                     // as long as it's within 30 minutes of the original return true, otherwise
                                     // call it false and allow the page to expire
                                     if (time() - strtotime($initial_details['TIMESTAMP']) < 180) {
                                         return true;
                                     } else {
                                         return false;
                                     }
                                 }
                             }
                         } else {
                             // insufficient funds — user changed amount?
                             $this->editOrder($order_id, 0, 1);
                             $this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'incorrect amount');
                             return false;
                         }
                     } else {
                         // order reporting failure
                         $this->editOrder($order_id, 0, 1);
                         $this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'payment failed');
                         return false;
                     }
                 } else {
                     // user canceled transaction
                     $this->editOrder($order_id, 0, 1);
                     $this->editTransaction($order_details['transaction_id'], $service_timestamp = time(), $service_transaction_id = false, $data_sent = false, $data_returned = false, $successful = 0, $gross_price = false, $service_fee = false, $status = 'canceled');
                     return false;
                 }
             }
             break;
         default:
             return false;
     }
 }