function espresso_process_paypal_pro($payment_data)
{
    extract($payment_data);
    global $wpdb;
    // Included required files.
    require_once 'includes/paypal.nvp.class.php';
    $paypal_pro_settings = get_option('event_espresso_paypal_pro_settings');
    $sandbox = $paypal_pro_settings['paypal_pro_use_sandbox'];
    // Setup PayPal object
    $PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $paypal_pro_settings['paypal_api_username'], 'APIPassword' => $paypal_pro_settings['paypal_api_password'], 'APISignature' => $paypal_pro_settings['paypal_api_signature']);
    $PayPal = new Espresso_PayPal($PayPalConfig);
    // Populate data arrays with order data.
    $DPFields = array('paymentaction' => 'Sale', 'ipaddress' => $_SERVER['REMOTE_ADDR'], 'returnfmfdetails' => '1');
    $CCDetails = array('creditcardtype' => $_POST['creditcardtype'], 'acct' => $_POST['card_num'], 'expdate' => $_POST['expmonth'] . $_POST['expyear'], 'cvv2' => $_POST['cvv'], 'startdate' => '', 'issuenumber' => '');
    $PayerInfo = array('email' => $_POST['email'], 'payerid' => '', 'payerstatus' => '', 'business' => '');
    $PayerName = array('salutation' => '', 'firstname' => $_POST['first_name'], 'middlename' => '', 'lastname' => $_POST['last_name'], 'suffix' => '');
    $BillingAddress = array('street' => $_POST['address'], 'street2' => '', 'city' => $_POST['city'], 'state' => $_POST['state'], 'countrycode' => 'US', 'zip' => $_POST['zip'], 'phonenum' => empty($_POST['phone']) ? '' : $_POST['phone']);
    $ShippingAddress = array('shiptoname' => '', 'shiptostreet' => '', 'shiptostreet2' => '', 'shiptocity' => '', 'shiptostate' => '', 'shiptozip' => '', 'shiptocountrycode' => '', 'shiptophonenum' => '');
    $PaymentDetails = array('amt' => $payment_data['total_cost'], 'currencycode' => $paypal_pro_settings['currency_format'], 'itemamt' => '', 'shippingamt' => '', 'handlingamt' => '', 'taxamt' => '', 'desc' => stripslashes_deep($event_name), 'custom' => '', 'invnum' => '', 'notifyurl' => '');
    $OrderItems = array();
    $Item = array('l_name' => stripslashes_deep($event_name), 'l_desc' => stripslashes_deep($event_name), 'l_amt' => $_POST['amount'], 'l_number' => '', 'l_qty' => '1', 'l_taxamt' => '', 'l_ebayitemnumber' => '', 'l_ebayitemauctiontxnid' => '', 'l_ebayitemorderid' => '');
    array_push($OrderItems, $Item);
    // Wrap all data arrays into a single, "master" array which will be passed into the class function.
    $PayPalRequestData = array('DPFields' => $DPFields, 'CCDetails' => $CCDetails, 'PayerName' => $PayerName, 'BillingAddress' => $BillingAddress, 'PaymentDetails' => $PaymentDetails, 'OrderItems' => $OrderItems);
    $PayPalResult = $PayPal->DoDirectPayment($PayPalRequestData);
    $payment_data['payment_status'] = 'Incomplete';
    $payment_data['txn_type'] = 'PayPal Pro';
    $payment_data['txn_id'] = 0;
    $payment_data['txn_details'] = serialize($_REQUEST);
    $payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data);
    $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data);
    $Errors = GetErrors($PayPalResult);
    if (!empty($PayPalResult)) {
        unset($PayPalResult['REQUESTDATA']['CREDITCARDTYPE']);
        unset($PayPalResult['REQUESTDATA']['ACCT']);
        unset($PayPalResult['REQUESTDATA']['EXPDATE']);
        unset($PayPalResult['REQUESTDATA']['CVV2']);
        unset($PayPalResult['RAWREQUEST']);
        $payment_data['txn_id'] = $PayPalResult['TRANSACTIONID'];
        $payment_data['txn_details'] = serialize($PayPalResult);
        if (!APICallSuccessful($PayPalResult['ACK'])) {
            DisplayErrors($Errors);
        } else {
            $payment_data['payment_status'] = 'Completed';
        }
    } else {
        ?>
		<p><?php 
        _e('There was no response from PayPal.', 'event_espresso');
        ?>
</p>
		<?php 
    }
    //add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');
    return $payment_data;
}
Пример #2
0
<?php

// Included required files.
require_once 'includes/config.php';
require_once 'includes/paypal.nvp.class.php';
// Setup PayPal object
$PayPalConfig = array('Sandbox' => $sandbox, 'APIUsername' => $api_username, 'APIPassword' => $api_password, 'APISignature' => $api_signature);
$PayPal = new Espresso_PayPal($PayPalConfig);
// Populate data arrays with order data.
$GBFields = array('returnallcurrencies' => '1');
// Wrap all data arrays into a single, "master" array which will be passed into the class function.
$PayPalRequestData = array('GBFields' => $GBFields);
// Pass the master array into the PayPal class function
$PayPalResult = $PayPal->GetBalance($PayPalRequestData);
// Display results
echo '<pre />';
print_r($PayPalResult);