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; }
/** * @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; }
/** * @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)); }
/** * 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); }
public function getOrderFromPayment(Payment $payment) { $pi = $payment->getPaymentInstruction(); return $this->em->getRepository('FormaLibre\\InvoiceBundle\\Entity\\Order')->findOneBy(array('paymentInstruction' => $pi)); }
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; }
/** * 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; }
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; }
/** * @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; }