本文整理汇总了PHP中Paypal::addField方法的典型用法代码示例。如果您正苦于以下问题:PHP Paypal::addField方法的具体用法?PHP Paypal::addField怎么用?PHP Paypal::addField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paypal
的用法示例。
在下文中一共展示了Paypal::addField方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
function indexAction()
{
//[TODO] must check if orderId has been paid before to avoid double charge, if somehow user can access directly to payment controller.
$this->_checkAuth();
$orderId = $this->_request->getParam('orderId');
$this->_orderIdNumber = $orderId;
if (empty($orderId)) {
echo "kosong";
die;
}
$modelAppStore = new App_Model_Store();
if (!$modelAppStore->isUserOwnOrder($this->_userDetailInfo->guid, $orderId)) {
//forward to error page
$this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'notowner'));
die;
}
if ($modelAppStore->isOrderPaid($orderId)) {
//forward to error page
$this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'orderalreadypaid'));
die;
}
$tblOrder = new Pandamp_Modules_Payment_Order_Model_Order();
$items = $tblOrder->getOrderDetail($orderId);
$tmpMethod = $this->_request->getParam('method');
if (!empty($tmpMethod)) {
$items[0]['paymentMethod'] = $tmpMethod;
}
switch ($items[0]['paymentMethod']) {
case 'nsiapay':
require_once 'PaymentGateway/Nsiapay.php';
// include the class file
$paymentObject = new Nsiapay();
// initiate an instance of the class
if ($this->_testMode) {
$paymentObject->enableTestMode();
}
$paymentObject->addField('TYPE', "IMMEDIATE");
for ($iCart = 0; $iCart < count($items); $iCart++) {
$i = $iCart + 1;
$basket[] = $items[$iCart]['documentName'] . "," . $items[$iCart]['price'] . ".00" . "," . $items[$iCart]['qty'] . "," . $items[$iCart]['finalPrice'] . ".00";
$subTotal += $items[$iCart]['price'] * $items[$iCart]['qty'];
}
$ca = implode(";", $basket);
$merchantId = "000100090000028";
$paymentObject->addField("BASKET", $ca);
$paymentObject->addField("MERCHANTID", $merchantId);
$paymentObject->addField("CHAINNUM", "NA");
$paymentObject->addField("TRANSIDMERCHANT", $items[0]['invoiceNumber']);
$paymentObject->addField("AMOUNT", $subTotal);
$paymentObject->addField("CURRENCY", "360");
$paymentObject->addField("PurchaseCurrency", "360");
$paymentObject->addField("acquirerBIN", "360");
$paymentObject->addField("password", "123456");
$paymentObject->addField("URL", ROOT_URL);
$paymentObject->addField("MALLID", "199");
$paymentObject->addField("SESSIONID", Zend_Session::getId());
$sha1 = sha1($subTotal . ".00" . $merchantId . "08iIWbWvO16w" . $items[0]['invoiceNumber']);
// echo $subTotal.".00".$merchantId."08iIWbWvO16w".$items[0]['invoiceNumber']."<br>";
// echo $sha1;die;
$paymentObject->addField("WORDS", $sha1);
$ivnum = $this->updateInvoiceMethod($orderId, 'nsiapay', 1, 0, 'paid with nsiapay method');
$data['orderId'] = $orderId;
$data['starttime'] = date('YmdHis');
$data['amount'] = $subTotal;
$data['transidmerchant'] = $items[0]['invoiceNumber'];
$tblNsiapay = new Pandamp_Modules_Payment_Nsiapay_Model_Nsiapay();
$tblNsiapay->insert($data);
$nhis['orderId'] = $items[0]['invoiceNumber'];
$nhis['paymentStatus'] = 'requested';
$nhis['dateAdded'] = date('YmdHis');
$tblNhis = new Pandamp_Modules_Payment_NsiapayHistory_Model_NsiapayHistory();
$tblNhis->insert($nhis);
// $paymentObject->dumpFields();
$this->_helper->layout->disableLayout();
$paymentObject->submitPayment();
break;
case 'paypal':
/*
- Detect Multi Item and set accordingly
- Logic for test mode
*/
require_once 'PaymentGateway/Paypal.php';
// include the class file
$paymentObject = new Paypal();
// initiate an instance of the class
if ($this->_testMode) {
$paymentObject->addField('business', $this->_paymentVars['paypalTestBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalTestSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalTestCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalTestNotifyUrl']);
$paymentObject->enableTestMode();
} else {
$paymentObject->addField('business', $this->_paymentVars['paypalBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalNotifyUrl']);
}
for ($iCart = 0; $iCart < count($items); $iCart++) {
$i = $iCart + 1;
$paymentObject->addField("item_number_" . $i, $items[$iCart]['itemId']);
//.........这里部分代码省略.........
示例2: pay_new
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
$myPaypal = new Paypal();
// Specify your paypal email
$myPaypal->addField('business', $gate_conf['email']);
// Specify the currency
$myPaypal->addField('currency_code', $gate_conf['currency']);
// Specify the url where paypal will send the user on success/failure
$myPaypal->addField('return', site_url('user/pay_complete'));
$myPaypal->addField('cancel_return', site_url('user/pay_cancel'));
// Specify the url where paypal will send the IPN
$myPaypal->addField('notify_url', site_url('payment/ipn/paypal'));
// Specify the product information
$myPaypal->addField('item_name', $this->startup->site_config['sitename'] . ' ' . $this->lang->line('user_controller_14'));
$myPaypal->addField('amount', $group->price);
$myPaypal->addField('item_number', rand(1, 1000) . '-' . $user->id);
// Specify any custom value
$myPaypal->addField('custom', base64_encode(serialize(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$myPaypal->enableTestMode();
}
// Let's start the train!
$data['form'] = $myPaypal->submitPayment($this->lang->line('user_controller_paypal_submitpayment'));
} else {
if ($gate->name == 'authorize') {
// Include the paypal library
include_once APPPATH . 'libraries/payment/Authorize.php';
// Create an instance of the authorize.net library
$myAuthorize = new Authorize();
// Specify your authorize.net login and secret
$myAuthorize->setUserInfo($gate_conf['login'], $gate_conf['secret']);
// Specify the url where authorize.net will send the user on success/failure
$myAuthorize->addField('x_Receipt_Link_URL', site_url('user/pay_complete'));
// Specify the url where authorize.net will send the IPN
$myAuthorize->addField('x_Relay_URL', site_url('payment/ipn/authorize'));
// Specify the product information
$myAuthorize->addField('x_Description', $this->startup->site_config['sitename'] . ' ' . $this->lang->line('user_controller_14'));
$myAuthorize->addField('x_Amount', $group->price);
$myAuthorize->addField('x_Invoice_num', rand(1, 1000) . '-' . $user->id);
$myAuthorize->addField('x_Cust_ID', base64_encode(serialize(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$myAuthorize->enableTestMode();
}
// Let's start the train!
$data['form'] = $myAuthorize->submitPayment($this->lang->line('user_controller_paypal_submitpayment'));
} else {
if ($gate->name = '2co') {
// Include the paypal library
include_once APPPATH . 'libraries/payment/TwoCo.php';
// Create an instance of the authorize.net library
$my2CO = new TwoCo();
// Specify your 2CheckOut vendor id
$my2CO->addField('sid', $gate_conf['vendor_id']);
// Specify the order information
$my2CO->addField('cart_order_id', rand(1, 1000) . '-' . $user->id);
$my2CO->addField('total', $group->price);
// Specify the url where authorize.net will send the IPN
$my2CO->addField('x_Receipt_Link_URL', site_url('payment/ipn/two_checkout'));
$my2CO->addField('tco_currency', $gate_conf['currency']);
$my2CO->addField('custom', base64_encode(serialize(array('user_id' => $user->id, 'type' => 'reg'))));
// Enable test mode if needed
if (defined('XUDEBUG') and XUDEBUG == true) {
$my2CO->enableTestMode();
}
// Let's start the train!
$data['form'] = $my2CO->submitPayment($this->lang->line('user_controller_paypal_submitpayment'));
}
}
}
$this->load->view($this->startup->skin . '/header', array('headerTitle' => $this->lang->line('user_controller_15')));
$this->load->view($this->startup->skin . '/user/register/pay_new', array('ammount' => $group, 'user' => $id, 'form' => $data['form']));
$this->load->view($this->startup->skin . '/footer');
}
示例3: Paypal
<?php
// Include the paypal library
include_once 'Paypal.php';
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Specify your paypal email
$myPaypal->addField('business', 'YOUR_PAYPAL_EMAIL');
// Specify the currency
$myPaypal->addField('currency_code', 'USD');
// Specify the url where paypal will send the user on success/failure
$myPaypal->addField('return', 'http://YOUR_HOST/payment/paypal_success.php');
$myPaypal->addField('cancel_return', 'http://YOUR_HOST/payment/paypal_failure.php');
// Specify the url where paypal will send the IPN
$myPaypal->addField('notify_url', 'http://YOUR_HOST/payment/paypal_ipn.php');
// Specify the product information
$myPaypal->addField('item_name', 'T-Shirt');
$myPaypal->addField('amount', '9.99');
$myPaypal->addField('item_number', '001');
// Specify any custom value
$myPaypal->addField('custom', 'muri-khao');
// Enable test mode if needed
$myPaypal->enableTestMode();
// Let's start the train!
$myPaypal->submitPayment();
示例4: indexAction
public function indexAction()
{
//[TODO] must check if orderId has been paid before to avoid double charge, if somehow user can access directly to payment controller.
$this->_checkAuth();
$orderId = $this->_request->getParam('orderId');
$this->_orderIdNumber = $orderId;
if (empty($orderId)) {
echo "kosong";
die;
}
$modelAppStore = new App_Model_Store();
if (!$modelAppStore->isUserOwnOrder($this->_userDetailInfo->guid, $orderId)) {
//forward to error page
$this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'notowner'));
die;
}
if ($modelAppStore->isOrderPaid($orderId)) {
//forward to error page
$this->_helper->redirector->gotoSimple('error', 'store', 'site', array('view' => 'orderalreadypaid'));
die;
}
$tblOrder = new Kutu_Core_Orm_Table_Order();
$items = $tblOrder->getOrderDetail($orderId);
//var_dump($items); die();
$tmpMethod = $this->_request->getParam('method');
if (!empty($tmpMethod)) {
$items[0]['paymentMethod'] = $tmpMethod;
}
switch ($items[0]['paymentMethod']) {
case 'paypal':
/*
- Detect Multi Item and set accordingly
- Logic for test mode
*/
require_once 'PaymentGateway/Paypal.php';
// include the class file
$paymentObject = new Paypal();
// initiate an instance of the class
if ($this->_testMode) {
$paymentObject->addField('business', $this->_paymentVars['paypalTestBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalTestSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalTestCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalTestNotifyUrl']);
$paymentObject->enableTestMode();
} else {
$paymentObject->addField('business', $this->_paymentVars['paypalBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalNotifyUrl']);
}
for ($iCart = 0; $iCart < count($items); $iCart++) {
$i = $iCart + 1;
$paymentObject->addField("item_number_" . $i, $items[$iCart]['itemId']);
$paymentObject->addField("item_name_" . $i, $items[$iCart]['documentName']);
//nama barang [documentName]
$paymentObject->addField("amount_" . $i, number_format($items[$iCart]['price'], 2, '.', ''));
//harga satuan [price]
$paymentObject->addField("quantity_" . $i, $items[$iCart]['qty']);
//jumlah barang [qty]\
}
$paymentObject->addField('tax_cart', $items[0]['orderTax']);
$paymentObject->addField('currency_code', $this->_defaultCurrency);
//$paymentObject->addField('custom',$_SESSION['_orderIdNumber']);
$paymentObject->addField('custom', $orderId);
$ivnum = $this->updateInvoiceMethod($orderId, 'paypal', 1, 0, 'paid with paypal method');
//$paymentObject->dumpFields();
$mod = new App_Model_Store_Mailer();
$mod->sendInvoiceToUser($orderId, 1);
$paymentObject->submitPayment();
//setting payment and status as pending (1), notify = 0, notes = 'paid with...'
break;
case 'manual':
case 'bank':
/*
1. update order status
2. redirect to instruction page
*/
//setting payment and status as pending (1), notify = 0, notes = 'paid with...'
$this->updateInvoiceMethod($orderId, 'bank', 1, 0, 'paid with manual method');
$mod = new App_Model_Store_Mailer();
$mod->sendBankInvoiceToUser($orderId, 1);
// HAP: i think we should send this notification when user were on page "Complete Order" and after confirmation made by user is approved;
//$this->Mailer($orderId, 'admin-order', 'admin');
//$this->Mailer($orderId, 'user-order', 'user');
$this->_helper->redirector('instruction', 'store_payment', 'site', array('orderId' => $orderId));
break;
case 'postpaid':
/*
1. validate POSTPAID status of the client
2. validate CREDIT LIMIT (per user) with current Outstanding Bill + New Bill
3. update order status
4. redirect to success or failed
*/
/*
* if userid isn't listed as postpaid user will be redirected
*/
if (!$this->_userInfo->isPostPaid) {
echo 'Not Post Paid Customer';
//$paymentObject->submitPayment();
return $this->_helper->redirector('notpostpaid');
//.........这里部分代码省略.........
示例5: start_ipn
public function start_ipn($data, $config)
{
$myPaypal = new Paypal();
$myPaypal->addField('cmd', '_cart');
$myPaypal->addField('charset', 'utf-8');
// Specify your paypal email
$myPaypal->addField('business', $config["email"]);
$myPaypal->addField('upload', 1);
if (isset($config["image_url"]) && $config["image_url"] != '') {
$myPaypal->addField('image_url', $config["image_url"]);
}
if (isset($config["cpp_header_image"]) && $config["cpp_header_image"] != '') {
$myPaypal->addField('cpp_header_image', $config["cpp_header_image"]);
}
// Specify the currency
$myPaypal->addField('currency_code', $this->_config["currency"]);
// Specify the url where paypal will send the user on success/failure
$myPaypal->addField('return', $this->EE->functions->create_url($config["thank_you_url"]));
$myPaypal->addField('cancel_return', $data["cancel_return"] . '&token=' . $data["transaction_id"]);
// Specify the url where paypal will send the IPN
$myPaypal->addField('notify_url', $data["notify_url"]);
$i = 1;
foreach ($data["cart"]["items"] as $items) {
$myPaypal->addField('item_name_' . $i, $items["title"]);
$myPaypal->addField('amount_' . $i, $this->_currency_round($items["price"]));
$myPaypal->addField('item_number_' . $i, $items["product_id"]);
$myPaypal->addField('quantity_' . $i, $items["quantity"]);
$i++;
}
// Add shipping address info
#$myPaypal->addField('address_override',1);
$myPaypal->addField('address1', $data["br_shipping_address1"]);
$myPaypal->addField('address2', $data["br_shipping_address2"]);
$myPaypal->addField('city', $data["br_shipping_city"]);
$myPaypal->addField('country', $data["br_shipping_country"]);
$myPaypal->addField('email', $data["email"]);
$myPaypal->addField('first_name', $data["br_shipping_fname"]);
$myPaypal->addField('last_name', $data["br_shipping_lname"]);
$myPaypal->addField('state', $data["br_shipping_state"]);
$myPaypal->addField('zip', $data["br_shipping_zip"]);
// Specify the shipping / discount / tax
$myPaypal->addField('no_shipping', 2);
$myPaypal->addField('handling_cart', $data["cart_shipping"]);
$myPaypal->addField('discount_amount_cart', $data["cart_discount"]);
$myPaypal->addField('tax_cart', $data["cart_tax"]);
// Specify any custom value
$myPaypal->addField('no_note', 1);
$myPaypal->addField('custom', $data["transaction_id"]);
if ($config["sandbox"] == "TRUE") {
$myPaypal->enableTestMode();
}
// Let's start the train!
$myPaypal->submitPayment();
}
示例6: indexAction
public function indexAction()
{
/*
1. Calculate Tax, Save Order and Order Detail
2. Set Payment Method
3. Submit Variable to Payment Gateway or Manual
*/
// Process and order...
$this->_checkAuth();
$cart = $this->completeItem();
$methode = $this->_request->getParam('paymentMethod');
if (empty($_SESSION['_orderIdNumber'])) {
$this->saveOrder($cart, $methode);
} else {
$this->_orderIdNumber = $_SESSION['_orderIdNumber'];
if ($methode == 'paypal') {
$this->updateOrder($cart, $methode, $this->_orderIdNumber);
}
}
$paymentMethod = $this->_request->getParam('type');
$this->_paymentMethod = $paymentMethod;
switch ($this->_paymentMethod) {
case 'paypal':
/*
- Detect Multi Item and set accordingly
- Logic for test mode
*/
require_once 'PaymentGateway/Paypal.php';
// include the class file
$paymentObject = new Paypal();
// initiate an instance of the class
if ($this->_testMode) {
$paymentObject->addField('business', $this->_paymentVars['paypalTestBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalTestSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalTestCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalTestNotifyUrl']);
$paymentObject->enableTestMode();
} else {
$paymentObject->addField('business', $this->_paymentVars['paypalBusiness']);
$paymentObject->addField('return', $this->_paymentVars['paypalSuccessUrl']);
$paymentObject->addField('cancel_return', $this->_paymentVars['paypalCancelUrl']);
$paymentObject->addField('notify_url', $this->_paymentVars['paypalNotifyUrl']);
}
$cart = $this->completeItem();
for ($iCart = 0; $iCart < count($cart['items']); $iCart++) {
$i = $iCart + 1;
$paymentObject->addField("item_number_" . $i, $cart['items'][$iCart]['itemId']);
$paymentObject->addField("item_name_" . $i, $cart['items'][$iCart]['item_name']);
//nama barang [documentName]
$paymentObject->addField("amount_" . $i, $cart['items'][$iCart]['itemPrice']);
//harga satuan [price]
$paymentObject->addField("quantity_" . $i, $cart['items'][$iCart]['qty']);
//jumlah barang [qty]\
}
$paymentObject->addField('tax_cart', $cart['taxAmount']);
$paymentObject->addField('currency_code', $this->_defaultCurrency);
//$paymentObject->addField('custom',$_SESSION['_orderIdNumber']);
$paymentObject->addField('custom', $this->_orderIdNumber);
$ivnum = $this->updateInvoiceMethod('paypal', 1, 0, 'paid with paypal method');
//$paymentObject->dumpFields();
$paymentObject->submitPayment();
//setting payment and status as pending (1), notify = 0, notes = 'paid with...'
break;
case '2co':
/*
require_once('PaymentGateway/TwoCo.php');
$paymentObject = new TwoCo;
$paymentAccount=$this->paymentVars->twoco->business;
$paymentNotifyUrl=$this->paymentVars->returnUrl;
$paymentObject->addField('sid', 'YOUR_VENDOR_ID');
$paymentObject->addField('x_Receipt_Link_URL', 'http://YOUR_HOST/payment/twoco_ipn.php');
$paymentObject->addField('tco_currency', 'USD');
$paymentObject->addField('cart_order_id', rand(1, 100));
$paymentObject->addField('total', '9.99');
// Specify the url where authorize.net will send the IPN
$paymentObject->addField('custom', 'muri');
// Enable test mode if needed
if($this->testMode)$paymentObject->enableTestMode();
$paymentObject->dumpFields();
// Let's start the train!
$paymentObject->submitPayment();
*/
break;
case 'postpaid':
/*
1. validate POSTPAID status of the client
2. validate CREDIT LIMIT (per user) with current Outstanding Bill + New Bill
3. update order status
4. redirect to success or failed
*/
/*
* if userid isn't listed as postpaid user will be redirected
*/
if (!$this->_userInfo->isPostPaid) {
echo 'Not Post Paid Customer';
//$paymentObject->submitPayment();
return $this->_helper->redirector('notpostpaid');
//.........这里部分代码省略.........
示例7: espresso_display_paypal
function espresso_display_paypal($payment_data)
{
extract($payment_data);
global $wpdb;
include_once 'Paypal.php';
$myPaypal = new Paypal();
echo '<!-- Event Espresso PayPal Gateway Version ' . $myPaypal->gateway_version . '-->';
global $org_options;
$paypal_settings = get_option('event_espresso_paypal_settings');
$paypal_id = empty($paypal_settings['paypal_id']) ? '' : $paypal_settings['paypal_id'];
$paypal_cur = empty($paypal_settings['currency_format']) ? '' : $paypal_settings['currency_format'];
$no_shipping = isset($paypal_settings['no_shipping']) ? $paypal_settings['no_shipping'] : '0';
$use_sandbox = $paypal_settings['use_sandbox'];
if ($use_sandbox) {
$myPaypal->enableTestMode();
}
$myPaypal->addField('business', $paypal_id);
$myPaypal->addField('return', home_url() . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id);
$myPaypal->addField('cancel_return', home_url() . '/?page_id=' . $org_options['cancel_return']);
$myPaypal->addField('notify_url', home_url() . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment');
$event_name = $wpdb->get_var('SELECT event_name FROM ' . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");
$myPaypal->addField('cmd', '_cart');
$myPaypal->addField('upload', '1');
$i = 1;
$sql = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id='" . $attendee_id . "'";
$session_id = $wpdb->get_var($sql);
$sql = "SELECT amount_pd FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session='" . $session_id . "'";
$amount_pds = $wpdb->get_col($sql);
$cost = 0;
foreach ($amount_pds as $amount_pd) {
$cost += $amount_pd;
}
$myPaypal->addField('item_name_' . $i, $event_name);
$myPaypal->addField('amount_' . $i, $cost);
$myPaypal->addField('quantity_' . $i, '1');
$myPaypal->addField('currency_code', $paypal_cur);
$myPaypal->addField('image_url', empty($paypal_settings['image_url']) ? '' : $paypal_settings['image_url']);
$myPaypal->addField('no_shipping ', $no_shipping);
$myPaypal->addField('first_name', $fname);
$myPaypal->addField('last_name', $lname);
$myPaypal->addField('email', $attendee_email);
$myPaypal->addField('address1', $address);
$myPaypal->addField('city', $city);
$myPaypal->addField('state', $state);
$myPaypal->addField('zip', $zip);
if (!empty($paypal_settings['bypass_payment_page']) && $paypal_settings['bypass_payment_page'] == 'Y') {
$myPaypal->submitPayment();
} else {
if (empty($paypal_settings['button_url'])) {
if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "/paypal/btn_stdCheckout2.gif")) {
$button_url = EVENT_ESPRESSO_GATEWAY_DIR . "/paypal/btn_stdCheckout2.gif";
} else {
$button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/paypal/btn_stdCheckout2.gif";
}
} elseif (file_exists($paypal_settings['button_url'])) {
$button_url = $paypal_settings['button_url'];
} else {
$button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/paypal/btn_stdCheckout2.gif";
}
$myPaypal->submitButton($button_url, 'paypal');
}
if ($use_sandbox) {
echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Paypal Debug Mode Is Turned On', 'event_espresso') . '</h3>';
$myPaypal->dump_fields();
}
}
示例8: Paypal
$this->lastError = "IPN Validation Failed . {$urlParsed['path']} : {$urlParsed['host']}";
$this->logResults(false);
return false;
}
}
}
$url1 = parse_url($place_order['url']);
if (isset($url1["query"]) and $url1["query"] != '') {
$qsign = '&';
} else {
$qsign = '?';
}
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Specify your paypal email
$myPaypal->addField('business', trim(get_option('paypalexpress_username', 'payments')));
$currencies_list_paypal = mw()->shop_manager->currency_get_for_paypal();
$currencyCode = $place_order['currency'];
$amount = $place_order['amount'];
$place_order['payment_amount'] = $amount;
$place_order['payment_shipping'] = $place_order['shipping'];
if (!in_array(strtoupper($place_order['currency']), $currencies_list_paypal)) {
$payment_currency = get_option('payment_currency', 'payments');
$payment_currency_rate = get_option('payment_currency_rate', 'payments');
if ($payment_currency_rate != false) {
$payment_currency_rate = str_replace(',', '.', $payment_currency_rate);
$payment_currency_rate = floatval($payment_currency_rate);
}
if ($payment_currency_rate != 0.0) {
$currencyCode = $payment_currency;
$amount = $amount * $payment_currency_rate;
示例9: paypal_form
/**
* Shows the paypal button after new post
*
* @param type $type
* @param type $post_id
* @param type $pack_id
* @param type $display
* @return type
*/
public function paypal_form($type = 'post', $post_id = 0, $pack_id = 0, $display = false)
{
// Include the paypal library
include_once dirname(__FILE__) . '/lib/payment/Paypal.php';
//var_dump( $type, $post_id, $pack_id ); exit;
$email = get_option('wpuf_sub_paypal_mail');
$curreny = get_option('wpuf_sub_currency');
$amount = 0;
if ($type == 'post') {
$post = get_post($post_id);
$amount = get_option('wpuf_sub_amount');
$item_name = $post->post_title;
$item_number = get_post_meta($post_id, 'wpuf_order_id', true);
$custom = 'post';
$cbt = sprintf(__('Click here to complete the pack on %s', 'wpuf'), get_bloginfo('name'));
}
if ($type == 'pack') {
$pack = $this->get_subscription($pack_id);
if ($pack) {
$amount = $pack->cost;
$item_name = $pack->name;
$item_number = $pack->id;
$custom = 'pack';
$cbt = sprintf(__('Click here to complete the pack on %s', 'wpuf'), get_bloginfo('name'));
}
}
// Create an instance of the paypal library
$myPaypal = new Paypal();
// Specify your paypal email
$myPaypal->addField('business', $email);
// Specify the currency
$myPaypal->addField('currency_code', $curreny);
// Specify the url where paypal will send the user on success/failure
$myPaypal->addField('return', get_bloginfo('home') . '/?action=wpuf_pay_success');
$myPaypal->addField('cancel_return', get_bloginfo('home'));
// Specify the url where paypal will send the IPN
$myPaypal->addField('notify_url', get_bloginfo('home') . '/?action=wpuf_pay_success');
// Specify the product information
$myPaypal->addField('item_name', $item_name);
$myPaypal->addField('amount', $amount);
$myPaypal->addField('item_number', $item_number);
// Specify any custom value
$myPaypal->addField('custom', $custom);
$myPaypal->addField('cbt', $cbt);
// Enable test mode if needed
if (get_option('wpuf_sub_paypal_sandbox') == 'yes') {
$myPaypal->enableTestMode();
}
// Let's start the train!
$form = $myPaypal->submitPayment();
return $form;
}
示例10: submit_to_paypal
function submit_to_paypal()
{
$eStore_default_currency = get_option('cart_payment_currency');
$eStore_return_url = get_option('cart_return_from_paypal_url');
$eStore_sandbox_enabled = get_option('eStore_cart_enable_sandbox');
if (!empty($eStore_default_currency)) {
$paypal_currency = $eStore_default_currency;
} else {
$paypal_currency = 'USD';
}
$email = get_option('cart_paypal_email');
$myPaypal = new Paypal();
$myPaypal->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr';
//PAYPAL_LIVE_URL
$myPaypal->addField('charset', "utf-8");
$myPaypal->addField('business', $email);
$paypal_currency = apply_filters('eStore_change_curr_code_before_payment_filter', $paypal_currency);
$myPaypal->addField('currency_code', $paypal_currency);
$cancel_url = get_option('cart_cancel_from_paypal_url');
if (!empty($cancel_url)) {
$myPaypal->addField('cancel_return', $cancel_url);
}
if (get_option('eStore_auto_product_delivery') != '') {
if (WP_ESTORE_ENABLE_NEW_CHECKOUT_REDIRECTION === '1') {
$notify = WP_ESTORE_SITE_HOME_URL . '/?estore_pp_ipn=process';
} else {
$notify = WP_ESTORE_URL . '/paypal.php';
}
$myPaypal->addField('notify_url', $notify);
}
// =======================
global $wpdb;
$products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
$weight = 0;
$count = 1;
$all_items_digital = true;
foreach ($_SESSION['eStore_cart'] as $item) {
$rounded_price = round($item['price'], 2);
$rounded_price = apply_filters('eStore_change_price_before_payment_filter', $rounded_price);
$myPaypal->addField("item_name_{$count}", htmlspecialchars($item['name']));
$myPaypal->addField("amount_{$count}", $rounded_price);
$myPaypal->addField("quantity_{$count}", $item['quantity']);
$myPaypal->addField("item_number_{$count}", $item['item_number']);
//Check to see if this is a tax free item and set the tax accordingly so that the profile based PayPal tax can work nicely
if ($item['tax'] == "0") {
$myPaypal->addField("tax_{$count}", $item['tax']);
}
$id = $item['item_number'];
$ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT);
if (!empty($ret_product->weight)) {
$weight += $ret_product->weight * $item['quantity'];
}
if (empty($item['digital_flag'])) {
$all_items_digital = false;
}
$count++;
}
$total_items_in_cart = count($_SESSION['eStore_cart']);
if ($total_items_in_cart == 1 && !empty($ret_product->return_url)) {
$myPaypal->addField('return', $ret_product->return_url);
} else {
if (!empty($eStore_return_url)) {
$myPaypal->addField('return', $eStore_return_url);
}
}
if (!get_option('eStore_paypal_profile_shipping')) {
//Not Using paypal's profile based shipping so include shipping otherwise ignore shipping here as it will be calculated on paypal's site
$shipping = round($_SESSION['eStore_cart_postage_cost'], 2);
if (!empty($shipping)) {
$shipping = apply_filters('eStore_change_shipping_before_payment_filter', $shipping);
//change tax amount before submitting if converting currency to another type
$myPaypal->addField('no_shipping', '2');
$myPaypal->addField('handling_cart', $shipping);
//$myPaypal->addField('shipping_1', $shipping);
} else {
//If you do not want to collect address for checkout that has no shipping cost then uncomment the following line of code.
//$myPaypal->addField('no_shipping', '1');
}
} else {
//Include the weight for profile based shipping calc
$myPaypal->addField('weight_cart', round($weight, 2));
$myPaypal->addField('weight_unit', 'lbs');
if ($all_items_digital) {
//All the items in the cart are digital items so set the shipping flag to 0 so no shipping is charged
$total_items = count($_SESSION['eStore_cart']);
for ($i = 1; $i <= $total_items; $i++) {
$myPaypal->addField('shipping_' . $i, '0');
}
} else {
if (isset($_SESSION['eStore_cart_postage_cost']) && $_SESSION['eStore_cart_postage_cost'] == 0) {
//Free shipping discount applied. send 0 shipping to override profile based shipping
if (empty($weight)) {
//Add $0 shipping override
$myPaypal->addField('shipping_1', '0');
}
}
}
}
if (!empty($_SESSION['eStore_cart_total_tax'])) {
$cart_total_tax = round($_SESSION['eStore_cart_total_tax'], 2);
//.........这里部分代码省略.........