Example #1
0
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $log = Am_Di::getInstance()->invoiceLogRecord;
     $log->title = "refundTransaction";
     $log->paysys_id = $this->getId();
     $apireq = new Am_Paysystem_PaypalApiRequest($this);
     $apireq->refundTransaction($payment);
     $res = $apireq->sendRequest($log);
     $log->setInvoice($payment->getInvoice());
     $log->update();
     if ($res['ACK'] != 'Success') {
         $result->setFailed('Transaction was not refunded. Got error from paypal: ' . $res['L_SHORTMESSAGE0']);
         return;
     }
     $result->setSuccess();
     // We will not add refund record here because it will be handeld by IPN script.
 }
Example #2
0
 function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount)
 {
     $log = Am_Di::getInstance()->invoiceLogRecord;
     $log->title = "refundTransaction";
     $log->paysys_id = $this->getId();
     $apireq = new Am_Paysystem_PaypalApiRequest($this);
     $apireq->refundTransaction($payment);
     $res = $apireq->sendRequest($log);
     $log->setInvoice($payment->getInvoice());
     $log->update();
     if ($res['ACK'] != 'Success') {
         throw new Am_Exception_InputError('Transaction was not refunded. Got error from paypal: ' . $res['L_SHORTMESSAGE0']);
     }
     $trans = new Am_Paysystem_Transaction_Manual($this);
     $trans->setAmount($amount);
     $trans->setReceiptId($res['REFUNDTRANSACTIONID']);
     $result->setSuccess();
 }