示例#1
0
 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->setId($r['lr_transfer']);
     $tr->setType(Payment_Transaction::TXTYPE_PAYMENT);
     $tr->setAmount($r['lr_amnt']);
     $tr->setCurrency(str_replace('LR', '', $r['lr_currency']));
     if ($r['lr_encrypted'] == $this->_getHash1($r)) {
         $tr->setStatus(Payment_Transaction::STATUS_COMPLETE);
     }
     return $tr;
 }
示例#3
0
 /**
  * Handle IPN and return response object
  * @return Payment_Transaction
  */
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['get'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['wp_requestid']);
     $tx->setAmount($ipn['wp_payamount'] / 100);
     $tx->setCurrency($ipn['wp_paycurrency']);
     $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
     if ($ipn['wp_status'] == 1) {
         $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
     }
     if ($ipn['wp_status'] == 2) {
         $tx->setStatus(Payment_Transaction::STATUS_PENDING);
     }
     return $tx;
 }
示例#4
0
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['x_trans_id']);
     $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
     $tx->setAmount($ipn['x_amount']);
     $tx->setCurrency($invoice->getCurrency());
     if (isset($ipn['x_response_code'])) {
         switch ($ipn['x_response_code']) {
             //Approved
             case '1':
                 $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
                 break;
             case '2':
                 // Declined
             // Declined
             case '3':
                 // Error
             // Error
             case '4':
                 // Held for Review
                 $tx->setStatus(Payment_Transaction::STATUS_PENDING);
                 break;
             default:
                 throw new Payment_Exception('Authorize.net unknown x_response_code');
         }
     }
     return $tx;
 }
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $transaction = new Payment_Transaction();
     if (isset($ipn['transactionAmount'])) {
         $money = explode(' ', $ipn['transactionAmount']);
         if (isset($money[0])) {
             $transaction->setCurrency($money[0]);
         }
         if (isset($money[1])) {
             $transaction->setAmount(round($money[1], 2));
         }
     }
     if (isset($ipn['transactionId'])) {
         $transaction->setId($ipn['transactionId']);
     }
     if (isset($ipn['status']) && $ipn['status'] == 'PS') {
         $transaction->setStatus(Payment_Transaction::STATUS_COMPLETE);
     }
     if (isset($ipn['operation']) && $ipn['operation'] == 'pay') {
         $transaction->setType(Payment_Transaction::TXTYPE_PAYMENT);
     }
     return $transaction;
 }
示例#6
0
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['get'];
     // Onebip parameters:
     $payment_id = $ipn['payment_id'];
     $country = $ipn['country'];
     $currency = $ipn['currency'];
     $price = $ipn['price'];
     $tax = $ipn['tax'];
     $commission = $ipn['commission'];
     $amount = $ipn['amount'];
     $original_price = $ipn['original_price'];
     $original_currency = $ipn['original_currency'];
     $tx = new Payment_Transaction();
     $tx->setId($payment_id);
     $tx->setAmount($original_price / 100);
     $tx->setCurrency($original_currency);
     $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
     $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
     return $tx;
 }
示例#7
0
 /**
  * @see https://dev.payza.com/resources/references/ipn-variables
  * @param type $data
  * @param Payment_Invoice $invoice
  * @return Payment_Transaction 
  */
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['ap_referencenumber']);
     $tx->setAmount($ipn['ap_totalamount']);
     $tx->setCurrency($ipn['ap_currency']);
     if ($ipn['ap_purchasetype'] == 'subscription') {
         switch ($ipn['ap_status']) {
             case 'Subscription-Canceled':
             case 'Subscription-Expired':
                 $tx->setType(Payment_Transaction::TXTYPE_SUBSCR_CANCEL);
                 $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
                 break;
             case 'Subscription-Payment-Success':
                 $tx->setType(Payment_Transaction::TXTYPE_SUBSCR_CREATE);
                 $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
                 $tx->setSubscriptionId($ipn['ap_subscriptionreferencenumber']);
                 break;
             case 'Subscription-Payment-Failed':
             case 'Subscription-Payment-Rescheduled':
             default:
                 break;
         }
     } else {
         $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
         if ($ipn['ap_status'] == 'Success') {
             $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
         }
     }
     return $tx;
 }
示例#8
0
 /**
  * Handle IPN and return response object
  * @return Payment_Transaction
  */
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['ik_trn_id']);
     $tx->setAmount($ipn['ik_am']);
     $tx->setCurrency($ipn['ik_cur']);
     $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
     if ($ipn['ik_inv_st'] == 'success') {
         $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
     }
     return $tx;
 }
示例#9
0
 /**
  * Handle IPN and return response object
  * @return Payment_Transaction
  */
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $client = $this->_getSoapClient();
     $Pay_Status = 'FAIL';
     $terminalId = $this->getParam('terminalId');
     $userName = $this->getParam('userName');
     $userPassword = $this->getParam('userPassword');
     $refId = $ipn['RefId'];
     $resCode = $ipn['ResCode'];
     $orderId = $ipn['SaleOrderId'];
     $verifySaleOrderId = $ipn['SaleOrderId'];
     $verifySaleReferenceId = $ipn['SaleReferenceId'];
     $parameters = array('terminalId' => $terminalId, 'userName' => $userName, 'userPassword' => $userPassword, 'orderId' => $orderId, 'saleOrderId' => $verifySaleOrderId, 'saleReferenceId' => $verifySaleReferenceId);
     error_log('Parameters: ' . print_r($parameters, 1));
     $result = $client->bpVerifyRequest($parameters);
     $VerifyAnswer = $result->return;
     error_log('Verify answer:' . $VerifyAnswer);
     if ($VerifyAnswer == '0') {
         // Call the SOAP method
         $result = $client->bpSettleRequest($parameters);
         $SetlleAnswer = $result->return;
         error_log('Settle answer:' . $SetlleAnswer);
         if ($SetlleAnswer == '0') {
             $Pay_Status = 'OK';
         }
     }
     if ($VerifyAnswer != '0' and $VerifyAnswer != '') {
         $result = $client->bpInquiryRequest($parameters);
         $InquiryAnswer = $result->return;
         error_log('Inquiry Answer:' . $InquiryAnswer);
         if ($InquiryAnswer == '0') {
             // Call the SOAP method
             $result = $client->bpSettleRequest($parameters);
             $SetlleAnswer = $result->return;
             error_log('Second Settle Answer:' . $InquiryAnswer);
             if ($SetlleAnswer == '0') {
                 $Pay_Status = 'OK';
             }
         } else {
             // Call the SOAP method
             $result = $client->bpReversalRequest($parameters);
             $ReversalAnswer = $result->return;
             error_log('Reversal request Answer:' . $ReversalAnswer);
         }
     }
     if ($Pay_Status != 'OK') {
         throw new Payment_Exception('Sale verification failed: ' . $VerifyAnswer);
     }
     $response = new Payment_Transaction();
     $response->setType(Payment_Transaction::TXTYPE_PAYMENT);
     $response->setId($refId);
     $response->setAmount($invoice->getTotalWithTax());
     $response->setCurrency($invoice->getCurrency());
     $response->setStatus(Payment_Transaction::STATUS_COMPLETE);
     return $response;
 }
示例#10
0
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $uniqid = md5($ipn['trade_no'] . $ipn['trade_status']);
     $tx = new Payment_Transaction();
     $tx->setId($uniqid);
     $tx->setAmount($ipn['total_fee']);
     $tx->setCurrency($invoice->getCurrency());
     $contract = $this->getParam('type');
     if ($contract == '1') {
         switch ($ipn['trade_status']) {
             case 'TRADE_SUCCESS':
             case 'TRADE_FINISHED':
                 $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
                 $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
                 break;
             default:
                 $tx->setStatus($ipn['trade_status']);
                 break;
         }
     }
     if ($contract == '2') {
         switch ($ipn['trade_status']) {
             case 'WAIT_SELLER_SEND_GOODS':
                 $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
                 $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
                 break;
             default:
                 $tx->setStatus($ipn['trade_status']);
                 break;
         }
     }
     return $tx;
 }
 /**
  * Handle IPN and return response object
  * @todo
  * @return Payment_Transaction
  */
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['sale_id']);
     $tx->setAmount($ipn['invoice_cust_amount']);
     $tx->setCurrency($ipn['cust_currency']);
     switch ($ipn['message_type']) {
         case 'ORDER_CREATED':
             $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
             $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
             break;
         case 'REFUND_ISSUED':
             $tx->setType(Payment_Transaction::TXTYPE_REFUND);
             break;
         case 'RECURRING_INSTALLMENT_SUCCESS':
             $tx->setType(Payment_Transaction::TXTYPE_SUBSCR_CREATE);
             break;
         case 'RECURRING_STOPPED':
             $tx->setType(Payment_Transaction::TXTYPE_SUBSCR_CANCEL);
             break;
         case 'FRAUD_STATUS_CHANGED':
         case 'SHIP_STATUS_CHANGED':
         case 'INVOICE_STATUS_CHANGED':
         case 'RECURRING_INSTALLMENT_FAILED':
         case 'RECURRING_STOPPED':
         case 'RECURRING_COMPLETE':
         case 'RECURRING_RESTARTED':
         default:
             //@todo implement in future
             break;
     }
     return $tx;
 }
示例#12
0
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     //@todo
     $response = new Payment_Transaction();
     $response->setType(Payment_Transaction::TXTYPE_PAYMENT);
     $response->setId(uniqid());
     $response->setAmount($invoice->getTotalWithTax());
     $response->setCurrency($invoice->getCurrency());
     $response->setStatus(Payment_Transaction::STATUS_COMPLETE);
     return $response;
 }
示例#13
0
 public function getTransaction($data, Payment_Invoice $invoice)
 {
     $ipn = $data['post'];
     $tx = new Payment_Transaction();
     $tx->setId($ipn['sign']);
     $tx->setAmount($ipn['total_fee']);
     $tx->setCurrency($invoice->getCurrency());
     $tx->setType(Payment_Transaction::TXTYPE_PAYMENT);
     switch ($ipn['trade_status']) {
         case 'TRADE_SUCCESS':
         case 'TRADE_FINISHED':
             //case 'WAIT_SELLER_SEND_GOODS':
             $tx->setStatus(Payment_Transaction::STATUS_COMPLETE);
             break;
         default:
             throw new Payment_Exception('Unknown AliPay IPN status :' . $ipn['trade_status']);
             break;
     }
     return $tx;
 }
 /**
  * 
  * 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;
 }