public function ipn($data, Payment_Invoice $invoice) { $tx = new Payment_Transaction(); $tx->setAmount($invoice->getTotal()); $tx->setCurrency($invoice->getCurrency()); $tx->setId(md5(uniqid($invoice->getNumber()))); $tx->setIsValid(true); $tx->setStatus(Payment_Transaction::STATUS_COMPLETE); $tx->setType(Payment_Transaction::TXTYPE_PAYMENT); return $tx; }
public function getTransaction($data, Payment_Invoice $invoice) { $r = $data['post']; $tr = new Payment_Transaction(); $tr->setAmount($r['mb_amount'])->setCurrency($r['currency']); if ($r['md5sig'] == $this->_generateMD5($r)) { switch ($r['status']) { case '2': $tr->setStatus(Payment_Transaction::STATUS_COMPLETE); break; case '0': $tr->setStatus(Payment_Transaction::STATUS_PENDING); break; } $tr->setIsValid(true); } return $tr; }
/** * * Creates and return transaction with pending status * We need to do so because only in new transaction notification * Google returns invoice number. In all other notifications only * Google order number is returned * * @param SimpleXmlElement $xml * @return Payment_Transaction */ private function _processNewOrderNotification(SimpleXMLElement $xml) { $tr = new Payment_Transaction(); $tr->setIsValid(true)->setStatus(Payment_Transaction::STATUS_PENDING); if (isset($xml->{'order-total'})) { $tr->setAmount((string) $xml->{'order-total'}); $tr->setCurrency((string) $xml->{'order-total'}['currency']); } if (isset($xml->{'google-order-number'})) { $tr->setId((string) $xml->{'google-order-number'}); } return $tr; }