コード例 #1
0
 /**
  * Start express checkout
  */
 static function startExpressCheckout()
 {
     /* define options */
     $config = paypalConfig::getInstance();
     /* check account or packet price */
     $user_roles = TMM_Cardealer_User::get_user_roles();
     $featured_packets = TMM_Cardealer_User::get_features_packets();
     $currency = TMM_Ext_Car_Dealer::$default_currency['name'];
     if (isset($user_roles[$_POST['PAYMENTREQUEST_0_CUSTOM']])) {
         $amount = $user_roles[$_POST['PAYMENTREQUEST_0_CUSTOM']]['packet_price'];
         $role_name = $user_roles[$_POST['PAYMENTREQUEST_0_CUSTOM']]['name'];
         $desc = __('Account Status Upgrade', TMM_PAYPAL_PLUGIN_TEXTDOMAIN);
     } else {
         if (isset($featured_packets[$_POST['PAYMENTREQUEST_0_CUSTOM']])) {
             $amount = $featured_packets[$_POST['PAYMENTREQUEST_0_CUSTOM']]['packet_price'];
             $role_name = $featured_packets[$_POST['PAYMENTREQUEST_0_CUSTOM']]['name'];
             $desc = __('Featured Cars Bundle', TMM_PAYPAL_PLUGIN_TEXTDOMAIN);
         } else {
             header('Location: ' . get_permalink(get_option('paypal_cancel_page')));
         }
     }
     $desc .= ': `' . $role_name . '`, ' . $amount . ' ' . $currency;
     $checked = apply_filters('tmm_paypal_currency', $currency, (double) $amount);
     if ($currency !== $checked['currency']) {
         $desc .= ' (' . $checked['amount'] . ' ' . $checked['currency'] . ')';
     }
     $desc .= ', ' . home_url();
     $currency = $checked['currency'];
     $amount = $checked['amount'];
     $fields = array('USER' => trim(get_option('paypal_api_username')), 'PWD' => trim(get_option('paypal_api_password')), 'SIGNATURE' => trim(get_option('paypal_api_signature')), 'METHOD' => 'SetExpressCheckout', 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', 'RETURNURL' => $config->getItem('plugin_form_handler_url') . '?func=confirm', 'CANCELURL' => $config->getItem('cancel_page'), 'SOLUTIONTYPE' => get_option('paypal_solutiontype') === 'Mark' ? 'Mark' : 'Sole', 'VERSION' => $config->getItem('paypal_api_version'), 'PAYMENTREQUEST_0_AMT' => $amount, 'PAYMENTREQUEST_0_ITEMAMT' => $amount, 'PAYMENTREQUEST_0_AMT0' => $amount, 'ITEMAMT' => $amount, 'PAYMENTREQUEST_0_CURRENCYCODE' => $currency, 'PAYMENTREQUEST_0_DESC' => $desc, 'L_PAYMENTREQUEST_0_NAME0' => $role_name, 'L_PAYMENTREQUEST_0_DESC0' => $desc, 'L_PAYMENTREQUEST_0_AMT0' => $amount);
     if (isset($_POST['PAYMENTREQUEST_0_CUSTOM'])) {
         $packet_key = $_POST['PAYMENTREQUEST_0_CUSTOM'];
         $fields['PAYMENTREQUEST_0_CUSTOM'] = $packet_key;
         //*** check if packet key exists
         $packets = TMM_Cardealer_User::get_user_roles();
         if (!isset($packets[$packet_key])) {
             $packets = TMM_Cardealer_User::get_features_packets();
             if (!isset($packets[$packet_key])) {
                 header('Location: ' . $config->getItem('cancel_page'));
             }
         }
         //*** check if user paid full price or wrong price
         if ((double) $fields['PAYMENTREQUEST_0_AMT'] !== (double) $packets[$packet_key]['packet_price']) {
             header('Location: ' . $config->getItem('cancel_page'));
         }
     } else {
         header('Location: ' . $config->getItem('cancel_page'));
     }
     /* request to payPal for getting token */
     $result = self::doCurlRequest($fields);
     if (isset($result['ACK']) && ($result['ACK'] == 'Success' || $result['ACK'] == 'SuccessWithWarning')) {
         if (get_option('paypal_environment') == 'sandbox') {
             header('Location: ' . $config->getItem('paypal_sandbox_server_url') . $result['TOKEN']);
         } elseif (get_option('paypal_environment') == 'live') {
             header('Location: ' . $config->getItem('paypal_live_server_url') . $result['TOKEN']);
         }
     } else {
         header('Location: ' . get_permalink(get_option('paypal_cancel_page')));
     }
 }
コード例 #2
0
<?php

/**
 * Form posting handler
 */
require_once '../../../wp-load.php';
require_once TMM_PAYPAL_PLUGIN_PATH . '/classes/paypalConfig.php';
require_once TMM_PAYPAL_PLUGIN_PATH . '/classes/paypalApi.php';
if (isset($_POST['func']) && $_POST['func'] === 'start') {
    paypalApi::startExpressCheckout();
} else {
    if (isset($_GET['func']) && $_GET['func'] == 'confirm' && isset($_GET['token']) && isset($_GET['PayerID'])) {
        $message_num = 0;
        $paypal_data = paypalApi::confirmExpressCheckout();
        $config = paypalConfig::getInstance();
        if (isset($paypal_data['ACK']) && ($paypal_data['ACK'] == 'Success' || $paypal_data['ACK'] == 'SuccessWithWarning')) {
            $message_num = TMM_Cardealer_User::user_paid_money($paypal_data);
            header('Location: ' . $config->getItem('success_page'));
        } else {
            $message_num = $paypal_data['L_ERRORCODE0'];
            header('Location: ' . $config->getItem('cancel_page') . '?errorcode=' . $message_num);
        }
    } else {
        header('Location: ' . $config->getItem('cancel_page'));
    }
}
コード例 #3
0
				<th class="manage-column">
					<a href="<?php 
echo $links['date_link'];
?>
"><?php 
_e('Date', TMM_PAYPAL_PLUGIN_TEXTDOMAIN);
?>
</a>
				</th>
			</tr>
		</tfoot>

		<tbody class="list:user" id="the-list">
			<?php 
$roles = TMM_Cardealer_User::get_user_roles();
$feature_packets = TMM_Cardealer_User::get_features_packets();
?>
			<?php 
if (isset($rows)) {
    foreach ($rows as $kk => $row) {
        ?>
				<?php 
        $is_price_red = false;
        $is_key_red = false;
        if ((double) @$roles[$row->packet_id]['packet_price'] !== (double) $row->amount) {
            if ((double) @$feature_packets[$row->packet_id]['packet_price'] !== (double) $row->amount) {
                $is_price_red = true;
            }
        }
        //***
        if (@(!isset($roles[$row->packet_id]))) {