Example #1
0
function espresso_process_wepay_callback($payment_data)
{
    $payment_data['txn_details'] = serialize($_REQUEST);
    $payment_data['txn_type'] = 'WePay';
    $wepay_settings = get_option('event_espresso_wepay_settings');
    include_once 'Wepay.php';
    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']);
    }
    $wepay = new Wepay($wepay_settings['access_token']);
    $raw = $wepay->request('checkout', array('checkout_id' => $_REQUEST['checkout_id']));
    if (!empty($raw)) {
        $payment_data['txn_details'] = serialize(get_object_vars($raw));
        $payment_data['txn_id'] = $raw->reference_id;
        $responsecode = $raw->state;
        if ($responsecode == 'cancelled' || $responsecode == 'failed') {
            $payment_data['payment_status'] = 'Incomplete';
            $subject = 'Problem with your WePay payment';
            $body = "WePay has informed us that your payment for " . $payment_data['event_link'] . " has moved to a status of " . $responsecode . ".\n";
            $body .= "We have changed your payment status for the event to 'Incomplete'.\n";
            $body .= "Please look into the cause in your account interface at wepay.com.\nThank You.\n";
            wp_mail($payment_data['email'], $subject, $body);
        }
        return $payment_data;
    }
}
Example #2
0
 public function payment()
 {
     $captcha = $this->f3->get('SESSION.captcha_qpay');
     if ($this->f3->exists('POST.amount')) {
         if ($captcha && strtoupper($this->f3->get('POST.captcha_qpay')) != $captcha) {
             $this->f3->reroute('/home/Invalid CAPTCHA code');
         }
         $amount = $this->f3->get('POST.amount');
         $submit = $this->f3->get('POST.submit');
         if ($submit == 'paypal') {
             $charge = $amount * 3.9 / 100;
         }
         if ($submit == 'credit') {
             $charge = $amount * 2.9 / 100;
         }
         if ($submit == 'bank') {
             $charge = $amount * 0.9 / 100;
         }
         $amount1 = $amount - $charge;
         $service_fee = 10;
         $vend_amount = round($amount1 * 41 - 10, 0);
         $this->f3->set('amount', $amount);
         $this->f3->set('charge', $charge);
         $this->f3->set('service_fee', $service_fee);
         $this->f3->set('vend_amount', $vend_amount, 60);
         $this->f3->set('meter', $this->f3->get('POST.meter'), 60);
         //set the session vairables
         $this->f3->set('SESSION.vend_amount', $vend_amount);
         $this->f3->set('SESSION.meter', $this->f3->get('POST.meter'));
         $client_id = "100047";
         $client_secret = "dc6457521d";
         $access_token = "STAGE_0340a90c4dcbf2101713e14fe5dec0acf509e8db983ab647e2e9a81de0b8ac37";
         $account_id = "1443337002";
         // you can find your account ID via list_accounts.php which users the /account/find call
         /** 
          * Initialize the WePay SDK object 
          */
         //require '../../wepay/wepay.php';
         Wepay::useStaging($client_id, $client_secret);
         $wepay = new WePay($access_token);
         /**
          * Make the API request to get the checkout_uri
          * 
          */
         try {
             $checkout = $wepay->request('/checkout/create', array('account_id' => $account_id, 'amount' => $amount, 'fee_payer' => "payee", 'short_description' => "this is a qpower payment", 'type' => "SERVICE", 'mode' => "iframe"));
             $this->f3->set('SESSION.checkout', $checkout);
         } catch (WePayException $e) {
             // if the API call returns an error, get the error message for display later
             $error = $e->getMessage();
             $this->f3->set('error', $error);
         }
         $this->f3->set('checkout', $checkout);
         $this->f3->set('view', 'home.htm');
         $this->f3->set('body', 'ajax-display.htm');
     }
 }
Example #3
0
function espresso_display_wepay($payment_data)
{
    extract($payment_data);
    // Setup class
    include_once 'Wepay.php';
    echo '<!-- Event Espresso WePay Gateway Version ' . Wepay::$version . '-->';
    $wepay_settings = get_option('event_espresso_wepay_settings');
    global $org_options;
    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']);
    }
    $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id);
    $fields['account_id'] = $wepay_settings['account_id'];
    $fields['short_description'] = stripslashes_deep($event_name);
    $fields['long_description'] = stripslashes_deep($event_name) . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Registrant Email:', 'event_espresso') . ' ' . $attendee_email . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity;
    $fields['type'] = 'SERVICE';
    $fields['reference_id'] = $attendee_id;
    $fields['amount'] = number_format($event_cost, 2, '.', '');
    if ($wepay_settings['force_ssl_return']) {
        $home = str_replace("http://", "https://", home_url());
    } else {
        $home = home_url();
    }
    $fields['redirect_uri'] = $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=wepay';
    $fields['callback_uri'] = $home . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=wepay';
    if (empty($wepay_settings['access_token'])) {
        return;
    }
    $wepay = new Wepay($wepay_settings['access_token']);
    $raw = $wepay->request('checkout/create', $fields);
    if (empty($raw->checkout_uri)) {
        return;
    }
    $uri = $raw->checkout_uri;
    if ($wepay_settings['bypass_payment_page'] == 'Y') {
        $wepay->submitPayment($uri);
        //Enable auto redirect to payment site
    } else {
        $wepay->submitButton($uri, $wepay_settings['button_url'], 'wepay');
        //Display payment button
        wp_deregister_script('jquery.validate.pack');
    }
    if ($wepay_settings['use_sandbox']) {
        echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>';
        $wepay->dump_fields($fields);
        // for debugging, output a table of all the fields
    }
}
 function charge(&$order)
 {
     //create a code for the order
     if (empty($order->code)) {
         $order->code = $order->getRandomCode();
     }
     //code to charge with gateway and test results would go here
     // application settings
     $account_id = pmpro_getOption('wepay_account_id');
     $client_id = pmpro_getOption('wepay_client_id');
     $client_secret = pmpro_getOption('wepay_client_secret');
     $access_token = pmpro_getOption('wepay_access_token');
     // credit card id to charge
     $credit_card_id = $order->wepay_token;
     //TODO: Make sure we're getting this
     // change to useProduction for live environments
     $environment = pmpro_getOption('gateway_environment');
     if ($environment == 'live') {
         Wepay::useProduction($client_id, $client_secret);
     } else {
         Wepay::useStaging($client_id, $client_secret);
     }
     $wepay = new WePay($access_token);
     // charge the credit card
     $response = $wepay->request('checkout/create', array('account_id' => $account_id, 'amount' => '25.50', 'currency' => 'USD', 'short_description' => 'A vacation home rental', 'type' => 'goods', 'payment_method' => array('type' => 'credit_card', 'credit_card' => array('id' => $credit_card_id))));
     //test response
     //simulate a successful charge
     $order->payment_transaction_id = "TEST" . $order->code;
     $order->updateStatus("success");
     return true;
 }

<div class="wrap">
<h2> All Transactions</h2>

<?php 
include_once 'wepay_api.php';
$account_id = 471568071;
$client_id = 167371;
$client_secret = "798f5f4b8a";
$access_token = "STAGE_5dcc267978e11dfb927d91a5dd5f7ed1972484f30f59a64b3f30760ee7faf897";
Wepay::useStaging($client_id, $client_secret);
$wepay = new WePay($access_token);
/**************************************************/
if (isset($_REQUEST['refund_btn'])) {
    $chechout_id = $_REQUEST['refund_btn'];
    $refundtype = $_REQUEST['refundtype_' . $chechout_id];
    $refund_amount = $_REQUEST['refund_amount_' . $chechout_id];
    $refund_description = $_REQUEST['refund_description_' . $chechout_id];
    $refund_arg = array('checkout_id' => $chechout_id, 'refund_reason' => $refund_description);
    if ($refundtype == 'partial') {
        $refund_arg['amount'] = $refund_amount;
    }
    //print_r($refund_arg);
    try {
        $refund_trs = $wepay->request('/checkout/refund', $refund_arg);
        //echo "<pre>";
        //	print_r($refund_trs);
        if ($refund_trs->state == "refunded" || $refund_trs->state == "captured") {
            ?>
			<div class="updated"><p><strong>Transaction Refunded Successfully</p></strong></div>
Example #6
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 
}
Example #7
0
<?php

$wepayId = "116276";
define("WEPAY_CLIENT_ID", $wepayId);
define("WEPAY_CLIENT_SECRET", "50f678683c");
require 'wepay_sdk.php';
Wepay::useStaging(WEPAY_CLIENT_ID, WEPAY_CLIENT_SECRET);
//client_id and client_secret ***************************CHANGE TO useProduction when going live**************************
session_start();
Example #8
0
<?php

require '../wepay.php';
Wepay::useStaging('YOUR CLIENT ID', 'YOUR CLIENT SECRET');
session_start();