コード例 #1
0
 /**
  * Process Pingback Request
  *
  * Validates the incoming POST/GET response from the gateway to ensure it is
  * legitimate and can be trusted.
  *
  * @param array $get The GET data for this request
  * @param array $post The POST data for this request
  * @return array An array of transaction data, sets any errors using Input if the data fails to validate
  *  - client_id The ID of the client that attempted the payment
  *  - amount The amount of the payment
  *  - currency The currency of the payment
  *  - invoices An array of invoices and the amount the payment should be applied to (if any) including:
  *    - id The ID of the invoice to apply to
  *    - amount The amount to apply to the invoice
  *    - status The status of the transaction (approved, declined, void, pending, reconciled, refunded, returned)
  *    - reference_id The reference ID for gateway-only use with this transaction (optional)
  *    - transaction_id The ID returned by the gateway to identify this transaction
  *    - parent_transaction_id The ID returned by the gateway to identify this transaction's original transaction (in the case of refunds)
  */
 public function validate(array $get, array $post)
 {
     $status = "error";
     $amount = 0;
     $currency = '';
     $this->initPaymentwallConfigs();
     $pingback = new Paymentwall_Pingback($_GET, $this->getRealClientIP());
     list($type, $client_id, $amount, $currency, $gateway_id, $company_id) = explode('|', $pingback->getProductId());
     if (!$amount or !$currency) {
         $this->Input->setErrors($this->getCommonError("invalid"));
     }
     if ($pingback->validate()) {
         if ($pingback->isDeliverable()) {
             $status = 'approved';
         } elseif ($pingback->isCancelable()) {
             $status = 'declined';
         }
     } else {
         $status = 'error';
     }
     // Log the response
     $this->log($this->ifSet($_SERVER['REQUEST_URI']), serialize($get), "output", true);
     // Clone function processNotification in class GatewayPayments
     // Process transaction after validate
     $this->processTransaction(array('client_id' => $pingback->getUserId(), 'amount' => $amount, 'currency' => $currency, 'status' => $status, 'reference_id' => null, 'transaction_id' => $pingback->getReferenceId(), 'parent_transaction_id' => null, 'invoices' => $this->unserializeInvoices($pingback->getParameter('invoice')), 'gateway_id' => $gateway_id, 'company_id' => $company_id));
 }