本文整理汇总了PHP中PayPal\Api\Item::setSku方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::setSku方法的具体用法?PHP Item::setSku怎么用?PHP Item::setSku使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Item
的用法示例。
在下文中一共展示了Item::setSku方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createItem
/**
* @param string $name
* @param int $currency
* @param int $quantity
* @param string $sku
* @param int $price
* @return Item
*/
public static function createItem($name, $currency, $quantity, $sku, $price)
{
$item = new Item();
$item->setName($name);
$item->setCurrency($currency);
$item->setQuantity($quantity);
$item->setSku($sku);
$item->setPrice($price);
return $item;
}
示例2: createItem
public static function createItem()
{
$item = new Item();
$item->setName(self::$name);
$item->setPrice(self::$price);
$item->setQuantity(self::$quantity);
$item->setSku(self::$sku);
$item->setCurrency(self::$currency);
return $item;
}
示例3: setPaypalItem
public function setPaypalItem($name, $currency, $quantity, $sku, $price)
{
$price = number_format($price, 2);
$item = new Item();
$item->setQuantity($quantity);
$item->setName($name);
$item->setPrice($price);
$item->setCurrency($currency);
$item->setSku($sku);
return $item;
}
示例4: createPayment
private function createPayment($details)
{
$payment = new Payment();
$payer = new Payer();
$payer->payment_method = "paypal";
$amount = new Amount();
$amount->currency = $details['PAYMENTREQUEST_CURRENCYCODE'];
$amount->total = $details['PAYMENTREQUEST_AMT'];
$transaction = new Transaction();
$transaction->amount = $amount;
$transaction->description = $details['PAYMENTREQUEST_DESCRIPTION'];
$itemList = new ItemList();
foreach ($details['PAYMENTREQUEST_ITEMS'] as $itemInfo) {
$item = new Item();
$item->setQuantity($itemInfo['quantity']);
$item->setName($itemInfo['name']);
$item->setDescription($itemInfo['description']);
$item->setPrice($itemInfo['price']);
$item->setCategory($itemInfo['category']);
$item->setCurrency($itemInfo['currency']);
$item->setTax($itemInfo['tax']);
$item->setSku($itemInfo['sku']);
$itemList->addItem($item);
}
$addressInfo = $details['PAYMENTREQUEST_SHIPPING_ADDRESS'];
$shippingAddress = new ShippingAddress();
$shippingAddress->setRecipientName($addressInfo['recipient_name']);
$shippingAddress->setLine1($addressInfo['line1']);
$shippingAddress->setPostalCode($addressInfo['postal_code']);
$shippingAddress->setCity($addressInfo['city']);
$shippingAddress->setCountryCode($addressInfo['country_code']);
$itemList->setShippingAddress($shippingAddress);
$transaction->setItemList($itemList);
$redirectUrls = new RedirectUrls();
$redirectUrls->return_url = $details['RETURN_URL'];
$redirectUrls->cancel_url = $details['CANCEL_URL'];
$payment->intent = "sale";
$payment->payer = $payer;
$payment->redirect_urls = $redirectUrls;
$payment->transactions = [$transaction];
if (false == isset($details['response']) && false == isset($details['response']['state']) && isset($payment->payer->payment_method) && 'paypal' == $payment->payer->payment_method) {
$paymentResponse = $payment->create($this->api);
$details->replace(['response' => $paymentResponse->toArray()]);
foreach ($paymentResponse->links as $link) {
if ($link->rel == 'approval_url') {
$details->replace(['approval_url' => $link->href]);
}
}
}
}
示例5: getItemList
/**
* @return ItemList
*/
protected function getItemList()
{
$items = array();
foreach ($this->order->get_order_items() as $order_item) {
/** @var \AppZap\Payment\Model\OrderItem $order_item */
$item = new Item();
$item->setName($order_item->get_title());
$item->setQuantity($order_item->get_quantity());
$item->setSku($order_item->get_article_number());
$item->setPrice($order_item->get_price());
$item->setCurrency("EUR");
$items[] = $item;
}
$itemList = new ItemList();
$itemList->setItems($items);
return $itemList;
}
示例6: create
public static function create($items, Details $shippingDetails, $paymentIntent, $paymentMethod, $fi = null)
{
$payer = new Payer();
$payer->setPaymentMethod($paymentMethod);
if ($fi !== null) {
$payer->setFundingInstruments(array($fi));
}
$fullList = array();
foreach ($items as $item) {
if (!$item instanceof ItemInterface) {
throw new Exception('All the item created for the payment MUST implement the ItemInterface');
}
$singleItem = new Item();
$singleItem->setName($item->getName());
$singleItem->setSku($item->getSku());
$singleItem->setCurrency($item->getCurrency());
$singleItem->setPrice($item->getPrice());
$singleItem->setQuantity($item->getQuantity());
$fullList[] = $singleItem;
}
$itemList = new ItemList();
$itemList->setItems($fullList);
$details = $shippingDetails;
$subtotal = 0.0;
/** @var Item $singleItem */
foreach ($fullList as $singleItem) {
$subtotal += floatval($singleItem->getPrice()) * floatval($singleItem->getQuantity());
}
$details->setSubtotal($subtotal);
$total = $subtotal + floatval($details->getTax()) + floatval($details->getShipping());
$currencyMode = Validation::currencyMode($items);
$amount = new Amount();
$amount->setCurrency($currencyMode)->setTotal($total)->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList);
$payment = new Payment();
$payment->setIntent($paymentIntent)->setPayer($payer)->setTransactions(array($transaction));
return $payment;
}
示例7: makePaymentUsingPayPal
/**
* [makePaymentUsingPayPal description]
* @param [type] $order [description]
* @param [type] $currency [description]
* @param [type] $returnUrl [description]
* @param [type] $cancelUrl [description]
* @return [type] [description]
*/
function makePaymentUsingPayPal($order, $currency, $returnUrl, $cancelUrl)
{
$payer = new Payer();
$payer->setPaymentMethod("paypal");
// $payee = new Payee();
// $payee->setEmail((string)$order['email_paypal']);
// Specify the payment amount.
$item = new Item();
$item->setQuantity((string) $order['quantity']);
$item->setName($order['description']);
$item->setPrice((string) $order['input_price']);
$item->setCurrency($currency);
$item->setSku($order['item_number']);
$array_item[] = $item;
if (isset($order['price_ship'])) {
$item_ship = new Item();
$item_ship->setQuantity('1');
$item_ship->setName('shipping');
$item_ship->setPrice((string) $order['price_ship']);
$item_ship->setCurrency($currency);
$item_ship->setSku('shipping');
$array_item[] = $item_ship;
}
$item_list = new ItemList();
$item_list->setItems($array_item);
$amount = new Amount();
$amount->setCurrency($currency);
$amount->setTotal((string) $order['total']);
//$amount->setTax()
// ###Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it. Transaction is created with
// a `Payee` and `Amount` types
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription($order['description']);
$transaction->setItemList($item_list);
// $transaction->setPayee($payee);
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($returnUrl);
$redirectUrls->setCancelUrl($cancelUrl);
$payment = new Payment();
$payment->setRedirectUrls($redirectUrls);
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->create($this->getApiContext());
return $payment;
}
示例8: createItem
/**
* Creates a single PayPal item from given order product
*
* @param OrderProductInterface $orderProduct
*
* @return Item
*/
protected function createItem(OrderProductInterface $orderProduct) : Item
{
$item = new Item();
$item->setName($orderProduct->getProduct()->translate()->getName());
$item->setCurrency($orderProduct->getSellPrice()->getCurrency());
$item->setQuantity($orderProduct->getQuantity());
$item->setSku($orderProduct->getProduct()->getSku());
$item->setPrice($orderProduct->getSellPrice()->getNetAmount());
$item->setTax($orderProduct->getSellPrice()->getTaxAmount());
return $item;
}
示例9: buildItemList
/**
* Build ItemList
*
* @param Mage_Sales_Model_Quote $quote
* @return ItemList
*/
protected function buildItemList($quote, $taxFailure)
{
$itemArray = array();
$itemList = new ItemList();
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
if (!$taxFailure) {
foreach ($quote->getAllVisibleItems() as $quoteItem) {
$item = new Item();
if ($quoteItem->getQty() > 1) {
$item->setName($quoteItem->getName() . ' x' . $quoteItem->getQty());
} else {
$item->setName($quoteItem->getName());
}
$item->setSku($quoteItem->getSku())->setCurrency($currencyCode)->setQuantity(1)->setPrice($quoteItem->getRowTotal());
$itemArray[] = $item;
}
$itemList->setItems($itemArray);
}
return $itemList;
}
示例10: generateItemsList
function generateItemsList($order)
{
$currency = $this->properties->getCurrency();
$orderItems = $order->items;
$items = array();
foreach ($orderItems as $orderItem) {
$item = new Item();
$item->setName($orderItem->name);
$item->setQuantity($orderItem->quantity);
$item->setCurrency($currency);
$item->setPrice($orderItem->price);
if (isset($orderItem->sku)) {
$item->setSku($orderItem->sku);
}
$items[] = $item;
}
$itemList = new ItemList();
$itemList->setItems($items);
return $itemList;
}
示例11: payThroughPayPal
/**
* Создаем платеж типа paypal
* в случае успеха возвращает массив с ид-платежа,
* токеном и редирект-урлом куда нужно направить пользователя для оплаты
*
* @param double $pay_sum
* @param string $paymentInfo
* @param string $sku - internal UNIT ID
*
* @return array | null
*/
public function payThroughPayPal($pay_sum, $paymentInfo, $sku = null)
{
set_time_limit(120);
$payer = new Payer();
$payer->setPaymentMethod('paypal');
$amount = new Amount();
$amount->setCurrency('USD');
$amount->setTotal($pay_sum);
$item1 = new Item();
$item1->setName($paymentInfo)->setCurrency('USD')->setQuantity(1)->setPrice($pay_sum);
// Ид товара/услуги на вашей стороне
if ($sku) {
$item1->setSku($sku);
}
$itemList = new ItemList();
$itemList->setItems([$item1]);
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('Payment to DirectLink');
$transaction->setItemList($itemList);
$transaction->setNotifyUrl($this->config['url.notify_url']);
//**
$redirect_urls = new RedirectUrls();
$redirect_urls->setReturnUrl($this->config['url.return_url']);
$redirect_urls->setCancelUrl($this->config['url.cancel_url']);
$payment = new Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setTransactions([$transaction]);
$payment->setRedirectUrls($redirect_urls);
//$payment->setId('123456789'); //**
$payment->create($this->_apiContext);
//var_dump($payment); exit;
$links = $payment->getLinks();
foreach ($links as $link) {
if ($link->getMethod() == 'REDIRECT') {
$redirect_to = $link->getHref();
$token = time() . "_" . rand(100, 999);
$tmp = parse_url($redirect_to);
if (isset($tmp['query'])) {
parse_str($tmp['query'], $out);
if (isset($out['token'])) {
$token = $out['token'];
}
}
$paymentId = $payment->getId();
// ++ DEBUG LOG
$this->logging_queryes('paymentCreate_' . $paymentId . '.txt', $payment->toJSON());
// -- DEBUG LOG
return ['paymentId' => $paymentId, 'token' => $token, 'redirect_to' => $redirect_to];
}
}
return null;
}