本文整理汇总了PHP中Cart::find_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::find_by_id方法的具体用法?PHP Cart::find_by_id怎么用?PHP Cart::find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cart
的用法示例。
在下文中一共展示了Cart::find_by_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_cart
protected function load_cart($id = null)
{
if (!$id) {
$id = $this->GetData('id');
}
$obj = Cart::find_by_id($id);
if (!$obj) {
throw new Error404('Unable to find Cart');
}
return $obj;
}
示例2: show
public function show($id = null)
{
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
if (!$id) {
Error404();
}
$payment = PaymentTransaction::find_by_id($id);
if (!$payment) {
Error404();
}
$cart = Cart::find_by_id($payment->cart_id);
if ($cart) {
$user = User::find_by_id($cart->user_id);
$this->assign("user", $user);
$this->assign("cart", $cart);
}
$this->assign("payment", $payment);
$this->title = "Payment {$payment->id}";
$this->render("paymenttransaction/show.tpl");
}
示例3: processPayment
/**
* Processes an IPN request.
*
* @param type $postData HTTP POST data from the request
* @return string Any output for the notification page
*/
public static function processPayment($gateway, $postData)
{
$responseData = array_merge(array('cmd' => '_notify-validate'), $postData);
$qs = http_build_query($responseData);
$curl = curl_init($gateway->getSetting('endpoint'));
global $config;
if ($config['dev'] or true) {
// Paypal sandbox certificate is apparently invalid
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
}
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $qs);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
if (!isset($postData['transaction_subject'])) {
// No transaction subject
}
$ref = explode("-", $postData['custom']);
if (count($ref) < 2) {
return;
}
$type = $ref[0];
$id = $ref[1];
if ($type != 'cart') {
// Not a cart, nothing to do here
return;
}
$id = mysql_real_escape_string($id);
$cart = Cart::find_by_id($id);
$payment = new PaymentTransaction();
$payment->processResponse = $postData;
$payment->paymentgateway_id = $gateway->id;
$payment->amount = $postData['mc_gross'];
$payment->externalid = $postData['txn_id'];
$payment->status = 'ptsFailed';
$payment->sender = $postData['payer_email'];
$payment->method = "PayPal ({$postData['payer_email']})";
if (!$cart) {
// Cart not found
$payment->failurereason = "Transaction specified a cart, but the cart was not found";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response);
return;
}
$cart->check_discounts();
// Make Payment Object
$payment->cart_id = $cart->id;
if ($response != 'VERIFIED') {
// IPN response is not verified
$payment->failurereason = "The transaction was not verified";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response, $cart);
return;
}
if ($postData['payment_status'] != "Completed") {
// Payment status is not completed
$payment->failurereason = "Payment status is not completed";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response, $cart);
return;
}
if ($postData['receiver_email'] != $gateway->getSetting('email')) {
// Sent to the wrong email
$payment->failurereason = "Payment was sent to a different email address";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response, $cart);
return;
}
$total = $cart->cost() + $cart->card_fee();
if ($postData['mc_gross'] * 100 < $total) {
// Cart is not enough
$payment->failurereason = "Payment was not enough for the cart";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response, $cart);
return;
}
if ($cart->paid) {
// Cart is already marked paid
$payment->failurereason = "The cart has already been paid for";
$payment->save();
Email::send_payment_alert($postData, $payment->failurereason, $response, $cart);
return;
}
// Payment is valid and for the right amount for our cart!
$payment->status = 'ptsTaken';
$payment->save();
Email::send_user_paymentconfirmation($payment);
// Mark cart as paid, this will trigger the event signup
// email to the user.
$cart->mark_paid($payment, "Paypal");
// Email staff about payment
Email::send_payment_complete($postData, $response, $cart);
//.........这里部分代码省略.........
示例4: create_from_signup
public static function create_from_signup($signup, $note = "")
{
$hash = self::hash_items($signup);
$cart = Cart::find("carts.hash = '{$hash}' AND carts.hash IS NOT NULL");
if ($cart) {
return $cart;
}
$cart = new Cart();
$cart->user_id = $signup->user->id;
$cart->note = $note;
$cart->hash = $hash;
if ($cart->save()) {
// Add Signup
$added = false;
if (!$signup->paid) {
$cart->add_item($signup);
$added = true;
}
foreach ($signup->event_services() as $service) {
if (!$service->paid) {
$cart->add_item($service);
$added = true;
}
}
$cart = Cart::find_by_id($cart->id);
if ($added) {
return $cart;
} else {
$cart->destroy();
return false;
}
}
return false;
}
示例5: cart
public function cart()
{
return Cart::find_by_id($this->cart_id);
}
示例6: _processPayment
public static function _processPayment($gateway, $postData)
{
// Process according to SagePay
$paymentTransaction = null;
if (isset($_POST['VendorTxCode'])) {
$paymentTransaction = PaymentTransaction::find_by_id($postData['VendorTxCode']);
}
if (!$paymentTransaction) {
throw new PGI_SagePay_ProcessException('Unable to find a payment matching ' . $postData['VendorTxCode']);
}
if ($paymentTransaction->status == 'ptsTaken') {
$params = array('Status' => 'OK', 'StatusDetail' => "Payment for {$paymentTransaction->cart}", 'RedirectURL' => "{$paymentTransaction->baseuri}/payments/{$paymentTransaction->cart->id}/complete");
$output = '';
foreach ($params as $key => $value) {
$output .= "{$key}={$value}\r\n";
}
return $output;
}
if ($paymentTransaction->status != 'ptsSubmitted') {
throw new PGI_SagePay_ProcessException("{$paymentTransaction} is in state {$paymentTransaction->status}", $paymentTransaction, $notify);
}
// Validate response
if (!isset($postData['VPSTxId'])) {
throw new PGI_SagePay_ProcessException('No transaction ID from SagePay');
}
if ($paymentTransaction->externalid != $postData['VPSTxId']) {
throw new PGI_SagePay_ProcessException("{$postData['VPSTxId']} does not match the transaction ID in " . $paymentTransaction, $paymentTransaction);
}
$fields = array('VPSTxId', 'VendorTxCode', 'Status', 'TxAuthNo', 'VendorName', 'AVSCV2', 'SecurityKey', 'AddressResult', 'PostCodeResult', 'CV2Result', 'GiftAid', '3DSecureStatus', 'CAVV', 'AddressStatus', 'PayerStatus', 'CardType', 'Last4Digits', 'DeclineCode', 'ExpiryDate', 'FraudResponse', 'BankAuthCode');
$sig = '';
foreach ($fields as $name) {
switch ($name) {
case 'SecurityKey':
$sig .= $paymentTransaction->initialResponse->SecurityKey;
break;
case 'VendorName':
$sig .= $gateway->getSetting('vendor');
break;
default:
$sig .= $postData[$name];
break;
}
}
$sig = strtoupper(md5($sig));
if ($sig != $postData['VPSSignature']) {
throw new PGI_SagePay_ProcessException("Signatures do not match, found {$sig}, expecting {$postData['VPSSignature']}", $paymentTransaction);
}
$url = "{$paymentTransaction->baseuri}/payments/{$paymentTransaction->id}/failed";
$paymentTransaction->processResponse = $postData;
// Determine our correct response
switch ($postData['Status']) {
case 'OK':
$url = "{$paymentTransaction->baseuri}/payments/{$paymentTransaction->cart->id}/complete";
$cart = Cart::find_by_id($paymentTransaction->cart->id);
$paymentTransaction->status = 'ptsTaken';
if ($postData['CardType'] == 'PAYPAL') {
$paymentTransaction->method = 'PayPal';
} else {
$cardName = 'Credit Card';
$lookup = array('VISA' => 'Visa', 'DELTA' => 'Visa Debit', 'UKE' => 'Visa Electron', 'MC' => 'Mastercard', 'SWITCH' => 'UK Maestro', 'MAESTRO' => 'Maestro', 'AMEX' => 'American Express', 'DINERS' => 'Diners Club', 'JCB' => 'JCB', 'LASER' => 'LASER', 'PAYPAL' => 'PayPal');
if (isset($lookup[$postData['CardType']])) {
$cardName = $lookup[$postData['CardType']];
}
$paymentTransaction->method = "{$cardName} (Ending in {$postData['Last4Digits']})";
}
$paymentTransaction->save();
Email::send_user_paymentconfirmation($paymentTransaction);
// Mark cart as paid, this will trigger the event signup
// email to the user.
$cart->mark_paid(null, "SagePay");
// Email staff about payment
Email::send_payment_complete($postData, $postData['Status'], $cart);
// And alert on Twitter
$account = TwitterAccount::find_by_code('site');
if ($account) {
$signups = $cart->get_signups();
$eventsignups = array();
foreach ($signups as $signup) {
$amount = sprintf("%.2f", $signup->event_ticket->cost / 100);
$paidsignups = count($signup->event->participants("paid"));
$message = "{$signup->user->nickname} has paid for {$signup->event->name} {$signup->event_ticket->name} [£{$amount}] ({$paidsignups}/{$signup->event->capacity}) [{$signup->id}]";
$account->add_tweet($message);
}
}
break;
case 'ABORT':
$paymentTransaction->status = 'ptsCancelled';
$paymentTransaction->failurereason = $postData['StatusDetail'];
break;
default:
$paymentTransaction->status = 'ptsFailed';
$paymentTransaction->failurereason = $postData['StatusDetail'];
break;
}
$paymentTransaction->save();
$params = array('Status' => 'OK', 'StatusDetail' => "Payment for {$paymentTransaction->cart}", 'RedirectURL' => $url);
$output = '';
foreach ($params as $key => $value) {
$output .= "{$key}={$value}\r\n";
}
//.........这里部分代码省略.........
示例7: send_user_paymentconfirmation
public static function send_user_paymentconfirmation($payment)
{
$cart = Cart::find_by_id($payment->cart_id);
$params = array('name' => $cart->user->nickname, 'method' => $payment->method, 'cart' => self::getCartBreakdown($cart), 'paymentdate' => date('jS F Y', $payment->created_at));
$message = array('subject' => "Payment Confirmation: Cart {$cart->id}");
return self::sendWithMandrill($cart->user->email, $cart->user->nickname, 'epic-lan-payment-confirmation', $params, $message);
}