/** * @param Amount $amount * @param ItemList $itemLists * @param string $invoiceNumber * @param string $description * * @return Transaction */ public static function createTransaction(Amount $amount, ItemList $itemLists, $invoiceNumber, $description) { $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setItemList($itemLists); $transaction->setInvoiceNumber($invoiceNumber); $transaction->setDescription($description); return $transaction; }
public static function createTransaction() { $transaction = new Transaction(); $transaction->setAmount(AmountTest::createAmount()); $transaction->setDescription(self::$description); $transaction->setInvoiceNumber(self::$invoiceNumber); $transaction->setCustom(self::$custom); $transaction->setSoftDescriptor(self::$softDescriptor); $transaction->setItemList(ItemListTest::createItemList()); $transaction->setPayee(PayeeTest::createPayee()); $transaction->setRelatedResources(array(RelatedResourcesTest::createRelatedResources())); return $transaction; }
public function callCreate($clientId, $clientSecret, $orderId, $amount, $currency, $description, $returnUrl, $cancelUrl) { $oauthCredential = new OAuthTokenCredential($clientId, $clientSecret); $apiContext = new ApiContext($oauthCredential); $apiContext->setConfig(['mode' => $this->mode]); $payer = new Payer(); $payer->setPaymentMethod('paypal'); $item = new Item(); $item->setName($description); $item->setCurrency($currency); $item->setPrice($amount); $item->setQuantity(1); $itemList = new ItemList(); $itemList->setItems(array($item)); $amountObject = new Amount(); $amountObject->setCurrency($currency); $amountObject->setTotal($amount); $transaction = new Transaction(); $transaction->setItemList($itemList); $transaction->setAmount($amountObject); $transaction->setDescription($description); $transaction->setInvoiceNumber($orderId); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setRedirectUrls($redirectUrls); $payment->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (\Exception $e) { throw new PaymentException('PayPal Exception: ' . $e->getMessage()); } $approvalUrl = $payment->getApprovalLink(); return $approvalUrl; }
public function setPaypalTransaction($amount, $descr, $invoiceNumber, $itemList) { $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription($descr); $transaction->setInvoiceNumber($invoiceNumber); $transaction->setItemList($itemList); return $transaction; }