コード例 #1
0
 protected function createTransaction($amount, $currency)
 {
     $transaction = new FinancialTransaction();
     $transaction->setState(FinancialTransactionInterface::STATE_PENDING);
     $transaction->setRequestedAmount($amount);
     $paymentInstruction = new PaymentInstruction($amount, $currency, 'sips', new ExtendedData());
     $payment = new Payment($paymentInstruction, $amount);
     $payment->addTransaction($transaction);
     return $transaction;
 }
コード例 #2
0
 /**
  * @return \JMS\Payment\CoreBundle\Entity\ExtendedData|null
  */
 public function getExtendedData()
 {
     if (null !== $this->extendedData) {
         return $this->extendedData;
     }
     if (null !== $this->payment) {
         return $this->payment->getPaymentInstruction()->getExtendedData();
     } else {
         if (null !== $this->credit) {
             return $this->credit->getPaymentInstruction()->getExtendedData();
         }
     }
     return null;
 }
コード例 #3
0
 /**
  * @dataProvider getTestAmountsForDependentCredit
  * @expectedException \InvalidArgumentException
  */
 public function testCreditOnlyAcceptsValidAmountsForDependentCredit($amount)
 {
     $controller = $this->getController();
     $instruction = new PaymentInstruction(111, 'EUR', 'foo', new ExtendedData());
     $instruction->setState(PaymentInstruction::STATE_VALID);
     $credit = new Credit($instruction, 100);
     $payment = new Payment($instruction, 10);
     $payment->setState(Payment::STATE_APPROVED);
     $credit->setPayment($payment);
     $instruction->setDepositedAmount(10);
     $payment->setDepositedAmount(5.0);
     $payment->setCreditingAmount(0.01);
     $payment->setCreditedAmount(0.01);
     $payment->setReversingDepositedAmount(0.01);
     $this->callCredit($controller, array($credit, $amount));
 }
コード例 #4
0
 /**
  * This method adds a Payment container to this PaymentInstruction.
  *
  * This method is called automatically from Payment::__construct().
  *
  * @param Payment $payment
  * @return void
  */
 public function addPayment(Payment $payment)
 {
     if ($payment->getPaymentInstruction() !== $this) {
         throw new \InvalidArgumentException('This payment container belongs to another instruction.');
     }
     $this->payments->add($payment);
 }
コード例 #5
0
 public function getOrderFromPayment(Payment $payment)
 {
     $pi = $payment->getPaymentInstruction();
     return $this->em->getRepository('FormaLibre\\InvoiceBundle\\Entity\\Order')->findOneBy(array('paymentInstruction' => $pi));
 }
コード例 #6
0
 public function testHasPendingTransactionOnPayment()
 {
     $instruction = $this->getInstruction();
     $payment = new Payment($instruction, 100);
     $this->assertFalse($instruction->hasPendingTransaction());
     $transaction = new FinancialTransaction();
     $payment->addTransaction($transaction);
     $transaction->setState(FinancialTransaction::STATE_PENDING);
     $this->assertTrue($instruction->hasPendingTransaction());
 }
 /**
  * @param string $amount
  * @param string $currency
  * @param array  $extendedDataValues
  *
  * @return \JMS\Payment\CoreBundle\Entity\FinancialTransaction
  */
 protected function createTransaction($amount, $currency, array $extendedDataValues = array('CN' => 'Foo Bar'))
 {
     $transaction = new FinancialTransaction();
     $transaction->setRequestedAmount($amount);
     $extendedData = new ExtendedData();
     foreach ($extendedDataValues as $key => $value) {
         $extendedData->set($key, $value);
     }
     $paymentInstruction = new PaymentInstruction($amount, $currency, 'ogone_caa', $extendedData);
     $payment = new Payment($paymentInstruction, $amount);
     $payment->addTransaction($transaction);
     return $transaction;
 }
コード例 #8
0
 /**
  * Creates a payment with sample financial transactions:
  * - 1 APPROVE transaction
  * - 3 DEPOSIT transactions
  * - 2 REVERSE_APPROVAL transactions
  * - 4 REVERSE_DEPOSIT transactions
  * 
  * @return Payment
  */
 protected function getPayment()
 {
     $payment = new Payment($this->getInstruction(), 123.45);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_APPROVE);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_APPROVAL);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_APPROVAL);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_DEPOSIT);
     $payment->addTransaction($transaction);
     $transaction = new FinancialTransaction();
     $transaction->setTransactionType(FinancialTransaction::TRANSACTION_TYPE_REVERSE_DEPOSIT);
     $payment->addTransaction($transaction);
     return $payment;
 }
コード例 #9
0
 protected function getTransaction($withCredit = false)
 {
     $instruction = new PaymentInstruction(123, 'EUR', 'foo', new ExtendedData());
     $transaction = new FinancialTransaction();
     if (!$withCredit) {
         $payment = new Payment($instruction, 100);
         $payment->addTransaction($transaction);
     } else {
         $credit = new Credit($instruction, 123.45);
         $credit->addTransaction($transaction);
     }
     return $transaction;
 }
コード例 #10
0
 /**
  * @param $amount
  * @param $currency
  * @param $data
  * @return \JMS\Payment\CoreBundle\Entity\FinancialTransaction
  */
 protected function createTransaction($amount, $currency)
 {
     $transaction = new FinancialTransaction();
     $transaction->setRequestedAmount($amount);
     $paymentInstruction = new PaymentInstruction($amount, $currency, 'paypal_express_checkout', new ExtendedData());
     $payment = new Payment($paymentInstruction, $amount);
     $payment->addTransaction($transaction);
     return $transaction;
 }