Beispiel #1
0
function event_espresso_display_wepay_settings($need_to_reauthorize)
{
    $wepay_settings = get_option('event_espresso_wepay_settings');
    $uri = $_SERVER['REQUEST_URI'];
    $pos = strpos($uri, '&activate_wepay=true');
    if ($pos) {
        $uri = substr("{$uri}", 0, $pos);
    }
    $pos = strpos($uri, '&code');
    if ($pos) {
        $uri = substr("{$uri}", 0, $pos);
    }
    _e('Instructions:');
    ?>
	&nbsp;<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=instructions"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
	<form method="post" action="<?php 
    echo $uri;
    ?>
#wepay">
		<table width="99%" border="0" cellspacing="5" cellpadding="5">
			<tr>
				<td valign="top"><ul>
						<li>
							<label for="wepay_client_id">
	<?php 
    _e('WePay Client ID', 'event_espresso');
    ?>
							</label>
							<input type="text" name="wepay_client_id" size="35" value="<?php 
    echo $wepay_settings['wepay_client_id'];
    ?>
" />
						</li>
						<li>
							<label for="wepay_client_secret">
	<?php 
    _e('WePay Client Secret', 'event_espresso');
    ?>
							</label>
							<input type="text" name="wepay_client_secret" size="35" value="<?php 
    echo $wepay_settings['wepay_client_secret'];
    ?>
" />
						</li>
						<li>
							<label for="button_url">
	<?php 
    _e('Button Image URL', 'event_espresso');
    ?>
 <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=button_image"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
							</label>
							<input type="text" name="button_url" size="34" value="<?php 
    echo $wepay_settings['button_url'] == '' ? '' : $wepay_settings['button_url'];
    ?>
" />
							<a href="media-upload.php?post_id=0&amp;type=image&amp;TB_iframe=true&amp;width=640&amp;height=580&amp;rel=button_url" id="add_image" class="thickbox" title="Add an Image"><img src="images/media-button-image.gif" alt="Add an Image"></a> </li>
						<li>
							<label for="account_id">
							<?php 
    _e('Select the Account to Use', 'event_espresso');
    ?>
 <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=select_account"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
							</label>
							<?php 
    echo select_input('account_id', $wepay_settings['available_accounts'], $wepay_settings['account_id']);
    ?>
							</li>
					</ul></td>
				<td valign="top">
					<ul>
						<li>
							<label for="bypass_payment_page">
							<?php 
    _e('Bypass Payment Overview Page', 'event_espresso');
    ?>
 <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=bypass_confirmation"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
							</label>
							<?php 
    $values = array(array('id' => 'N', 'text' => __('No', 'event_espresso')), array('id' => 'Y', 'text' => __('Yes', 'event_espresso')));
    echo select_input('bypass_payment_page', $values, $wepay_settings['bypass_payment_page']);
    ?>
							</li>
						<li>
							<label for="use_sandbox">
	<?php 
    _e('Turn on Debugging Using the', 'event_espresso');
    ?>
 <a href="https://developer.wepay.com/devscr?cmd=_home||https://cms.wepay.com/us/cgi-bin/?&amp;cmd=_render-content&amp;content_ID=developer/howto_testing_sandbox||https://cms.wepay.com/us/cgi-bin/?&amp;cmd=_render-content&amp;content_ID=developer/howto_testing_sandbox_get_started" title="WePay Sandbox Login||Sandbox Tutorial||Getting Started with WePay Sandbox" target="_blank"><?php 
    _e('WePay Sandbox', 'event_espresso');
    ?>
</a> <a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=wepay_sandbox_info"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
							</label>
							<input name="use_sandbox" type="checkbox" value="1" <?php 
    echo $wepay_settings['use_sandbox'] ? 'checked="checked"' : '';
    ?>
 />
							<br />
						</li>
						<li>
							<label for="force_ssl_return">
	<?php 
    _e('Force HTTPS on Return URL', 'event_espresso');
    ?>
								<a class="thickbox" href="#TB_inline?height=300&width=400&inlineId=force_ssl_return"><img src="<?php 
    echo EVENT_ESPRESSO_PLUGINFULLURL;
    ?>
/images/question-frame.png" width="16" height="16" /></a>
							</label>
							<input name="force_ssl_return" type="checkbox" value="1" <?php 
    echo $wepay_settings['force_ssl_return'] ? 'checked="checked"' : '';
    ?>
 /></li>
						<li>
							<?php 
    _e('Current Button Image', 'event_espresso');
    ?>
							<br />
	<?php 
    echo $wepay_settings['button_url'] == '' ? '<img src="' . $button_url . '" />' : '<img src="' . $wepay_settings['button_url'] . '" />';
    ?>
</li>
					</ul>
				</td>
			</tr>
		</table>
		<p>
			<input type="hidden" name="update_wepay" value="update_wepay">
			<input class="button-primary" type="submit" name="Submit" value="<?php 
    _e('Update WePay Settings', 'event_espresso');
    ?>
" id="save_wepay_settings" />
		</p>
	</form>
	<?php 
    if ($need_to_reauthorize) {
        if ($wepay_settings['use_sandbox']) {
            Wepay::useStaging($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']);
        } else {
            Wepay::useProduction($wepay_settings['wepay_client_id'], $wepay_settings['wepay_client_secret']);
        }
        $scope = Wepay::$all_scopes;
        $redirect_uri = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
        $_SESSION['redirect_uri'] = $redirect_uri;
        $uri = Wepay::getAuthorizationUri($scope, $redirect_uri);
        ?>
		<form method="post" action="<?php 
        echo $uri;
        ?>
">
			<input class="button-primary" type="submit" name="Submit" value="<?php 
        _e('Authorize Application', 'event_espresso');
        ?>
" id="authorize_wepay_application" />
		</form>
	<?php 
    }
    ?>
	<div id="wepay_sandbox_info" style="display:none">
		<h2><?php 
    _e('WePay Sandbox', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('In addition to using the WePay Sandbox feature. The debugging feature will also output the form variables to the payment page, send an email to the admin that contains the all WePay variables.', 'event_espresso');
    ?>
</p>
		<hr />
		<p><?php 
    _e('The WePay Sandbox is a testing environment that is a duplicate of the live WePay site, except that no real money changes hands. The Sandbox allows you to test your entire integration before submitting transactions to the live WePay environment. Create and manage test accounts, and view emails and API credentials for those test accounts.', 'event_espresso');
    ?>
</p>
	</div>
	<div id="instructions" style="display:none">
		<h2><?php 
    _e('WePay Instructions', 'event_espresso');
    ?>
</h2>
	<?php 
    _e('To use WePay, follow these steps:');
    ?>
		<ol>
			<li>
	<?php 
    _e('At WePay.com (or stage.wepay.com for sandbox) sign up as a user and add an account to your user.');
    ?>
			</li>
			<li>
	<?php 
    _e('Register your instance of Event Espresso as an application in your WePay user profile.');
    ?>
			</li>
			<li>
	<?php 
    _e('Copy your client id and client secret from your application profile and paste them here.');
    ?>
			</li>
			<li>
	<?php 
    _e('Anytime you change your id and secret on this page and update your WePay settings, you will see a button to authorize your application.');
    ?>
			</li>
			<li>
	<?php 
    _e('Once your application is authorized, you will be able to select from your available accounts, and update your WePay settings.');
    ?>
			</li>
		</ol>
	</div>
	<div id="select_account" style="display: none">
		<h2><?php 
    _e('WePay Account', 'event_espresso');
    ?>
</h2>
		<p><?php 
    _e('The name of the account you want to use with Event Espresso.', 'event_espresso');
    ?>
</p>
	</div>
	<?php 
}