本文整理汇总了PHP中Invoice::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::getItems方法的具体用法?PHP Invoice::getItems怎么用?PHP Invoice::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::getItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculate
public function calculate(Invoice $invoiceBill)
{
$this->coupon = $invoiceBill->getCoupon();
$this->user = $invoiceBill->getUser();
$isFirstPayment = $invoiceBill->isFirstPayment();
foreach ($invoiceBill->getItems() as $item) {
$item->first_discount = $item->second_discount = 0;
$item->_calculateTotal();
}
if (!$this->coupon) {
return;
}
if ($this->coupon->getBatch()->discount_type == Coupon::DISCOUNT_PERCENT) {
foreach ($invoiceBill->getItems() as $item) {
if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
$item->first_discount = moneyRound($item->first_total * $this->coupon->getBatch()->discount / 100);
}
if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
$item->second_discount = moneyRound($item->second_total * $this->coupon->getBatch()->discount / 100);
}
}
} else {
// absolute discount
$discountFirst = $this->coupon->getBatch()->discount;
$discountSecond = $this->coupon->getBatch()->discount;
$first_discountable = $second_discountable = array();
$first_total = $second_total = 0;
$second_total = array_reduce($second_discountable, create_function('$s,$item', 'return $s+=$item->second_total;'), 0);
foreach ($invoiceBill->getItems() as $item) {
if ($this->coupon->isApplicable($item->item_type, $item->item_id, $isFirstPayment)) {
$first_total += $item->first_total;
$first_discountable[] = $item;
}
if ($this->coupon->isApplicable($item->item_type, $item->item_id, false)) {
$second_total += $item->second_total;
$second_discountable[] = $item;
}
}
if ($first_total) {
$k = max(0, min($discountFirst / $first_total, 1));
// between 0 and 1!
foreach ($first_discountable as $item) {
$item->first_discount = moneyRound($item->first_total * $k);
}
}
if ($second_total) {
$k = max(0, min($discountSecond / $second_total, 1));
// between 0 and 1!
foreach ($second_discountable as $item) {
$item->second_discount = moneyRound($item->second_total * $k);
}
}
}
foreach ($invoiceBill->getItems() as $item) {
$item->_calculateTotal();
}
}
示例2: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$a = new Am_Paysystem_Action_Form(self::URL);
$vars = array('MERCHANT' => $this->getConfig('merchant'), 'ORDER_REF' => $invoice->public_id, 'ORDER_DATE' => $invoice->tm_added);
foreach ($invoice->getItems() as $item) {
$vars['ORDER_PNAME[]'] = $item->item_title;
$vars['ORDER_PCODE[]'] = $item->item_id;
$vars['ORDER_PRICE[]'] = $item->first_price;
$vars['ORDER_QTY[]'] = $item->qty;
$vars['ORDER_VAT[]'] = $item->first_tax;
}
$vars['ORDER_SHIPPING'] = 0;
$vars['PRICES_CURRENCY'] = strtoupper($invoice->currency);
$vars['DISCOUNT'] = $invoice->first_discount;
foreach ($vars as $k => $v) {
$a->__set($k, $v);
}
$a->__set('ORDER_HASH', $this->calculateHash($vars));
$a->__set('BILL_FNAME', $invoice->getFirstName());
$a->__set('BILL_LNAME', $invoice->getLastName());
$a->__set('BILL_EMAIL', $invoice->getEmail());
$a->__set('BILL_PHONE', $invoice->getPhone());
$a->__set('BILL_ADDRESS', $invoice->getStreet());
$a->__set('BILL_ZIPCODE', $invoice->getZip());
$a->__set('BILL_CITY', $invoice->getCity());
$a->__set('BILL_STATE', $invoice->getState());
$a->__set('BILL_COUNTRYCODE', $invoice->getCountry());
$a->__set('LANGUAGE', $this->getConfig('language', 'ro'));
if ($this->getConfig('testing')) {
$a->__set('TESTORDER', 'TRUE');
}
$result->setAction($a);
}
示例3: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$a = new Am_Paysystem_Action_Redirect(self::URL);
$a->products = current(array_filter(array($invoice->getItem(0)->getBillingPlanData('paypro_product_id'), $this->getConfig('product_id'))));
$id = $this->invoice->getSecureId("THANKS");
$desc = array();
foreach ($invoice->getItems() as $it) {
if ($it->first_total > 0) {
$desc[] = $it->item_title;
}
}
$desc = implode(',', $desc);
$desc .= ". (invoice: {$id})";
$name = $invoice->getLineDescription();
$hash = "price={$invoice->first_total}-{$invoice->currency}^^^name={$name}^^^desc={$desc}";
$a->hash = base64_encode($this->getHash($hash));
$a->CustomField1 = $invoice->public_id;
$a->firstname = $invoice->getFirstName();
$a->Lastname = $invoice->getLastName();
$a->Email = $invoice->getEmail();
$a->Address = $invoice->getStreet();
$a->City = $invoice->getCity();
$a->Country = $invoice->getCountry() == 'GB' ? 'united kingdom' : $invoice->getCountry();
$a->State = $invoice->getState();
$a->Zipcode = $invoice->getZip();
$a->Phone = $invoice->getPhone();
//$a->lnk = $this->getCancelUrl();
$result->setAction($a);
}
示例4: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$items = $invoice->getItems();
if (count($items) > 1) {
$exc = new Am_Exception_InternalError("It's impossible purchase " . count($items) . " products at one invoice with Selz-plugin");
$this->getDi()->errorLogTable->logException($exc);
throw $exc;
}
$item = $items[0];
$bp = $this->getDi()->billingPlanTable->load($item->billing_plan_id);
$sharedLink = $bp->data()->get(self::SHARED_LINK_FIELD);
if (!$sharedLink) {
$exc = new Am_Exception_InternalError("Product #{$item->item_id} has no shared link");
$this->getDi()->errorLogTable->logException($exc);
throw $exc;
}
if ($this->getConfig('payment_way', 'redirect') == 'redirect') {
$a = new Am_Paysystem_Action_Redirect($sharedLink);
} else {
$a = new Am_Paysystem_Action_HtmlTemplate_Selz($this->getDir(), 'selz.phtml');
$a->link = $sharedLink;
$a->inv = $invoice->public_id;
$a->thanks = $this->getReturnUrl();
$a->ipn = $this->getPluginUrl('ipn');
$a->way = $this->getConfig('payment_way');
}
$result->setAction($a);
}
示例5: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$a = new Am_Paysystem_Action_Form(self::URL);
$vars = array('MERCHANT' => $this->getConfig('email'), 'COUNTRY_ID' => $this->getConfig('country'), 'PAYMENT_METHOD_AVAILABLE' => 'all', 'TRANSACTION_ID' => $invoice->public_id);
$i = '1';
foreach ($invoice->getItems() as $item) {
//Creating new format without dot for $item->first_price
$price = str_replace('.', '', $item->first_total);
$vars['ITEM_NAME_' . $i] = $item->item_title;
$vars['ITEM_CODE_' . $i] = $item->item_id;
$vars['ITEM_AMMOUNT_' . $i] = $price;
$vars['ITEM_QUANTITY_' . $i] = $item->qty;
$vars['ITEM_CURRENCY_' . $i] = $item->currency;
$i++;
}
$vars['CURRENCY'] = strtoupper($invoice->currency);
foreach ($vars as $k => $v) {
$a->__set($k, $v);
}
$a->__set('BUYER_FNAME', $invoice->getFirstName());
$a->__set('BUYER_LNAME', $invoice->getLastName());
$a->__set('BUYER_EMAIL', $invoice->getEmail());
$a->__set('BUYER_PHONE', $invoice->getPhone());
$a->__set('BUYER_STREET', $invoice->getStreet());
$a->__set('BUYER_STATE', $invoice->getState());
$a->__set('BUYER_CITY', $invoice->getCity());
$a->__set('BUYER_COUNTRY', $invoice->getCountry());
$a->__set('BUYER_ZIP_CODE', $invoice->getZip());
$a->__set('BUYER_CITY', $invoice->getCity());
$a->__set('BUYER_STATE', $invoice->getState());
$a->__set('LANGUAGE', $this->getConfig('language', 'es'));
$result->setAction($a);
}
示例6: calculate
public function calculate(Invoice $invoiceBill)
{
$this->invoiceBill = $invoiceBill;
foreach ($invoiceBill->getItems() as $item) {
$this->item = $item;
foreach (self::$_prefixes as $prefix) {
$this->currentPrefix = $prefix;
$fields = new stdClass();
foreach (self::$_noPrefixFields as $k) {
$fields->{$k} = @$item->{$k};
}
foreach (self::$_prefixFields as $k) {
$kk = $prefix ? $prefix . $k : $k;
if (isset($fields->{$kk})) {
throw new Am_Exception_InternalError("Field is already defined [{$k}]");
}
$fields->{$k} = @$item->{$kk};
}
$this->calculatePiece($fields);
foreach (self::$_noPrefixFields as $k) {
$item->{$k} = $fields->{$k};
}
foreach (self::$_prefixFields as $k) {
$kk = $prefix ? $prefix . $k : $k;
$item->{$kk} = $fields->{$k};
}
}
unset($this->item);
}
}
示例7: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$u = $invoice->getUser();
$domain = $this->getConfig('testing') ? Am_Paysystem_Xfers::SANDBOX_DOMAIN : Am_Paysystem_Xfers::LIVE_DOMAIN;
$a = new Am_Paysystem_Action_Form('https://' . $domain . '/api/v2/payments');
$a->api_key = $this->getConfig('api_key');
$a->order_id = $invoice->public_id;
$a->cancel_url = $this->getCancelUrl();
$a->return_url = $this->getReturnUrl();
$a->notify_url = $this->getPluginUrl('ipn');
if ($invoice->first_tax) {
$a->tax = $invoice->first_tax;
}
/* @var $item InvoiceItem */
$i = 1;
foreach ($invoice->getItems() as $item) {
$a->{'item_name_' . $i} = $item->item_title;
$a->{'item_description_' . $i} = $item->item_description;
$a->{'item_quantity_' . $i} = $item->qty;
$a->{'item_price_' . $i} = $item->first_price;
$i++;
}
$a->total_amount = $invoice->first_total;
$a->currency = $invoice->currency;
$a->user_email = $invoice->getUser()->email;
$a->signature = sha1($a->api_key . $this->getConfig('api_secret') . $a->order_id . $a->total_amount . $a->currency);
$result->setAction($a);
}
示例8: isNotAcceptableForInvoice
public function isNotAcceptableForInvoice(Invoice $invoice)
{
foreach ($invoice->getItems() as $item) {
/* @var $item InvoiceItem */
if (!$item->getBillingPlanData('centili_apikey')) {
return "item [" . $item->item_title . "] has no related Centili Api Key configured";
}
}
}
示例9: getModel
/**
* @param Invoice $dataObject
* @return \Magento\Sales\Model\Order\Invoice
* @throws \Exception
*/
public function getModel(Invoice $dataObject)
{
$items = [];
/** @var InvoiceItem $item */
foreach ($dataObject->getItems() as $item) {
$items[$item->getOrderItemId()] = $item->getQty();
}
return $this->invoiceLoader->setOrderId($dataObject->getOrderId())->setInvoiceId($dataObject->getEntityId())->setInvoiceItems($items)->create();
}
示例10: isNotAcceptableForInvoice
public function isNotAcceptableForInvoice(Invoice $invoice)
{
$items = $invoice->getItems();
if (count($items) > 1) {
return 'Justclick can not process invoices with more than one item';
}
/* @var $item InvoiceItem */
if (!$items[0]->getBillingPlanData('justclick_id')) {
return "item [" . $item->item_title . "] has no related Justclick product configured";
}
}
示例11: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
if (count($invoice->getItems()) > 1) {
throw new Am_Exception_InternalError('Only one product at invoice is allowed');
}
$bp = $this->getDi()->billingPlanTable->load($invoice->getItem(0)->billing_plan_id);
if (!($campaignId = $bp->data()->get(self::JP_CAMPAIGN_ID))) {
throw new Am_Exception_InternalError("Product #{$invoice->getItem(0)->item_id} cannot be paid by junglepay - has no Campaign ID");
}
$a = new Am_Paysystem_Action_HtmlTemplate_Junglepay($this->getDir(), 'payment-junglepay-iframe.phtml');
$a->wkey = $campaignId;
$a->refererId = $invoice->public_id;
$result->setAction($a);
}
示例12: encodeInvoice
public function encodeInvoice(Invoice $invoice)
{
$data = ['id' => $invoice->getId(), 'number' => $invoice->getNumber(), 'name' => $invoice->getName(), 'created' => $invoice->getCreated(), 'delivered' => $invoice->getDelivered(), 'due' => $invoice->getDue(), 'status' => $invoice->getStatus(), 'variable_symbol' => $invoice->getVariableSymbol(), 'constant_symbol' => $invoice->getConstantSymbol(), 'description' => $invoice->getDescription(), 'items' => $this->encodeItems($invoice->getItems()), 'price' => $invoice->getPrice(), 'price_total' => $invoice->getPriceTotal(), 'currency' => $invoice->getCurrency()];
if ($invoice->getClient()) {
$data['client'] = $this->encodeClient($invoice->getClient());
}
if ($invoice->getShippingAddress()) {
$data['shipping_address'] = $this->encodeAddress($invoice->getShippingAddress());
}
if ($invoice->getDiscount() && $invoice->getDiscount()->getType() != 'none') {
$data['discount'] = ['type' => $invoice->getDiscount()->getType(), 'value' => $invoice->getDiscount()->getValue()];
}
return json_encode(['invoice' => $data]);
}
示例13: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$u = $invoice->getUser();
$request = $this->createHttpRequest();
$basket = '<basket>';
foreach ($invoice->getItems() as $item) {
$basket .= '<item>';
$basket .= '<description>' . $item->item_title . '</description>';
$basket .= '<productSku>' . $item->item_id . '</productSku>';
$basket .= '<quantity>' . $item->qty . '</quantity>';
$basket .= '<unitNetAmount>' . $item->first_price . '</unitNetAmount>';
$basket .= '<unitTaxAmount>' . $item->first_tax / $item->qty . '</unitTaxAmount>';
$basket .= '<unitGrossAmount>' . $item->first_total / $item->qty . '</unitGrossAmount>';
$basket .= '<totalGrossAmount>' . $item->first_total . '</totalGrossAmount>';
$basket .= '</item>';
}
$basket .= '</basket>';
$vars = array('VPSProtocol' => '3.0', 'TxType' => 'PAYMENT', 'Vendor' => $this->getConfig('login'), 'VendorTxCode' => $invoice->public_id . '-AMEMBER', 'Amount' => number_format($invoice->first_total, 2, '.', ''), 'Currency' => $invoice->currency ? $invoice->currency : 'USD', 'Description' => $invoice->getLineDescription(), 'NotificationURL' => $this->getPluginUrl('ipn'), 'SuccessURL' => $this->getReturnUrl(), 'RedirectionURL' => $this->getReturnUrl(), 'BillingFirstnames' => $u->name_f, 'BillingSurname' => $u->name_l, 'BillingAddress1' => $u->street, 'BillingCity' => $u->city, 'BillingPostCode' => $u->zip, 'BillingCountry' => $u->country, 'DeliveryFirstnames' => $u->name_f, 'DeliverySurname' => $u->name_l, 'DeliveryAddress1' => $u->street, 'DeliveryCity' => $u->city, 'DeliveryPostCode' => $u->zip, 'DeliveryCountry' => $u->country, 'CustomerEMail' => $u->email, 'Profile' => 'NORMAL', 'BasketXML' => $basket);
if ($u->country == 'US') {
$vars['BillingState'] = $u->state;
$vars['DeliveryState'] = $u->state;
}
$request->addPostParameter($vars);
$request->setUrl($this->getConfig('testing') ? self::TEST_URL : self::LIVE_URL);
$request->setMethod(Am_HttpRequest::METHOD_POST);
$this->logRequest($request);
$response = $request->send();
$this->logResponse($response);
if (!$response->getBody()) {
throw new Am_Exception_InputError("An error occurred while payment request");
}
$res = array();
foreach (split(PHP_EOL, $response->getBody()) as $line) {
list($l, $r) = explode('=', $line, 2);
$res[trim($l)] = trim($r);
}
if ($res['Status'] == 'OK') {
$invoice->data()->set('sagepay_securitykey', $res['SecurityKey']);
$invoice->update();
$a = new Am_Paysystem_Action_Form($res['NextURL']);
$result->setAction($a);
} else {
throw new Am_Exception_InputError($res['StatusDetail']);
}
}
示例14: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$a = new Am_Paysystem_Action_Redirect($this->getConfig('testing') ? self::SANDBOX_URL : self::LIVE_URL);
$a->merchant_id = $this->getConfig('merchant_id');
$a->merchant_site_id = $this->getConfig('merchant_site_id');
$a->currency = $invoice->currency;
$a->version = '3.0.0';
$a->merchant_unique_id = $invoice->public_id;
$a->first_name = $invoice->getFirstName();
$a->last_name = $invoice->getLastName();
$a->email = $invoice->getEmail();
$a->address1 = $invoice->getStreet();
$a->address2 = $invoice->getStreet1();
$a->city = $invoice->getCity();
$a->country = $invoice->getCountry();
$a->state = $invoice->getState();
$a->zip = $invoice->getZip();
$a->phone1 = $invoice->getPhone();
$a->time_stamp = date("Y-m-d.h:i:s");
if ($invoice->rebill_times && ($gate2shop_id = $invoice->getItem(0)->getBillingPlanData('gate2shop_id')) && ($gate2shop_template_id = $invoice->getItem(0)->getBillingPlanData('gate2shop_template_id'))) {
$a->productId = $invoice->getItem(0)->item_id;
$a->rebillingProductId = $gate2shop_id;
$a->rebillingTemplateId = $gate2shop_template_id;
if ($invoice->rebill_times) {
$a->isRebilling = 'true';
}
$a->checksum = md5($this->getConfig('secret_key') . $this->getConfig('merchant_id') . $gate2shop_id . $gate2shop_template_id . $a->time_stamp);
} else {
$a->total_amount = $invoice->first_total;
$a->discount = $invoice->first_discount;
$a->total_tax = $invoice->first_tax;
$a->numberofitems = count($invoice->getItems());
for ($i = 0; $i < $a->numberofitems; $i++) {
$item = $invoice->getItem($i);
$a->addParam('item_name_' . ($i + 1), $item->item_title);
$a->addParam('item_number_' . ($i + 1), $i + 1);
$a->addParam('item_amount_' . ($i + 1), $item->first_price);
$a->addParam('item_discount_' . ($i + 1), $item->first_discount);
$a->addParam('item_quantity_' . ($i + 1), $item->qty);
}
$a->checksum = $this->calculateOutgoingHash($a, $invoice);
}
$a->filterEmpty();
$result->setAction($a);
}
示例15: findUpgrades
/**
* @param Invoice $invoice
* @return array of ProductUpgrade
*/
function findUpgrades(Invoice $invoice)
{
$items = $invoice->getItems();
if (!$items) {
return array();
}
static $cache;
if (empty($cache)) {
foreach ($this->_db->select("SELECT * FROM {$this->_table}") as $row) {
$cache[$row['from_billing_plan_id']][] = $row;
}
}
$ret = array();
foreach ((array) @$cache[$items[0]->billing_plan_id] as $row) {
$ret[] = $this->createRecord($row);
}
return $ret;
}