function qpp_get_stored_autoresponder($id)
{
    $auto = get_option('qpp_autoresponder' . $id);
    if (!is_array($auto)) {
        $send = qpp_get_stored_send($id);
        if ($send['thankyou']) {
            $auto = array('enable' => $send['thankyou'], 'subject' => 'Thank you for your payment.', 'whenconfirm' => $send['whenconfirm'], 'message' => $send['thankyoumessage'], 'paymentdetails' => 'checked', 'fromname' => '', 'fromemail' => '');
            $send['thankyou'] = '';
            update_option('qpp_send' . $id, $send);
        } else {
            $auto = array('enable' => '', 'subject' => 'Thank you for your payment.', 'whenconfirm' => 'aftersubmission', 'message' => 'Once payment has been confirmed we will process your order and be in contanct soon.', 'paymentdetails' => 'checked', 'fromname' => '', 'fromemail' => '');
        }
    }
    return $auto;
}
Example #2
0
function qpp_send_page($id)
{
    qpp_change_form_update();
    if (isset($_POST['Submit']) && check_admin_referer("save_qpp")) {
        $options = array('waiting', 'use_lc', 'lc', 'customurl', 'cancelurl', 'thanksurl', 'target', 'email', 'donate', 'combine', 'confirmmessage', 'google_onclick');
        foreach ($options as $item) {
            $send[$item] = stripslashes($_POST[$item]);
            $send[$item] = filter_var($send[$item], FILTER_SANITIZE_STRING);
        }
        update_option('qpp_send' . $id, $send);
        qpp_admin_notice("The submission settings have been updated.");
    }
    if (isset($_POST['Reset']) && check_admin_referer("save_qpp")) {
        delete_option('qpp_send' . $id);
        qpp_admin_notice("The submission settings have been reset.");
    }
    $qpp_setup = qpp_get_stored_setup();
    $id = $qpp_setup['current'];
    $newpage = $customurl = '';
    $send = qpp_get_stored_send($id);
    ${$send}['target'] = 'checked';
    ${$send}['lc'] = 'selected';
    qpp_create_css_file('update');
    $content = '<div class="qpp-settings"><div class="qpp-options">';
    if ($id) {
        $content .= '<h2>Send settings for ' . $id . '</h2>';
    } else {
        $content .= '<h2>Default form send options</h2>';
    }
    $content .= qpp_change_form($qpp_setup);
    $content .= '
    <form action="" method="POST">
    <h2>Submission Message</h2>
    <p>This is what the visitor sees while the paypal page loads</p>
    <input type="text" style="width:100%" name="waiting" value="' . $send['waiting'] . '" />
    <h2>Force Locale</h2>
    <p clsss="description">This may or may not work, Paypal has some very strange rule regarding language</p>
    <p><input type="checkbox" style="margin:0; padding: 0; border: none" name="use_lc" ' . $send['use_lc'] . ' value="checked" /> Use Locale</p>
    <select name="lc">
    <option value="AU" ' . $AU . '>Australia</option>
    <option value="AT" ' . $AT . '>Austria</option>
    <option value="BE" ' . $BE . '>Belgium</option>
    <option value="BR" ' . $BR . '>Brazil</option>
    <option value="pt_BR" ' . $pt_BR . '>Brazilian Portuguese (for Portugal and Brazil only)</option>
    <option value="CA" ' . $CA . '>Canada</option>
    <option value="CH" ' . $CH . '>Switzerland</option>
    <option value="CN" ' . $CN . '>China</option>
    <option value="da_DK" ' . $da_DK . '>Danish (for Denmark only)</option>
    <option value="FR" ' . $FR . '>France</option>
    <option value="DE" ' . $DE . '>Germany</option>
    <option value="he_IL" ' . $he_IL . '>Hebrew (all)</option>
    <option value="id_ID" ' . $id_ID . '>Indonesian (for Indonesia only)</option>
    <option value="IT" ' . $IT . '>Italy</option>
    <option value="ja_JP" ' . $ja_JP . '>Japanese (for Japan only)</option>
    <option value="NL" ' . $NL . '>Netherlands</option>
    <option value="no_NO" ' . $no_NO . '>Norwegian (for Norway only)</option>
    <option value="PL" ' . $PL . '>Poland</option>
    <option value="PT" ' . $PT . '>Portugal</option>
    <option value="RU" ' . $RU . '>Russia</option>
    <option value="ru_RU" ' . $ru_RU . '>Russian (for Lithuania, Latvia, and Ukraine only)</option>
    <option value="zh_CN" ' . $zh_CN . '>Simplified Chinese (for China only)</option>
    <option value="zh_HK" ' . $zh_HK . '>Traditional Chinese (for Hong Kong only)</option>
    <option value="zh_TW" ' . $zh_TW . '>Traditional Chinese (for Taiwan only)</option>
    <option value="ES" ' . $ES . '>Spain</option>
    <option value="sv_SE" ' . $sv_SE . '>Swedish (for Sweden only)</option>
    <option value="th_TH" ' . $th_TH . '>Thai (for Thailand only)</option>
    <option value="tr_TR" ' . $tr_TR . '>Turkish (for Turkey only)</option>
    <option value="GB" ' . $GB . '>United Kingdom</option>
    <option value="US" ' . $US . '>United States</option>
    </select>
    <h2>Cancel and Thank you pages</h2>
    <p>If you leave these blank paypal will return the user to the current page.</p>
    <p>URL of cancellation page</p>
    <input type="text" style="width:100%" name="cancelurl" value="' . $send['cancelurl'] . '" />
    <p>URL of thank you page</p>
    <input type="text" style="width:100%" name="thanksurl" value="' . $send['thanksurl'] . '" />
    <h2>Confirmation Message</h2>
    <p><input type="checkbox" style="margin:0; padding: 0; border: none" name="confirmmessage" ' . $send['confirmmessage'] . ' value="checked" /> Send yourself a copy of the payment details.</p>
    <p>You can sen the payee a confirmation message using the <a href="?page=quick-paypal-payments/settings.php&tab=autoresponce">Auto Responder</a> options.</p>
    <h2>Custom Paypal Settings</h2>
    <p><input type="checkbox" style="margin:0; padding: 0; border: none" name="donate" ' . $send['donate'] . ' value="checked" /> Form is for donations only</p>
    <p><input type="checkbox" style="margin:0; padding: 0; border: none" name="combine" ' . $send['combine'] . ' value="checked" /> Include Postage and Processing in the amount to pay.</p>
    <p>If you have a custom PayPal page enter the URL here. Leave blank to use the standard PayPal payment page</p>
    <p><input type="text" style="width:100%" name="customurl" value="' . $send['customurl'] . '" /></p>
    <p>Alternate PayPal email address:</p>
    <p><input type="text" style="width:100%" name="email" value="' . $send['email'] . '" /></p>
    <p><input style="width:20px; margin: 0; padding: 0; border: none;" type="radio" name="target" value="current" ' . $current . ' /> Open in existing page<br>
    <input style="width:20px; margin: 0; padding: 0; border: none;" type="radio" name="target" value="newpage" ' . $newpage . ' /> Open link in new page/tab <span class="description">This is very browser dependant. Use with caution!</span></p>
    <h2>Google onClick Event</h2>
    <p><input type="text" style="width:100%" name="google_onclick" value="' . $send['google_onclick'] . '" /></p>
    <p><input type="submit" name="Submit" class="button-primary" style="color: #FFF;" value="Save Changes" /> <input type="submit" name="Reset" class="button-primary" style="color: #FFF;" value="Reset" onclick="return window.confirm( \'Are you sure you want to reset the form settings?\' );"/></p>';
    $content .= wp_nonce_field("save_qpp");
    $content .= '</form>
    </div>
    <div class="qpp-options" style="float:right;"> <h2>Form Preview</h2>
    <p>Note: The preview form uses the wordpress admin styles. Your form will use the theme styles so won\'t look exactly like the one below.</p>';
    if ($id) {
        $form = ' form="' . $id . '"';
    }
    $args = array('form' => $id, 'id' => '', 'amount' => '');
    $content .= qpp_loop($args);
    $content .= '<p>There are some more examples of payment forms <a href="http://quick-plugins.com/quick-paypal-payments/paypal-examples/" target="_blank">on this page</a>.</p>
    <p>And there are loads of shortcode options <a href="http://quick-plugins.com/quick-paypal-payments/paypal-payments-shortcodes/" target="_blank">on this page</a>.</p>
    </div></div>';
    echo $content;
}
function qpp_send_confirmation($values, $id, $amounttopay)
{
    $qpp_setup = qpp_get_stored_setup();
    $qpp = qpp_get_stored_options($id);
    $send = qpp_get_stored_send($id);
    $auto = qpp_get_stored_autoresponder($id);
    $c = qpp_currency($id);
    if (empty($auto['fromemail'])) {
        $auto['fromemail'] = $qpp_setup['email'];
    }
    if (empty($auto['fromname'])) {
        $auto['fromname'] = get_bloginfo('name');
    }
    $fullamount = $c['b'] . $amounttopay . $c['a'];
    $headers = "From: {$auto['fromname']} <{$auto['fromemail']}>\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n";
    $subject = $auto['subject'];
    $ref = $qpp['shortcodereference'] ? $qpp['shortcodereference'] : 'Reference';
    if ($qpp['fixedreference']) {
        $qpp['inputreference'] = $ref;
    }
    $amt = $qpp['shortcodeamount'] ? $qpp['shortcodeamount'] : 'Amount';
    if ($qpp['fixedamount']) {
        $qpp['inputamount'] = $amt;
    }
    $details = '<table>
    <tr><td>' . $qpp['inputreference'] . ': </td><td>' . $values['reference'] . '</td></tr><tr><td>' . $qpp['quantitylabel'] . ': </td><td>' . $values['quantity'] . '</td></tr>';
    if ($qpp['use_stock']) {
        $details .= '<tr><td>' . $qpp['stocklabel'] . ': </td><td>' . strip_tags($values['stock']) . '</td></tr>';
    }
    if ($qpp['use_options']) {
        $details .= '<tr><td>' . $qpp['optionlabel'] . ': </td><td>' . strip_tags($values['option1']) . '</td></tr>';
    }
    $details .= '<tr><td>' . $qpp['inputamount'] . ': </td><td>' . $amounttopay . '</td></tr></table>';
    $content = '<p>' . $auto['message'] . '</p>';
    $content = str_replace('<p><p>', '<p>', $content);
    $content = str_replace('</p></p>', '</p>', $content);
    $content = str_replace('[firstname]', $values['firstname'], $content);
    $content = str_replace('[name]', $values['firstname'] . ' ' . $values['lastname'], $content);
    $content = str_replace('[reference]', $values['reference'], $content);
    $content = str_replace('[fullamount]', $fullamount, $content);
    $content = str_replace('[amount]', $amounttopay, $content);
    $content = str_replace('[stock]', $values['stock'], $content);
    $content = str_replace('[option]', $values['option1'], $content);
    $content = str_replace('[details]', $details, $content);
    if ($auto['paymentdetails']) {
        $content .= $details;
    }
    wp_mail($values['email'], $subject, $content, $headers);
    if ($send['confirmmessage']) {
        $subject = 'Payment for ' . $values['reference'];
        if ($qpp['useaddress']) {
            $contentb .= '<tr><td>' . $address['email'] . '</td><td>' . $values['email'] . '</td></tr></tr>
            <tr><td>' . $address['firstname'] . '</td><td>' . $values['firstname'] . '</td></tr>
            <tr><td>' . $address['lastname'] . '</td><td>' . $values['lastname'] . '</td></tr>
            <tr><td>' . $address['address1'] . '</td><td>' . $values['address1'] . '</td></tr>
            <tr><td>' . $address['address2'] . '</td><td>' . $values['address2'] . '</td></tr>
            <tr><td>' . $address['city'] . '</td><td>' . $values['city'] . '</td></tr>
            <tr><td>' . $address['state'] . '</td><td>' . $values['state'] . '</td></tr>
            <tr><td>' . $address['zip'] . '</td><td>' . $values['zip'] . '</td></tr>
            <tr><td>' . $address['country'] . '</td><td>' . $values['country'] . '</td></tr>
            <tr><td>' . $address['night_phone_b'] . '</td><td>' . $values['night_phone_b'] . '</td></tr>';
        }
        $content = $cotenta . $contentb . $contentc;
        wp_mail($qpp_setup['email'], $subject, $content, $headers);
    }
}