本文整理汇总了PHP中Paypal::add_field方法的典型用法代码示例。如果您正苦于以下问题:PHP Paypal::add_field方法的具体用法?PHP Paypal::add_field怎么用?PHP Paypal::add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paypal
的用法示例。
在下文中一共展示了Paypal::add_field方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: paypal_c
public function paypal_c()
{
foreach ($_POST as $k => $post) {
$_POST[$k] = str_replace($this->paypal_c_url, "http://{$_SERVER['HTTP_HOST']}", $_POST[$k]);
if (false !== strpos($_POST[$k])) {
$_POST[$k] = str_replace('Payment-Pin', 'Payment-Pin_c', $_POST[$k]);
}
}
import('@.ORG.Payment.Paypal');
$p = new Paypal();
$p->add_field('business', $_POST['business']);
//收款人账号'402660_1224487424_biz@qq.com'
//$p->add_field ( 'return',$_POST['return'] );//网站中指定返回地址
$p->add_field('cancel_return', $_POST['cancel_return']);
$p->add_field('notify_url', $_POST['notify_url']);
$p->add_field('item_name', $_POST['item_name']);
//产品名称
$p->add_field('item_number', $_POST['item_number']);
//订单号码
$p->add_field('amount', $_POST['amount']);
//交易价格
$p->add_field('currency_code', $_POST['currency_code'] ? $_POST['currency_code'] : 'USD');
//货币代码
$p->submit_paypal_post_c();
//简洁提交
}
示例2: eme_paypal_form
function eme_paypal_form($event, $payment, $price, $lang, $multi_booking = 0)
{
global $post;
$quantity = 1;
$charge = eme_payment_provider_extra_charge($price, 'paypal');
$price += $charge;
$events_page_link = eme_get_events_page(true, false);
$payment_id = $payment['id'];
if ($multi_booking) {
$success_link = get_permalink($post->ID);
$fail_link = $success_link;
$name = __("Multiple booking request", "eme");
} else {
$success_link = eme_payment_return_url($event, $payment, 1);
$fail_link = eme_payment_return_url($event, $payment, 2);
$name = eme_sanitize_html(sprintf(__("Booking for '%s'", "eme"), $event['event_name']));
}
$notification_link = add_query_arg(array('eme_eventAction' => 'paypal_notification'), $events_page_link);
$button_above = eme_replace_payment_provider_placeholders(get_option('eme_paypal_button_above'), $charge, $event['currency'], $lang);
$button_label = eme_replace_payment_provider_placeholders(get_option('eme_paypal_button_label'), $charge, $event['currency'], $lang);
$button_below = eme_replace_payment_provider_placeholders(get_option('eme_paypal_button_below'), $charge, $event['currency'], $lang);
$button_img_url = get_option('eme_paypal_button_img_url');
require_once "payment_gateways/paypal/Paypal.php";
$p = new Paypal();
// the paypal or paypal sandbox url
$p->paypal_url = get_option('eme_paypal_url');
// the timeout in seconds before the button form is submitted to paypal
// this needs the included addevent javascript function
// 0 = no delay
// false = disable auto submission
$p->timeout = false;
// the button label
// false to disable button (if you want to rely only on the javascript auto-submission) not recommended
$button_label = htmlentities($button_label);
$p->button = $button_label;
if (!empty($button_img_url)) {
$p->button_img_url = $button_img_url;
}
if (get_option('eme_paypal_s_encrypt')) {
// use encryption (strongly recommended!)
$p->encrypt = true;
$p->private_key = get_option('eme_paypal_s_privkey');
$p->public_cert = get_option('eme_paypal_s_pubcert');
$p->paypal_cert = get_option('eme_paypal_s_paypalcert');
$p->cert_id = get_option('eme_paypal_s_certid');
} else {
$p->encrypt = false;
}
// the actual button parameters
// https://www.paypal.com/IntegrationCenter/ic_std-variable-reference.html
$p->add_field('charset', 'utf-8');
$p->add_field('business', get_option('eme_paypal_business'));
$p->add_field('return', $success_link);
$p->add_field('cancel_return', $fail_link);
$p->add_field('notify_url', $notification_link);
$p->add_field('item_name', $name);
$p->add_field('item_number', $payment_id);
$p->add_field('currency_code', $event['currency']);
$p->add_field('amount', $price);
$p->add_field('quantity', $quantity);
$p->add_field('no_shipping', 1);
if (get_option('eme_paypal_no_tax')) {
$p->add_field('tax', 0);
}
$form_html = $button_above;
$form_html .= $p->get_button();
$form_html .= $button_below;
return $form_html;
}
示例3: pay_new
/**
* User::pay_new()
*
* New payment
*
* @access public
* @param int $id User ID
* @param int $gate_id Gateway ID
* @return void
*/
public function pay_new($id = '', $gate_id = '')
{
if (intval($id) == 0 or intval($gate_id) == 0) {
show_404();
}
$user = $this->db->get_where('users', array('id' => $id))->row();
if (!$user or $user->status != 0) {
show_404();
}
$group = $this->db->get_where('groups', array('id' => $user->group))->row();
if (!$group) {
show_404();
}
$gate = $this->db->get_where('gateways', array('id' => $gate_id))->row();
if (!$gate) {
show_404();
}
// get payment gateway settings
$gate_conf = unserialize($gate->settings);
// load payment libs
include_once APPPATH . 'libraries/payment/PaymentGateway.php';
// which payment system to use?
if ($gate->name == 'paypal') {
// Include the paypal library
include_once APPPATH . 'libraries/payment/Paypal.php';
// Create an instance of the paypal library
$my_paypal = new Paypal();
// Specify your paypal email
$my_paypal->add_field('business', $gate_conf['email']);
// Specify the currency
$my_paypal->add_field('currency_code', $gate_conf['currency']);
// Specify the url where paypal will send the user on success/failure
$my_paypal->add_field('return', site_url('user/pay_complete'));
$my_paypal->add_field('cancel_return', site_url('user/pay_cancel'));
// Specify the url where paypal will send the IPN
$my_paypal->add_field('notify_url', site_url('payment/ipn/paypal'));
// Specify the product information
$my_paypal->add_field('item_name', $this->startup->site_config->sitename . ' ' . lang('Account Registration'));
$my_paypal->add_field('amount', $group->price);
$my_paypal->add_field('item_number', rand(1, 1000) . '-' . $user->id);
// Specify any custom value
$my_paypal->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$my_paypal->enable_test_mode();
}
// Let's start the train!
$data['form'] = $my_paypal->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.'));
} else {
if ($gate->name == 'authorize') {
// Include the paypal library
include_once APPPATH . 'libraries/payment/Authorize.php';
// Create an instance of the authorize.net library
$my_authorize = new Authorize();
// Specify your authorize.net login and secret
$my_authorize->set_user_info($gate_conf['login'], $gate_conf['secret']);
// Specify the url where authorize.net will send the user on success/failure
$my_authorize->add_field('x_Receipt_Link_URL', site_url('user/pay_complete'));
// Specify the url where authorize.net will send the IPN
$my_authorize->add_field('x_Relay_URL', site_url('payment/ipn/authorize'));
// Specify the product information
$my_authorize->add_field('x_Description', $this->startup->site_config->sitename . ' ' . lang('Account Registration'));
$my_authorize->add_field('x_Amount', $group->price);
$my_authorize->add_field('x_Invoice_num', rand(1, 1000) . '-' . $user->id);
$my_authorize->add_field('x_Cust_ID', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$my_authorize->enable_test_mode();
}
// Let's start the train!
$data['form'] = $my_authorize->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.'));
} else {
if ($gate->name = '2co') {
// Include the paypal library
include_once APPPATH . 'libraries/payment/TwoCo.php';
// Create an instance of the authorize.net library
$my2_co = new TwoCo();
// Specify your 2CheckOut vendor id
$my2_co->add_field('sid', $gate_conf['vendor_id']);
// Specify the order information
$my2_co->add_field('cart_order_id', rand(1, 1000) . '-' . $user->id);
$my2_co->add_field('total', $group->price);
// Specify the url where authorize.net will send the IPN
$my2_co->add_field('x_Receipt_Link_URL', site_url('payment/ipn/two_checkout'));
$my2_co->add_field('tco_currency', $gate_conf['currency']);
$my2_co->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$my2_co->enable_test_mode();
}
//.........这里部分代码省略.........
示例4: Paypal
end */
$_input_charset = 'utf-8';
//$service = 'create_direct_pay_by_user'; // what does it mean??
$partner = $INI['paypal']['mid'];
$security_code = $INI['paypal']['sec'];
$seller_acc = $INI['paypal']['acc'];
$sign_type = 'MD5';
$out_trade_no = "paypal-{$order['id']}-{$randno}";
$return_url = $INI['system']['wwwprefix'] . '/order/paypal/return.php';
$notify_url = $INI['system']['wwwprefix'] . '/order/paypal/giftnotify.php';
$show_url = $INI['system']['wwwprefix'] . "/gift_cards/index.php";
$subject = preg_replace('/[\\r\\n\\s]+/', '', strip_tags('Gift_Card'));
$body = $show_url;
$quantity = 1;
$paypal = new Paypal();
$paypal->add_field('business', $seller_acc);
$paypal->add_field('notify_url', $notify_url);
$paypal->add_field('return', $return_url);
//$paypal->add_field('cancel_return', $show_url);
//$paypal->add_field('transaction_subject', 'Paypal Transaction - test');
$paypal->add_field('item_name', $subject);
$paypal->add_field('item_number', $out_trade_no);
$paypal->add_field('currency_code', $currency);
$paypal->add_field('amount', $total_money);
$paypal->add_field('txn_id', $out_trade_no);
$sign = $paypal->submit_verify();
include template('gift_pay');
} else {
if ($order['paytype'] == 'cash') {
include template('gift_pay');
} else {
示例5: paymentPaypal
function paymentPaypal($order_id, $amount = 0)
{
global $_ARRAYLANG;
if (isset($_GET['result'])) {
$result = $_GET['result'];
switch ($result) {
case -1:
// Go validate PayPal IPN
$this->paymentPaypalIpn($order_id, $amount);
die;
case 0:
// Payment failed
break;
case 1:
// The payment has been completed.
// The notification with result == -1 will update the order.
// This case only redirects the customer to the list page with
// an appropriate message according to the status of the order.
$order_state = self::GetOrderValue('order_state', $order_id);
if ($order_state == 1) {
$product_id = self::GetOrderValue('order_product', $order_id);
return self::getSuccessMessage($product_id);
} elseif ($order_state == 0) {
if (self::GetSettings('set_paypal_ipn') == 1) {
return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_IPN_PENDING'] . "\");\n";
}
}
break;
case 2:
// Payment was cancelled
return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_CANCEL'] . "\");\n";
}
return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_NOT_VALID'] . "\");\n";
}
$product_id = self::getOrderValue('order_product', $order_id);
if (empty($product_id)) {
return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_UPDATING_ORDER'] . '");' . "\n";
}
// Prepare payment
$paypalUriIpn = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=-1";
$paypalUriNok = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=0";
$paypalUriOk = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=1";
$objPaypal = new Paypal();
$product_id = self::GetOrderValue('order_product', $order_id);
if (empty($product_id)) {
return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_PROCESSING_ORDER'] . "\");\n";
}
$product_name = self::GetProduktValue('product_name', $product_id);
$product_amount = self::GetProduktValue('product_price', $product_id);
$quantity = self::GetProduktValue('product_per_day', $product_id) == 'yes' ? intval($_REQUEST['contactFormField_Quantity']) : 1;
if ($product_amount <= 0) {
return '';
}
$objPaypal->add_field('business', self::GetProduktValue('product_paypal_sandbox', $product_id));
$objPaypal->add_field('return', $paypalUriOk);
$objPaypal->add_field('cancel_return', $paypalUriNok);
$objPaypal->add_field('notify_url', $paypalUriIpn);
$objPaypal->add_field('item_name', $product_name);
$objPaypal->add_field('amount', $product_amount);
$objPaypal->add_field('quantity', $quantity);
$objPaypal->add_field('currency_code', self::GetProduktValue('product_paypal_currency', $product_id));
$objPaypal->add_field('custom', $order_id);
//die();
$objPaypal->submit_paypal_post();
die;
}