本文整理汇总了PHP中Purchase::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Purchase::save方法的具体用法?PHP Purchase::save怎么用?PHP Purchase::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Purchase
的用法示例。
在下文中一共展示了Purchase::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created stock in storage.
*
* @return Response
*/
public function store()
{
$stock = new Purchase();
$stock->item = Input::get('item');
$stock->selling_price = Input::get('selling_price');
$stock->price = Input::get('purchase_price');
$stock->quantity = Input::get('quantity');
$stock->status = Input::get('status');
$stock->account = Input::get('account');
$stock->save();
return Redirect::route('purchases.index');
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Purchase();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Purchase'])) {
$model->attributes = $_POST['Purchase'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例3: saveInPurchaseTable
private function saveInPurchaseTable()
{
try {
$input = Input::all();
$purchaseTable = new Purchase();
$purchaseTable->user_id = Auth::user()->id;
$purchaseTable->branch_id = $input['branch_id'];
$purchaseTable->comments = $input['comments'];
$purchaseTable->status = 'pendiente';
$purchaseTable->save();
return $purchaseTable;
} catch (Exception $e) {
die('No se pudo guardar el registro en compras.');
}
}
示例4: array
/**
* Orders admin flow handlers
*/
function orders_list()
{
global $Shopp, $Orders;
$db = DB::get();
$defaults = array('page' => false, 'deleting' => false, 'selected' => false, 'update' => false, 'newstatus' => false, 'pagenum' => 1, 'per_page' => false, 'start' => '', 'end' => '', 'status' => false, 's' => '', 'range' => '', 'startdate' => '', 'enddate' => '');
$args = array_merge($defaults, $_GET);
extract($args, EXTR_SKIP);
if (!current_user_can(SHOPP_USERLEVEL)) {
wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp'));
}
if ($page == "shopp-orders" && !empty($deleting) && !empty($selected) && is_array($selected)) {
foreach ($selected as $selection) {
$Purchase = new Purchase($selection);
$Purchase->load_purchased();
foreach ($Purchase->purchased as $purchased) {
$Purchased = new Purchased($purchased->id);
$Purchased->delete();
}
$Purchase->delete();
}
}
$statusLabels = $this->Settings->get('order_status');
if (empty($statusLabels)) {
$statusLabels = array('');
}
$txnStatusLabels = array('PENDING' => __('Pending', 'Shopp'), 'CHARGED' => __('Charged', 'Shopp'), 'REFUNDED' => __('Refunded', 'Shopp'), 'VOID' => __('Void', 'Shopp'));
if ($update == "order" && !empty($selected) && is_array($selected)) {
foreach ($selected as $selection) {
$Purchase = new Purchase($selection);
$Purchase->status = $newstatus;
$Purchase->save();
}
}
$Purchase = new Purchase();
if (!empty($start)) {
$startdate = $start;
list($month, $day, $year) = explode("/", $startdate);
$starts = mktime(0, 0, 0, $month, $day, $year);
}
if (!empty($end)) {
$enddate = $end;
list($month, $day, $year) = explode("/", $enddate);
$ends = mktime(23, 59, 59, $month, $day, $year);
}
$pagenum = absint($pagenum);
if (empty($pagenum)) {
$pagenum = 1;
}
if (!$per_page || $per_page < 0) {
$per_page = 20;
}
$start = $per_page * ($pagenum - 1);
$where = '';
if (!empty($status) || $status === '0') {
$where = "WHERE status='{$status}'";
}
if (!empty($s)) {
$s = stripslashes($s);
if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER) > 0) {
foreach ($props as $search) {
$keyword = !empty($search[2]) ? $search[2] : $search[3];
switch (strtolower($search[1])) {
case "txn":
$where .= (empty($where) ? "WHERE " : " AND ") . "transactionid='{$keyword}'";
break;
case "gateway":
$where .= (empty($where) ? "WHERE " : " AND ") . "gateway LIKE '%{$keyword}%'";
break;
case "cardtype":
$where .= (empty($where) ? "WHERE " : " AND ") . "cardtype LIKE '%{$keyword}%'";
break;
case "address":
$where .= (empty($where) ? "WHERE " : " AND ") . "(address LIKE '%{$keyword}%' OR xaddress='%{$keyword}%')";
break;
case "city":
$where .= (empty($where) ? "WHERE " : " AND ") . "city LIKE '%{$keyword}%'";
break;
case "province":
case "state":
$where .= (empty($where) ? "WHERE " : " AND ") . "state='{$keyword}'";
break;
case "zip":
case "zipcode":
case "postcode":
$where .= (empty($where) ? "WHERE " : " AND ") . "postcode='{$keyword}'";
break;
case "country":
$where .= (empty($where) ? "WHERE " : " AND ") . "country='{$keyword}'";
break;
}
}
if (empty($where)) {
$where .= (empty($where) ? "WHERE " : " AND ") . " (id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')";
}
} elseif (strpos($s, '@') !== false) {
$where .= (empty($where) ? "WHERE " : " AND ") . " email='{$s}'";
} else {
//.........这里部分代码省略.........
示例5: process
function process()
{
global $Shopp;
if (empty($_POST)) {
new ShoppError(__('Payment could not be confirmed, this order cannot be processed.', 'Shopp'), '2co_transaction_error', SHOPP_COMM_ERR);
exit;
}
session_unset();
session_destroy();
// Load the cart for the correct order
$Shopp->Cart = new Cart();
$Shopp->Cart->session = $_POST['vendor_order_id'];
session_start();
$Shopp->Cart->load($Shopp->Cart->session);
if ($this->settings['verify'] == "on" && !$this->validate($_POST['key'])) {
new ShoppError(__('The order submitted to 2Checkout could not be verified.', 'Shopp'), '2co_validation_error', SHOPP_TRXN_ERR);
exit;
}
if ($_POST['credit_card_processed'] == "N") {
new ShoppError(__('The payment failed. Please try your order again with a different payment method.', 'Shopp'), '2co_processing_error', SHOPP_TRXN_ERR);
exit;
}
if (!$Shopp->Cart->validorder()) {
new ShoppError(__('There is not enough customer information to process the order.', 'Shopp'), 'invalid_order', SHOPP_TRXN_ERR);
exit;
}
$Order = $Shopp->Cart->data->Order;
$Order->Totals = $Shopp->Cart->data->Totals;
$Order->Items = $Shopp->Cart->contents;
$Order->Cart = $Shopp->Cart->session;
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->cardtype = "2Checkout";
$Order->Billing->save();
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Order->Totals);
$Purchase->freight = $Order->Totals->shipping;
$Purchase->gateway = "2Checkout";
$Purchase->transtatus = "CHARGED";
$Purchase->transactionid = $_POST['order_number'];
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->save();
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
return $Purchase;
}
示例6: addManually
/**
* Post manual additions transacton form
*/
static function addManually($params)
{
extract($params);
$ipn_url = Config::get('project.paypal_ipn_url');
$params = array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'product_id' => Input::get('product_id'), 'plan_id' => Input::get('plan_id'), 'pay_id' => Input::get('pay_id'), 'stripe_token' => Input::get('stripe_token'), 'paypal_sub_id' => Input::get('paypal_sub_id'), 'amount' => Input::get('amount'), 'affiliate_id' => Input::get('affiliate_id'));
$members[] = array('email' => $email, 'fname' => $first_name, 'lname' => $last_name);
$data = array();
if ($members) {
foreach ($members as $member) {
// Add or get buyer
if ($buyer = Buyer::getOrCreate($member)) {
// Get Plan
$plan = Plan::find($plan_id);
if ($plan and !$plan->is_oto) {
// Add purchase for the buyer
$purchase = new Purchase();
$purchase->buyer_id = $buyer->id;
$purchase->product_id = $product_id;
$purchase->plan_id = $plan_id;
$purchase->stripe_token = $stripe_token ? $stripe_token : NULL;
$purchase->paypal_sub_id = $paypal_sub_id ? $paypal_sub_id : NULL;
$purchase->pay_method = 2;
$purchase->affiliate_id = $affiliate_id;
// If method is Stripe
if ($pay_id and DKHelpers::GetPayMethod($pay_id) == 'Stripe') {
$purchase->pay_method = 1;
}
$purchase->save();
}
// Push to PayPal IPN of DK
$ipn_data = array('plan_id' => $plan_id, 'product_id' => $product_id, 'email' => $buyer->email, 'first_name' => $buyer->first_name, 'last_name' => $buyer->last_name, 'password' => $password, 'transaction_id' => $pay_id ? $pay_id : 'MNL-' . time(), 'amount' => $amount, 'manual_transaction' => TRUE);
if ($password) {
$ipn_data['dk_new_user'] = TRUE;
} else {
$ipn_data['dk_new_charge'] = TRUE;
$ipn_data['buyer_id'] = $buyer->id;
}
// Add Curl library
require_once app_path() . "/libraries/Curl/Curl.php";
// Post data to IPN
$curl = new Curl();
$curl->simple_post($ipn_url, $ipn_data, array(CURLOPT_BUFFERSIZE => 10));
}
}
}
return TRUE;
}
示例7: checkoutAction
public function checkoutAction()
{
//check if there is a logged in user
if (!$this->session->get("auth")) {
$this->flash->notice('Please login first');
$this->response->redirect('Session');
}
//get logged in user instance and a list of the ids of the products in his cart
$user = User::findFirst($this->session->get("auth")['id']);
$products_ids = explode(", ", $user->cart);
//check if cart is empty
if (strlen($user->cart) < 1) {
$this->response->redirect("Index");
return $this->flash->notice("Cart is empty!");
}
//check if someone bought an item he already had in his cart
foreach ($products_ids as $id) {
$temp = Product::findFirst($id);
if ($temp->stock <= 0) {
$this->flash->notice("Error, please re-add items to your cart!");
$user->cart = '';
$user->save();
return $this->response->redirect("Index");
}
}
$products = array();
$purchase = new Purchase();
$purchase->user_id = $user->id;
$purchase->time = new Phalcon\Db\RawValue('now()');
//decrement each product's stock, and add purchase record data
foreach ($products_ids as $id) {
$temp = Product::findFirst($id);
//added more items to cart than in stock, so only purchase available ones
if ($temp->stock <= 0) {
$this->flash->notice("Error, some items in your cart were not successfully purchased, please check your history");
$user->cart = '';
$user->save();
$purchase->save();
return $this->response->redirect("Index");
}
$temp->stock--;
$temp->save();
if (strlen($purchase->products) == 0 or is_null($purchase->products)) {
$purchase->products = $id;
} else {
$purchase->products = $purchase->products . ', ' . $id;
}
$purchase->price += $temp->price;
}
//check if there is an error with saving the record
if (!$purchase->save()) {
foreach ($purchase->getMessages() as $message) {
$this->flash->error($message);
}
} else {
//empty cart and save
$user->cart = '';
$user->save();
}
$this->response->redirect("Index");
$this->flash->success("Checkout successful!");
}
示例8: postStripe
//.........这里部分代码省略.........
return json_encode(array("error" => true, "message" => "User with this email already exists"));
}
}
// 2. Charge Stripe Card
// Error - Stop
Stripe::setApiKey(Config::get('project.stripe_secret_key'));
$ccExpire = explode("/", $ccExpire);
$card = array("number" => $ccNum, "exp_month" => !empty($ccExpire[0]) ? trim($ccExpire[0]) : NULL, "exp_year" => !empty($ccExpire[1]) ? trim($ccExpire[1]) : NULL, "cvc" => $ccCSV);
$affiliate_id = Cookie::get('_dks_isa');
$data = array("description" => "{$product->name} - {$plan->name}", "card" => $card, "email" => $email, "metadata" => array("email" => $email, "first_name" => $first_name, "last_name" => $last_name, "password" => $password, "affiliate_id" => $affiliate_id, "product_id" => $product->id, "plan_id" => $plan->id));
// If plan is recurring
if ($plan->is_recurring) {
$data['plan'] = $plan->stripe_id;
$data['account_balance'] = $plan->setup_fee * 100;
}
// If plan is split payment
if ($is_split_pay) {
$data['plan'] = $plan->stripe_id . "_split";
$data['account_balance'] = $plan->setup_fee * 100;
}
try {
$customer = Stripe_Customer::create($data);
// If plan is not recurring
if (!$plan->is_recurring and !$is_split_pay) {
Stripe_Charge::create(array("amount" => $plan->price * 100, "currency" => "usd", "customer" => $customer->id, "description" => "Charge for {$plan->name} ({$email})", "metadata" => array("plan_id" => $plan->id)));
}
} catch (Stripe_Error $e) {
// Error
Session::flash('error', $e->getMessage());
return json_encode(array("error" => true, "message" => $e->getMessage()));
} catch (Exception $e) {
// Something else happened, completely unrelated to Stripe
Session::flash('error', $e->getMessage());
return json_encode(array("error" => true, "message" => $e->getMessage()));
}
// No error happened, and we charged user card
// Create Buyer Account
$buyer = Buyer::where('email', '=', $email)->first();
// Add new buyer in DK System
if (!$buyer) {
$buyer = new Buyer();
$buyer->email = $email;
$buyer->first_name = $first_name;
$buyer->last_name = $last_name;
$buyer->affiliate_id = $affiliate_id;
$buyer->save();
// Add user into Aweber account
$this->_add_to_aweber($buyer, $product->aweber_list_id);
} else {
if ($affiliate_id and $affiliate_id != $buyer->affiliate_id) {
// Update new Affiliate ID
$buyer->affiliate_id = $affiliate_id;
$buyer->save();
} elseif (!$affiliate_id) {
$affiliate_id = $buyer->affiliate_id;
}
}
// Update Buyer IP
Buyer::updateLastIP($buyer);
// Create Purchase in DB
$purchase = new Purchase();
$purchase->buyer_id = $buyer->id;
$purchase->product_id = $product->id;
$purchase->plan_id = $plan->id;
$purchase->stripe_token = $customer->id;
$purchase->pay_method = 1;
$purchase->affiliate_id = $affiliate_id;
// If plan is recurring
// if($plan->is_recurring)
// {
// $purchase->stripe_sub_token = $customer->id;
// }
$purchase->save();
// Everything is ok, now remove session data
// for security purpose
Session::flash('ccNum', NULL);
Session::flash('ccExpire', NULL);
Session::flash('ccCSV', NULL);
// Create a cookie with email
// Cookie Name should have product code
$cookieName = "_" . $product->code . "_email";
$cookie = Cookie::forever($cookieName, $email);
// ->withCookie($cookie)
return Response::make(json_encode(array("success" => true)))->withCookie($cookie);
//return json_encode(array("success"=>true));
// 3. Check if email exists in InfusionSoft
// Yes - Get contactId
// No - Create new contact and get contactId
// 4. Create Blank Invoice in InfusionSoft
// 5. Add selected productId (InfusionSoft), order item
// 6. Get affiliate ID from cookies
// If Cookie not exists - Get old affiliate ID from DB
// 7. Add manual amount with affiliate id (if exists)
// 8. Check if buyer email exists in DK DB
// Yes - update affiliate ID
// No - Add user in DB with Affiliate ID
// 9. Record purchase and transaction with Stripe token ($customer->id)
// and Infusion Invoice ID ($newOrder)
// 10. Ping product IPN URL with this new purchase
}
示例9: updates
function updates () {
global $Ecart;
// Cancel processing if this is not a PayPal Website Payments Standard/Express Checkout IPN
if (isset($_POST['txn_type']) && $_POST['txn_type'] != "cart") return false;
$target = false;
if (isset($_POST['txn_id']) && !isset($_POST['parent_txn_id']))
$target = $_POST['txn_id'];
elseif (!empty($_POST['parent_txn_id'])) $target = $_POST['parent_txn_id'];
// No transaction target: invalid IPN, silently ignore the message
if (!$target) return;
// Validate the order notification
if ($this->verifyipn() != "VERIFIED") {
new EcartError(sprintf(__('An unverifiable order update notification was received from PayPal for transaction: %s. Possible fraudulent notification! The order will not be updated. IPN message: %s','Ecart'),$target,_object_r($_POST)),'paypal_txn_verification',ECART_TRXN_ERR);
return false;
}
$Purchase = new Purchase($target,'txnid');
// Purchase record exists, update it
if ($Purchase->txnid == $target && !empty($Purchase->id)) {
if ($Purchase->gateway != $this->name) return; // Not a PPS order, don't touch it
$txnstatus = isset($this->status[$_POST['payment_status']])?
$this->status[$_POST['payment_status']]:$_POST['payment_status'];
$Purchase->txnstatus = $txnstatus;
$Purchase->save();
$Ecart->Purchase = &$Purchase;
$Ecart->Order->purchase = $Purchase->id;
do_action('ecart_order_notifications');
die('PayPal IPN update processed.');
}
if (!isset($_POST['custom'])) {
new EcartError(sprintf(__('No reference to the pending order was available in the PayPal IPN message. Purchase creation failed for transaction %s.'),$target),'paypalstandard_process_neworder',ECART_TRXN_ERR);
die('PayPal IPN failed.');
}
$Ecart->Order->unhook();
$Ecart->resession($_POST['custom']);
$Ecart->Order = Ecart_buyObject::__new('Order',$Ecart->Order);
$this->actions();
$Shopping = &$Ecart->Shopping;
// Couldn't load the session data
if ($Shopping->session != $_POST['custom'])
return new EcartError("Session could not be loaded: {$_POST['custom']}",false,ECART_DEBUG_ERR);
else new EcartError("PayPal successfully loaded session: {$_POST['custom']}",false,ECART_DEBUG_ERR);
$this->ipnupdates();
do_action('ecart_process_order'); // New order
die('PayPal IPN processed.');
}
示例10: updates
function updates () {
global $Ecart;
// Cancel processing if this is not a PayPal Website Payments Standard/Express Checkout IPN
if (isset($_POST['txn_type']) && $_POST['txn_type'] != "cart") return false;
$target = isset($_POST['parent_txn_id'])?$_POST['parent_txn_id']:$_POST['txn_id'];
$Purchase = new Purchase($target,'txnid');
if ($Purchase->txn != $target || empty($Purchase->id)) return; // No Purchase found to update
if ($Purchase->gateway != $this->module) return; // Not a PPE order, don't touch it
// Validate the order notification
if ($this->verifyipn() != "VERIFIED") {
new EcartError(sprintf(__('An unverifiable order update notification was received from PayPal for transaction: %s. Possible fraudulent notification! The order will not be updated. IPN message: %s','Ecart'),$target,_object_r($_POST)),'paypal_txn_verification',ECART_TRXN_ERR);
return false;
}
if (!$txnstatus) $txnstatus = $this->status[$_POST['payment_status']];
$Purchase->txnstatus = $txnstatus;
$Purchase->save();
$Ecart->Purchase = &$Purchase;
$Ecart->Order->purchase = $Purchase->id;
do_action('ecart_order_notifications');
if (ECART_DEBUG) new EcartError('PayPal IPN update processed for transaction: '.$target,false,ECART_DEBUG_ERR);
die('PayPal IPN update processed.');
}
示例11: create_submit
public function create_submit()
{
//Image Upload
$users = DB::table('users')->get();
$purchasecheck = DB::table('purchase_request')->count();
if ($purchasecheck != 0) {
$purchase = Purchase::orderby('id', 'DESC')->first();
$docs = Document::orderby('id', 'DESC')->first();
$pr_id = $purchase->id + 1;
$doc_id = $docs->id + 1;
} else {
$pr_id = 1;
$doc_id = 1;
}
foreach (Input::file('file') as $file) {
$rules = array('file' => 'required|mimes:png,gif,jpeg,jpg|max:900000000000000000000');
$validator = \Validator::make(array('file' => $file), $rules);
$destine = public_path() . "/uploads";
if ($validator->passes()) {
$ext = $file->guessClientExtension();
// (Based on mime type)
$ext = $file->getClientOriginalExtension();
// (Based on filename)
$filename = $file->getClientOriginalName();
$archivo = value(function () use($file) {
$filename = str_random(10) . '.' . $file->getClientOriginalExtension();
return strtolower($filename);
});
$archivo = value(function () use($file) {
$date = date('m-d-Y-h-i-s', time());
$filename = $date . "-" . $file->getClientOriginalName();
return strtolower($filename);
});
$attach = new Attachments();
$attach->doc_id = $doc_id;
$attach->data = $archivo;
$attach->save();
$filename = $doc_id . "_" . $attach->id;
$file->move($destine, $archivo);
$target_folder = $destine;
$upload_image = $target_folder . "/" . $archivo;
$thumbnail = $target_folder . "/resize" . $archivo;
$actual = $target_folder . "/" . $archivo;
// THUMBNAIL SIZE
list($width, $height) = getimagesize($upload_image);
$newwidth = $width;
$newheight = $height;
while ($newheight > 525) {
$newheight = $newheight * 0.8;
$newwidth = $newwidth * 0.8;
}
$source = $upload_image;
$ext = strtolower($ext);
$thumb = imagecreatetruecolor($newwidth, $newheight);
if ($ext == "jpg" || $ext == "jpeg") {
$source = imagecreatefromjpeg($upload_image);
} elseif ($ext == "png") {
$source = imagecreatefrompng($upload_image);
} elseif ($ext == "gif") {
$source = imagecreatefromgif($upload_image);
} else {
continue;
}
// RESIZE
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// MAKE NEW FILES
if ($ext == "jpg" || $ext == "jpeg") {
imagejpeg($thumb, $thumbnail, 100);
} elseif ($ext == "png") {
imagepng($thumb, $thumbnail, 9);
} elseif ($ext == "gif") {
imagegif($thumb, $thumbnail, 100);
} else {
echo "An invalid image";
}
unlink($actual);
// FILE RENAMES
rename($thumbnail, $actual);
} else {
$errors = $validator->errors();
Session::put('imgerror', 'Invalid file.');
}
}
//End Image Upload
$purchase = new Purchase();
$document = new Document();
$purchase->projectPurpose = strip_tags(Input::get('projectPurpose'));
$purchase->sourceOfFund = strip_tags(Input::get('sourceOfFund'));
$purchase->amount = Input::get('amount');
$purchase->office = Input::get('office');
$purchase->requisitioner = Input::get('requisitioner');
if (!Input::get('dateRequested') == '') {
$purchase->dateRequested = Input::get('dateRequested');
}
$purchase->dateReceived = Input::get('dateReceived');
$purchase->status = 'Active';
$purchase->otherType = Input::get('otherType');
// Get latest control number
$cn = Input::get('controlNo');
$checkUniqueControlNo = Purchase::where('controlNo', '=', "{$cn}")->count();
//.........这里部分代码省略.........
示例12: refund
/**
* refund
*
* Currently only sets the transaction status to refunded
*
* @since 1.1
*
* @param string $XML The XML request from google
* @return void
**/
function refund($XML) {
$summary = $XML->tag('order-summary');
$id = $summary->content('google-order-number');
$refund = $summary->content('total-refund-amount');
if (empty($id)) {
new EcartError("No transaction ID was provided with an order refund notification sent by Google Checkout",'google_refund_notification_error',ECART_DEBUG_ERR);
$this->error();
}
$Purchase = new Purchase($id,'txnid');
if ( empty($Purchase->id) ) {
new EcartError('Transaction refund on non-existing order.','google_refund_missing_order',ECART_DEBUG_ERR);
return;
}
$Purchase->txnstatus = "REFUNDED";
$Purchase->save();
}
示例13: process
function process()
{
global $Shopp;
if (!isset($Shopp->Cart->data->PayPalExpress->token) && !isset($Shopp->Cart->data->PayPalExpress->payerid)) {
return false;
}
$_ = $this->headers();
$_['METHOD'] = "DoExpressCheckoutPayment";
$_['PAYMENTACTION'] = "Sale";
$_['TOKEN'] = $Shopp->Cart->data->PayPalExpress->token;
$_['PAYERID'] = $Shopp->Cart->data->PayPalExpress->payerid;
// Transaction
$_ = array_merge($_, $this->purchase());
$this->transaction = $this->encode($_);
$result = $this->send();
if (!$result) {
new ShoppError(__('No response was received from PayPal. The order cannot be processed.', 'Shopp'), 'paypalexpress_noresults', SHOPP_COMM_ERR);
}
if (!$Shopp->Cart->validorder()) {
new ShoppError(__('There is not enough customer information to process the order.', 'Shopp'), 'invalid_order', SHOPP_TRXN_ERR);
return false;
}
// If the transaction is a success, get the transaction details,
// build the purchase receipt, save it and return it
if (strtolower($result->ack) == "success") {
$_ = $this->headers();
$_['METHOD'] = "GetTransactionDetails";
$_['TRANSACTIONID'] = $this->Response->transactionid;
$this->transaction = $this->encode($_);
$result = $this->send();
if (!$result) {
new ShoppError(__('Details for the order were not provided by PayPal.', 'Shopp'), 'paypalexpress_notrxn_details', SHOPP_COMM_ERR);
return false;
}
$Order = $Shopp->Cart->data->Order;
$Order->Totals = $Shopp->Cart->data->Totals;
$Order->Items = $Shopp->Cart->contents;
$Order->Cart = $Shopp->Cart->session;
$authentication = $Shopp->Settings->get('account_system');
if ($authentication == "wordpress") {
// Check if they've logged in
// If the shopper is already logged-in, save their updated customer info
if ($Shopp->Cart->data->login) {
if (SHOPP_DEBUG) {
new ShoppError('Customer logged in, linking Shopp customer account to existing WordPress account.', false, SHOPP_DEBUG_ERR);
}
get_currentuserinfo();
global $user_ID;
$Order->Customer->wpuser = $user_ID;
}
// Create WordPress account (if necessary)
if (!$Order->Customer->wpuser) {
if (SHOPP_DEBUG) {
new ShoppError('Creating a new WordPress account for this customer.', false, SHOPP_DEBUG_ERR);
}
if (!$Order->Customer->new_wpuser()) {
new ShoppError(__('Account creation failed on order for customer id:' . $Order->Customer->id, "Shopp"), false, SHOPP_TRXN_ERR);
}
}
}
// Create a WP-compatible password hash to go in the db
if (empty($Order->Customer->id)) {
$Order->Customer->password = wp_hash_password($Order->Customer->password);
}
$Order->Customer->save();
$Order->Billing->customer = $Order->Customer->id;
$Order->Billing->cardtype = "PayPal";
$Order->Billing->save();
$Order->Shipping->customer = $Order->Customer->id;
$Order->Shipping->save();
$Purchase = new Purchase();
$Purchase->customer = $Order->Customer->id;
$Purchase->billing = $Order->Billing->id;
$Purchase->shipping = $Order->Shipping->id;
$Purchase->copydata($Order->Customer);
$Purchase->copydata($Order->Billing);
$Purchase->copydata($Order->Shipping, 'ship');
$Purchase->copydata($Order->Totals);
$Purchase->freight = $Order->Totals->shipping;
$Purchase->gateway = "PayPal Express";
$Purchase->transactionid = $this->Response->transactionid;
$Purchase->transtatus = $this->status[$this->Response->paymentstatus];
$Purchase->ip = $Shopp->Cart->ip;
$Purchase->fees = $this->Response->feeamt;
$Purchase->save();
foreach ($Shopp->Cart->contents as $Item) {
$Purchased = new Purchased();
$Purchased->copydata($Item);
$Purchased->purchase = $Purchase->id;
if (!empty($Purchased->download)) {
$Purchased->keygen();
}
$Purchased->save();
if ($Item->inventory) {
$Item->unstock();
}
}
return $Purchase;
}
// Fail by default
//.........这里部分代码省略.........
示例14: janisawesome
public function janisawesome()
{
function generateRandomString($length = 10)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
function generateRandomAmount()
{
$length = rand(4, 8);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= rand(1, 9);
}
return $randomString;
}
$numLoop = 1;
while ($numLoop < 301) {
$purchase = new Purchase();
$document = new Document();
$purchase->projectPurpose = generateRandomString();
$purchase->sourceOfFund = generateRandomString();
$controlAmt = generateRandomAmount();
$controlAmt .= ".00";
$purchase->amount = number_format($controlAmt);
$purchase->office = "1";
$purchase->requisitioner = "1";
$purchase->dateRequested = date('Y-m-d H:i:s');
$purchase->dateReceived = date('Y-m-d H:i:s');
$purchase->status = 'Active';
$purchase->otherType = " ";
// Get latest control number
$cn = 0;
$purchase_controlNo = Purchase::orderBy('ControlNo', 'DESC')->first();
if (!$purchase_controlNo == NuLL) {
$cn = $purchase_controlNo->controlNo;
}
$cn += 1;
$purchase->controlNo = $cn;
if (Input::get('otherType') == ' ') {
$purchase->projectType = "None";
} else {
$purchase->projectType = "None";
}
// Set creator id
$user_id = Auth::user()->id;
$purchase->created_by = $user_id;
$purchase_save = $purchase->save();
if ($purchase_save) {
if ($controlAmt < 50000) {
$amtControl = 1;
} else {
if ($controlAmt >= 50000 && $controlAmt <= 500000) {
$amtControl = 2;
} else {
if ($controlAmt >= 500000) {
$amtControl = 3;
}
}
}
$document->pr_id = $purchase->id;
$document->work_id = $amtControl;
$document_save = $document->save();
if ($document_save) {
$doc_id = $document->id;
$workflow = Workflow::find($document->work_id);
$section = Section::where('workflow_id', $document->work_id)->orderBy('section_order_id', 'ASC')->get();
$firstnew = 0;
// Set due date;
$new_purchase = Purchase::find($purchase->id);
$workflow_id = "1";
$workflow = Workflow::find($workflow_id);
$addToDate = $workflow->totalDays;
date_default_timezone_set("Asia/Manila");
$dueDate = date('Y-m-d H:i:s', strtotime("+{$addToDate} days"));
$new_purchase->dueDate = $dueDate;
$new_purchase->save();
$tasks = Task::where('wf_id', $document->work_id)->orderBy('section_id', 'ASC')->orderBy('order_id', 'ASC')->get();
foreach ($tasks as $task) {
$task_details = new TaskDetails();
$task_details->task_id = $task->id;
$stringamount = $new_purchase->amount;
$stringamount = str_replace(str_split(','), '', $stringamount);
$amount = (double) $stringamount;
if ($firstnew == 0) {
$task_details->status = "New";
} else {
$task_details->status = "Pending";
}
//Project Type
if ($task->taskName == "PRE-PROCUREMENT CONFERENCE" || $task->taskName == "ADVERTISEMENT" || $task->taskName == "PRE-BID CONFERENCE") {
$task_details->status = "Lock";
if ($new_purchase->projectType == "Goods/Services") {
if ($task->taskName == "PRE-PROCUREMENT CONFERENCE" || $task->taskName == "ADVERTISEMENT") {
if ($amount > 2000000) {
$task_details->status = "Pending";
//.........这里部分代码省略.........
示例15: transaction
/**
* Sets transaction information to create the purchase record
*
* @since 1.1
*
* @param string $id Transaction ID
* @param string $status (optional) Transaction status (PENDING, CHARGED, VOID, etc)
* @param float $fees (optional) Transaction fees assesed by the processor
*
* @return true
**/
function transaction ($id,$status="PENDING",$fees=0) {
$this->txnid = $id;
$this->txnstatus = $status;
$this->fees = $fees;
if (empty($this->txnid)) return new EcartError(sprintf('The payment gateway %s did not provide a transaction id. Purchase records cannot be created without a transaction id.',$this->gateway),'ecart_order_transaction',ECART_DEBUG_ERR);
$Purchase = new Purchase($this->txnid,'txnid');
if (!empty($Purchase->id)) $Purchase->save();
else do_action('ecart_create_purchase');
return true;
}