public function testCreateIdentifier() { $payment = new Payment(); $payment->write(); $this->assertNotNull($payment->Identifier); $this->assertNotEquals('', $payment->Identifier); $this->assertEquals(30, strlen($payment->Identifier)); }
/** * Mark this payment process as completed. * This sets the desired end-status on the payment, sets the transaction reference and writes the payment. * * In subclasses, you'll want to override this and: * * Log/Write the GatewayMessage * * Call a "complete" hook * * Don't forget to call the parent method from your subclass! * * @param string $endStatus the end state to set on the payment * @param ServiceResponse $serviceResponse the service response * @param mixed $gatewayMessage the message from Omnipay * @return void */ protected function markCompleted($endStatus, ServiceResponse $serviceResponse, $gatewayMessage) { $this->payment->Status = $endStatus; if ($gatewayMessage && ($reference = $gatewayMessage->getTransactionReference())) { $this->payment->TransactionReference = $reference; } $this->payment->write(); }
/** * Save preliminary data to database before processing payment */ public function setup() { $this->payment->Amount->Amount = $this->paymentData['Amount']; $this->payment->Amount->Currency = $this->paymentData['Currency']; $this->payment->Reference = isset($this->paymentData['Reference']) ? $this->paymentData['Reference'] : null; $this->payment->Status = Payment::PENDING; $this->payment->Method = $this->methodName; $this->payment->write(); }
protected function migrateRecord($record) { $payment = new Payment($record); $payment->Status = "Created"; $payment->ClassName = "Payment"; $payment->MoneyAmount = $record['AmountAmount']; $payment->MoneyCurrency = $record['AmountCurrency']; $payment->Gateway = $this->classToGateway($record['ClassName']); $statusmap = array('Incomplete' => 'Created', 'Success' => 'Captured', 'Failure' => 'Void', 'Pending' => 'Authorized', '' => 'Created'); $payment->Status = $statusmap[$record['Status']]; $payment->write(); $this->count++; }
function generateNextPaymentFrom($latest) { switch ($this->Frequency) { case 'Weekly': $date = date('Y-m-d', strtotime('+1 week', strtotime($latest->PaymentDate))); break; case 'Monthly': $date = date('Y-m-d', strtotime('+1 month', strtotime($latest->PaymentDate))); break; case 'Yearly': $date = date('Y-m-d', strtotime('+1 year', strtotime($latest->PaymentDate))); break; } $payment = new Payment(); $payment->RecurringPaymentID = $this->ID; $payment->PaymentDate = $date; $payment->Amount->Amount = $this->Amount->Amount; $payment->Amount->Currency = $this->Amount->Currency; $payment->write(); return $payment; }