本文整理汇总了PHP中Payment::createNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::createNew方法的具体用法?PHP Payment::createNew怎么用?PHP Payment::createNew使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Payment
的用法示例。
在下文中一共展示了Payment::createNew方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createPayment
private function createPayment($invitation, $ref, $payerId = null)
{
$invoice = $invitation->invoice;
$accountGateway = $invoice->client->account->account_gateways[0];
if ($invoice->account->account_key == NINJA_ACCOUNT_KEY) {
$account = Account::find($invoice->client->public_id);
$account->pro_plan_paid = date_create()->format('Y-m-d');
$account->save();
}
if ($invoice->is_quote) {
$invoice = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id);
}
$payment = Payment::createNew($invitation);
$payment->invitation_id = $invitation->id;
$payment->account_gateway_id = $accountGateway->id;
$payment->invoice_id = $invoice->id;
$payment->amount = $invoice->amount;
$payment->client_id = $invoice->client_id;
$payment->contact_id = $invitation->contact_id;
$payment->transaction_reference = $ref;
$payment->payment_date = date_create()->format('Y-m-d');
if ($payerId) {
$payment->payer_id = $payerId;
}
$payment->save();
Event::fire('invoice.paid', $payment);
return $payment;
}
示例2: save
private function save()
{
$rules = array('client' => 'required', 'invoice' => 'required', 'amount' => 'required|positive');
if (Input::get('invoice')) {
$invoice = Invoice::scope(Input::get('invoice'))->firstOrFail();
$rules['amount'] .= '|less_than:' . $invoice->balance;
}
if (Input::get('payment_type_id') == PAYMENT_TYPE_CREDIT) {
$rules['payment_type_id'] = 'has_credit:' . Input::get('client') . ',' . Input::get('amount');
}
$messages = array('required' => 'El campo es Requerido', 'positive' => 'El Monto debe ser mayor a cero', 'less_than' => 'El Monto debe ser menor o igual a ' . $invoice->balance, 'has_credit' => 'El Cliente no tiene crédito suficiente');
$validator = \Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
$url = 'pagos/create';
return Redirect::to($url)->withErrors($validator)->withInput();
} else {
$payment = Payment::createNew();
$paymentTypeId = Input::get('payment_type_id') ? Input::get('payment_type_id') : null;
$clientId = Client::getPrivateId(Input::get('client'));
$amount = floatval(Input::get('amount'));
if ($paymentTypeId == PAYMENT_TYPE_CREDIT) {
$credits = Credit::scope()->where('client_id', '=', $clientId)->where('balance', '>', 0)->orderBy('created_at')->get();
$applied = 0;
foreach ($credits as $credit) {
$applied += $credit->apply($amount);
if ($applied >= $amount) {
break;
}
}
}
$payment->client_id = $clientId;
$payment->invoice_id = Invoice::getPrivateId(Input::get('invoice'));
$payment->payment_type_id = $paymentTypeId;
$payment->payment_date = date("Y-m-d", strtotime(Input::get('payment_date')));
$payment->amount = $amount;
$payment->transaction_reference = trim(Input::get('transaction_reference'));
$payment->save();
Session::flash('message', 'Pago creado con éxito');
return Redirect::to('clientes/' . Input::get('client'));
}
}
示例3: save
private function save($publicId = null)
{
$action = Input::get('action');
$entityType = Input::get('entityType');
if ($action == 'archive' || $action == 'delete' || $action == 'mark') {
return InvoiceController::bulk($entityType);
}
$input = json_decode(Input::get('data'));
//echo "this is the result";
$invoice = $input->invoice;
//print_r($invoice);exit();
$branch = Branch::where('account_id', '=', Auth::user()->account_id)->where('id', Auth::user()->branch_id)->first();
$today = new DateTime('now');
$today = $today->format('Y-m-d');
$datelimit = DateTime::createFromFormat('Y-m-d', $branch->deadline);
$datelimit = $datelimit->format('Y-m-d');
$first = explode("-", $datelimit);
$second = explode("-", $today);
$first_day = $first[2];
$first_month = $first[1];
$first_year = $first[0];
$second_day = $second[2];
$second_month = $second[1];
$second_year = $second[0];
$a = gregoriantojd($first_month, $first_day, $first_year);
$b = gregoriantojd($second_month, $second_day, $second_year);
$errorS = "Expiró la Fecha Límite de " . $branch->name;
if ($a - $b < 0) {
Session::flash('error', $errorS);
return Redirect::to("{$entityType}s/create")->withInput();
} else {
$last_invoice = Invoice::where('account_id', '=', Auth::user()->account_id)->first();
if ($last_invoice) {
$yesterday = $last_invoice->invoice_date;
$today = date("Y-m-d", strtotime($invoice->invoice_date));
$errorD = "La fecha de la factura es incorrecta";
$yesterday = new DateTime($yesterday);
$today = new DateTime($today);
if ($yesterday > $today) {
Session::flash('error', $errorD);
return Redirect::to("{$entityType}s/create")->withInput();
}
}
if (false && ($errors = $this->invoiceRepo->getErrors($invoice))) {
Session::flash('error', trans('texts.invoice_error'));
return Redirect::to("{$entityType}s/create")->withInput()->withErrors($errors);
} else {
//$this->taxRateRepo->save($input->tax_rates);
$clientData = (array) $invoice->client;
$clientData['branch'] = $branch->id;
$client = $this->saveClient($invoice->client->public_id, $clientData);
$invoiceData = (array) $invoice;
$invoiceData['branch_id'] = $branch->id;
$invoiceData['client_id'] = $client->id;
$invoiceData['client_nit'] = $client->nit;
$invoiceData['client_name'] = $client->name;
$invoiceData['action'] = $action;
//$invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType);
$account = Auth::user()->account;
$client->load('contacts');
$sendInvoiceIds = [];
foreach ($client->contacts as $contact) {
if ($contact->send_invoice || count($client->contacts) == 1) {
$sendInvoiceIds[] = $contact->id;
}
}
/*foreach ($client->contacts as $contact)
{
$invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
if (in_array($contact->id, $sendInvoiceIds) && !$invitation)
{
$invitation = Invitation::createNew();
$invitation->invoice_id = $invoice->id;
$invitation->contact_id = $contact->id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invitation->save();
}
else if (!in_array($contact->id, $sendInvoiceIds) && $invitation)
{
$invitation->delete();
}
}*/
$message = trans($publicId ? "texts.updated_{$entityType}" : "texts.created_{$entityType}");
if ($input->invoice->client->public_id == '-1') {
$message = $message . ' ' . trans('texts.and_created_client');
$url = URL::to('clients/' . $client->public_id);
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
}
if ($action == 'email') {
$aux = 0;
foreach ($client->contacts as $contact) {
if ($contact->email) {
$aux = 1;
}
}
if ($aux == 0) {
$errorMessage = trans('El cliente no tiene Correo Electrónico.');
Session::flash('error', $errorMessage);
} else {
//.........这里部分代码省略.........
示例4: SlowTemplate
require_once "../../include/Configuration.php";
require_once "SlowTemplate.php";
require_once "WebUtility.php";
require_once "Database.php";
require_once "Payment.php";
$slow = new SlowTemplate('template/admin');
$slow->setTemplateFile('index.tpl');
session_start();
//////////////////////////////////////////////////////////////////////////////
// handle the submission
if ($_SERVER["REQUEST_METHOD"] == 'POST') {
if (isset($_POST["ok"])) {
$reciept = "BCXY" . rand(1000, 9999);
// need to be more random
$payment = Payment::createNew($reciept, Payment::TYPE_PAYMENT_RECIEVED);
if (is_object($payment)) {
$amount = numberInput($_POST["amount"]);
$payment->setTime(dateInput($_POST["day"] . " " . $_POST["time"]));
$payment->setPhonenumber($_POST["phone"]);
$payment->setName($_POST["name"]);
$payment->setAccount(rand(1000, 9999));
$payment->setStatus(Payment::STATUS_COMPLETED);
$payment->setAmount($amount);
$payment->setPostBalance($amount);
$payment->update();
print "Payment created";
}
}
}
//////////////////////////////////////////////////////////////////////////////
示例5: guardarFacturaG
public function guardarFacturaG()
{
/* David
Guardando factura con el siguiente formato:
{"invoice_items":[{"qty":"2","id":"2"}],"client_id":"1"}
//nuevo formato para la cascada XD
{"invoice_items":[{"qty":"2","id":"2","boni":"1","desc":"3"}],"client_id":"1"}
*/
$input = Input::all();
// $invoice_number = Auth::user()->account->getNextInvoiceNumber();
$invoice_number = Auth::user()->branch->getNextInvoiceNumber();
$client_id = $input['client_id'];
$client = DB::table('clients')->select('id', 'nit', 'name', 'public_id', 'custom_value4')->where('id', $input['client_id'])->first();
DB::table('clients')->where('id', $input['client_id'])->update(array('nit' => $input['nit'], 'name' => $input['name']));
$user_id = Auth::user()->getAuthIdentifier();
$user = DB::table('users')->select('account_id', 'branch_id', 'public_id')->where('id', $user_id)->first();
$account = DB::table('accounts')->where('id', $user->account_id)->first();
// //$account_id = $user->account_id;
// // $account = DB::table('accounts')->select('num_auto','llave_dosi','fecha_limite')->where('id',$user->account_id)->first();
// //$branch = DB::table('branches')->select('num_auto','llave_dosi','fecha_limite','address1','address2','country_id','industry_id')->where('id',$user['branch_id'])->first();
// //$branch = DB::table('branches')->select('num_auto','llave_dosi','fecha_limite','address1','address2','country_id','industry_id')->where('id','=',$user->branch_id)->first();
// // $branch = DB::table('branches')->select('number_autho','key_dosage','deadline','address1','address2','country_id','industry_id','law','activity_pri','activity_sec1','name')->where('id','=',$user->branch_id)->first();
$branch = DB::table('branches')->where('id', '=', $user->branch_id)->first();
$invoice_design = DB::table('invoice_designs')->select('id')->where('account_id', '=', $user->account_id)->first();
// return Response::json($invoice_design);
$items = $input['invoice_items'];
// $linea ="";
$amount = 0;
$subtotal = 0;
$fiscal = 0;
$icetotal = 0;
$bonidesc = 0;
$productos = array();
foreach ($items as $item) {
# code...
$product_id = $item['id'];
$pr = DB::table('products')->where('products.id', "=", $product_id)->first();
$pr->amount = $item['amount'];
// $pr->xd ='hola';
$amount = $amount + $pr->amount;
$pr->qty = 1;
$productos = $pr;
// $pr = DB::table('products')->select('cost')->where('id',$product_id)->first();
// $qty = (int) $item['qty'];
// $cost = $pr->cost/$pr->units;
// $st = ($cost * $qty);
// $subtotal = $subtotal + $st;
// $bd= ($item['boni']*$cost) + $item['desc'];
// $bonidesc= $bonidesc +$bd;
// $amount = $amount +$st-$bd;
// // $fiscal = $fiscal +$amount;
}
// $fiscal = $amount -$bonidesc-$icetotal;
$balance = 0;
// /////////////////////////hasta qui esta bien al parecer hacer prueba de que fuciona el join de los productos XD
$invoice_dateCC = date("Ymd");
$invoice_date = date("Y-m-d");
$invoice_date_limitCC = date("Y-m-d", strtotime($branch->deadline));
require_once app_path() . '/includes/control_code.php';
$cod_control = codigoControl($invoice_number, $client->nit, $invoice_dateCC, $amount, $branch->number_autho, $branch->key_dosage);
// $ice = DB::table('tax_rates')->select('rate')->where('name','=','ice')->first();
// //
// // creando invoice
$invoice = Invoice::createNew();
$invoice->invoice_number = $invoice_number;
$invoice->client_id = $client_id;
$invoice->user_id = $user_id;
$invoice->account_id = $user->account_id;
$invoice->branch_id = $user->branch_id;
$invoice->amount = number_format((double) $amount, 2, '.', '');
$invoice->subtotal = number_format((double) $amount, 2, '.', '');
$invoice->invoice_design_id = $invoice_design->id;
//------------- hasta aqui funciona despues sale error
$invoice->law = $branch->law;
$invoice->balance = $balance;
$invoice->control_code = $cod_control;
$invoice->start_date = $invoice_date;
$invoice->invoice_date = $invoice_date;
$invoice->activity_pri = $branch->activity_pri;
$invoice->activity_sec1 = $branch->activity_sec1;
// // $invoice->invoice
$invoice->end_date = $invoice_date_limitCC;
// //datos de la empresa atra vez de una consulta XD
// /*****************error generado al intentar guardar **/
// // $invoice->branch = $branch->name;
$invoice->address1 = $branch->address1;
$invoice->address2 = $branch->address2;
$invoice->number_autho = $branch->number_autho;
// $invoice->work_phone=$branch->postal_code;
$invoice->city = $branch->city;
$invoice->state = $branch->state;
// // $invoice->industry_id=$branch->industry_id;
// $invoice->country_id= $branch->country_id;
$invoice->key_dosage = $branch->key_dosage;
$invoice->deadline = $branch->deadline;
// $invoice->custom_value1 =$icetotal;
// $invoice->ice = $ice->rate;
// //cliente
//.........这里部分代码省略.........
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//return 0;
// return Response::json(Input::all());
// $rules = array(
// 'client' => 'required',
// 'invoice' => 'required',
// 'amount' => 'required'
// );
// if (Input::get('invoice')) {
// $invoice = Invoice::scope(Input::get('invoice'))->firstOrFail();
// $rules['amount'] .= '|less_than:' . $invoice->balance;
// }
// if (Input::get('payment_type_id') == PAYMENT_TYPE_CREDIT)
// {
// $rules['payment_type_id'] = 'has_credit:' . Input::get('client') . ',' . Input::get('amount');
// }
// $messages = array(
// 'required' => 'El campo es Requerido',
// 'positive' => 'El Monto debe ser mayor a cero',
// 'less_than' => 'El Monto debe ser menor o igual a ' . $invoice->balance,
// 'has_credit' => 'El Cliente no tiene crédito suficiente'
// );
// $validator = \Validator::make(Input::all(), $rules, $messages);
// if ($validator->fails())
// {
// $url = 'pagos/create';
// return Redirect::to($url)
// ->withErrors($validator)
// ->withInput();
// }
// else
// {
$payment = Payment::createNew();
$paymentTypeId = Input::get('payment_type_id');
$clientId = Input::get('client');
$amount = floatval(Input::get('amount'));
// if ($paymentTypeId == PAYMENT_TYPE_CREDIT)
// {
// $credits = Credit::scope()->where('client_id', '=', $clientId)
// ->where('balance', '>', 0)->orderBy('created_at')->get();
// $applied = 0;
// foreach ($credits as $credit)
// {
// $applied += $credit->apply($amount);
// if ($applied >= $amount)
// {
// break;
// }
// }
// }
// $payment->client_id = $clientId;
// $payment->invoice_id =Input::get('invoice');
// $payment->payment_type_id = $paymentTypeId;
// $payment->user_id = Auth::user()->id;
// $payment->payment_date = date("Y-m-d",strtotime(Input::get('payment_date')));
// $payment->amount = $amount;
// $payment->transaction_reference = trim(Input::get('transaction_reference'));
$payment->setClientId($clientId);
$payment->setInvoiceId(Input::get('invoice'));
$payment->setPaymentTypeId($paymentTypeId);
$payment->setUserId(Auth::user()->id);
$dateparser = explode("/", Input::get('payment_date'));
$date = $dateparser[2] . '-' . $dateparser[1] . '-' . $dateparser[0];
$payment->setPaymentDate($date);
$payment->setAmount($amount);
$payment->setTransactionReference(trim(Input::get('transaction_reference')));
$error = $payment->guardar();
if ($error) {
Session::flash('error', $error);
return Redirect::to('pagos/create');
}
$payment->save();
$cliente = Client::find($payment->client_id);
$cliente->balance = $cliente->balance - $payment->amount;
$cliente->paid_to_date = $cliente->paid_to_date + $payment->amount;
$cliente->save();
$invoice = Invoice::find($payment->invoice_id);
$invoice->balance = $invoice->balance - $payment->amount;
$invoice->save();
if ($paymentTypeId == PAYMENT_TYPE_CREDIT) {
$credits = Credit::scope()->where('client_id', '=', $clientId)->where('balance', '>', 0)->orderBy('created_at')->get();
$applied = 0;
foreach ($credits as $credit) {
$applied += $credit->apply($amount);
if ($applied >= $amount) {
break;
}
}
}
$paymentName = PaymentType::where('id', '=', $paymentTypeId)->first();
if ($invoice->balance == 0) {
// $invoice->invoice_status_id = INVOICE_STATUS_PAID;
Utils::addNote($invoice->id, '<b>' . $invoice->getClientName() . ': </b>Totalmente pagada; se pagó:<b>' . $payment->amount . '</b>Bs, con <b>' . $paymentName->name . '</b>', INVOICE_STATUS_PAID);
} else {
//.........这里部分代码省略.........
示例7: import
public static function import($row)
{
// NOT DONE
$payment = Payment::createNew($row['RECIEPT'], $row['TYPE']);
if (is_object($payment)) {
$payment->setTransferDirection($row['TRANSFERDIRECTION']);
$payment->setTime($row["TIME"]);
$payment->setPhonenumber($row['PHONENUMBER']);
$payment->setName($row['NAME']);
$payment->setAccount($row['ACCOUNT']);
$payment->setStatus($row['STATUS']);
$payment->setAmount($row['AMOUNT']);
$payment->setPostBalance($row['POST_BALANCE']);
$payment->setNote($row['NOTE']);
$payment->update();
}
}
示例8: fire
public function fire()
{
$this->info(date('Y-m-d') . ' Running CreateRandomData...');
$user = User::first();
if (!$user) {
$this->error("Error: please create user account by logging in");
return;
}
$productNames = ['Arkansas', 'New York', 'Arizona', 'California', 'Colorado', 'Alabama', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'Alaska', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];
$clientNames = ['IBM', 'Nestle', 'Mitsubishi UFJ Financial', 'Vodafone', 'Eni', 'Procter & Gamble', 'Johnson & Johnson', 'American International Group', 'Banco Santander', 'BHP Billiton', 'Pfizer', 'Itaú Unibanco Holding', 'Ford Motor', 'BMW Group', 'Commonwealth Bank', 'EDF', 'Statoil', 'Google', 'Siemens', 'Novartis', 'Royal Bank of Canada', 'Sumitomo Mitsui Financial', 'Comcast', 'Sberbank', 'Goldman Sachs Group', 'Westpac Banking Group', 'Nippon Telegraph & Tel', 'Ping An Insurance Group', 'Banco Bradesco', 'Anheuser-Busch InBev', 'Bank of Communications', 'China Life Insurance', 'General Motors', 'Telefónica', 'MetLife', 'Honda Motor', 'Enel', 'BASF', 'Softbank', 'National Australia Bank', 'ANZ', 'ConocoPhillips', 'TD Bank Group', 'Intel', 'UBS', 'Hewlett-Packard', 'Coca-Cola', 'Cisco Systems', 'UnitedHealth Group', 'Boeing', 'Zurich Insurance Group', 'Hyundai Motor', 'Sanofi', 'Credit Agricole', 'United Technologies', 'Roche Holding', 'Munich Re', 'PepsiCo', 'Oracle', 'Bank of Nova Scotia'];
foreach ($productNames as $i => $value) {
$product = Product::createNew($user);
$product->id = $i + 1;
$product->product_key = $value;
$product->save();
}
foreach ($clientNames as $i => $value) {
$client = Client::createNew($user);
$client->name = $value;
$client->save();
$contact = Contact::createNew($user);
$contact->email = "client@aol.com";
$contact->is_primary = 1;
$client->contacts()->save($contact);
$numInvoices = rand(1, 25);
if ($numInvoices == 4 || $numInvoices == 10 || $numInvoices == 25) {
// leave these
} else {
if ($numInvoices % 3 == 0) {
$numInvoices = 1;
} else {
if ($numInvoices > 10) {
$numInvoices = $numInvoices % 2;
}
}
}
$paidUp = rand(0, 1) == 1;
for ($j = 1; $j <= $numInvoices; $j++) {
$price = rand(10, 1000);
if ($price < 900) {
$price = rand(10, 150);
}
$invoice = Invoice::createNew($user);
$invoice->invoice_number = $user->account->getNextInvoiceNumber();
$invoice->amount = $invoice->balance = $price;
$invoice->created_at = date('Y-m-d', strtotime(date("Y-m-d") . ' - ' . rand(1, 100) . ' days'));
$client->invoices()->save($invoice);
$productId = rand(0, 40);
if ($productId > 20) {
$productId = $productId % 2 + rand(0, 2);
}
$invoiceItem = InvoiceItem::createNew($user);
$invoiceItem->product_id = $productId + 1;
$invoiceItem->product_key = $productNames[$invoiceItem->product_id];
$invoiceItem->cost = $invoice->amount;
$invoiceItem->qty = 1;
$invoice->invoice_items()->save($invoiceItem);
if ($paidUp || rand(0, 2) > 1) {
$payment = Payment::createNew($user);
$payment->invoice_id = $invoice->id;
$payment->amount = $invoice->amount;
$client->payments()->save($payment);
}
}
}
}