Пример #1
0
 public function finalizeTransaction(TierDescriptor $tiers, TransactionRepository $transactions, TransactionResultListener $resultListener)
 {
     $txId = Request::get("tx");
     // $st = Request::get('st');
     // $amt = Request::get('amt');
     $r = $this->callPayPalAPI($this->formUrl(), ["cmd" => "_notify-synch", "tx" => $txId, "at" => $this->pdtToken(), "submit" => "PDT"]);
     if ($r[0] == "SUCCESS") {
         $status = "success";
     } else {
         $status = $r[0];
     }
     $buyerId = Auth::user()->getAuthIdentifier();
     $money = $r['mc_gross'];
     $product = array_get($r, 'custom', 'free');
     $tierPrice = floatval($tiers->getTierPrice($product));
     if ($tierPrice > floatval($money)) {
         return $resultListener->transactionFail(null, sprintf(_("You did not pay the full amount of the price for the item! (For further information, the transaction id is %s)"), $txId));
     }
     $extra = json_encode($r);
     $tx = new PaypalTransaction($txId, $status, $buyerId, $money, $product, $extra);
     if ($tx->getStatus() == "success") {
         $transactions->saveOrUpdateTransaction($tx);
         return $resultListener->transactionOk($tx);
     } else {
         return $resultListener->transactionFail($tx, sprintf(_("The transaction did not commit. The current status is %s"), $tx->getStatus()));
     }
 }
 /**
  * @param TierDescriptor $_tiers
  * @param TransactionRepository $_transactions
  * @param TransactionResultListener $resultListener
  */
 public function finalizeTransaction(TierDescriptor $_tiers, TransactionRepository $_transactions, TransactionResultListener $resultListener)
 {
     $resultListener->transactionFail(null, _("You must pay the amount via wire transfer and then request review status by a staff member for this transaction method."));
 }