示例#1
0
     $additional_paypal = 0;
     $additional_paypal = apply_filters('ProjectTheme_filter_paypal_listing_additional', $additional_paypal, $pid);
     //$ProjectTheme_get_show_price = ProjectTheme_get_show_price($pid);
     $total = $my_total + $additional_paypal;
     $title_post = $post->post_title;
     $title_post = apply_filters('ProjectTheme_filter_paypal_listing_title', $title_post, $pid);
     //---------------------------------------------
     //$p->add_field('business', '*****@*****.**');
     $p->add_field('business', $business);
     $p->add_field('currency_code', get_option('ProjectTheme_currency'));
     $p->add_field('return', $this_script . '&action=success');
     $p->add_field('cancel_return', $this_script . '&action=cancel');
     $p->add_field('notify_url', $this_script . '&action=ipn');
     $p->add_field('item_name', $title_post);
     $p->add_field('custom', $pid . '|' . $uid . '|' . current_time('timestamp', 0));
     $p->add_field('amount', ProjectTheme_formats_special($total, 2));
     $p->add_field('bn', 'SiteMile_SP');
     $p->submit_paypal_post();
     // submit the fields to paypal
     break;
 case 'success':
     // Order was successful...
 // Order was successful...
 case 'ipn':
     if (isset($_POST['custom'])) {
         $cust = $_POST['custom'];
         $cust = explode("|", $cust);
         $pid = $cust[0];
         $uid = $cust[1];
         $datemade = $cust[2];
         //--------------------------------------------
$fee = get_option('projectTheme_fee_after_paid');
if (empty($fee)) {
    die('ERROR. Please specify an amount for the percent taken by admin for each project.');
}
//-------------------------------------------------------------------------
$adminfee = $total * ($fee * 0.01);
$receiver1 = get_option('ProjectTheme_paypal_email');
if (empty($receiver1)) {
    die('ERROR. The site admin has no paypal email defined.');
}
$amount1 = ProjectTheme_formats_special($adminfee, 2);
$receiver2 = get_user_meta($receiver_user_id, 'paypal_email', 'true');
if (empty($receiver2)) {
    die('ERROR. The bid winner has no paypal email defined.');
}
$amount2 = ProjectTheme_formats_special($total - $adminfee, 2);
$currency = get_option('ProjectTheme_currency');
$enasdbx = get_option('ProjectTheme_paypal_enable_sdbx');
if ($enasdbx == "yes") {
    $link = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay";
} else {
    $link = "https://svcs.paypal.com/AdaptivePayments/Pay";
}
$notifyURL = urlencode(get_bloginfo('siteurl') . "/?notify_chained=" . $pid);
$trID = $pid . "_" . time();
$params = "actionType=PAY_PRIMARY&cancelUrl=" . $ret . "&trackingId=" . $trID . "&ipnNotificationUrl=" . $notifyURL . "&currencyCode=" . $currency . "&receiverList.receiver(0).amount=" . ($amount1 + $amount2) . "&receiverList.receiver(0).email=" . $receiver1 . "&receiverList.receiver(0).primary=true&receiverList.receiver(1).primary=false&receiverList.receiver(1).amount=" . $amount2 . "&receiverList.receiver(1).email=" . $receiver2 . "&requestEnvelope.errorLanguage=en_US" . "&returnUrl=" . $ret;
function array_push_assoc($array, $key, $value)
{
    $array[$key] = $value;
    return $array;
}