Example #1
0
 /**
  * Inits and saves given PayUOrderInterface tepmplate
  * @param PayUOrderSourceInterface $source given source
  * @param PayUOrderInterface $template given template
  */
 public static function createFromSource(PayUOrderSourceInterface $source, PayUOrderInterface $template)
 {
     $template->setSource($source);
     if ($template->save()) {
         return $template;
     }
     return false;
 }
Example #2
0
 /**
  * Processes payment status request
  * @param PayUOrderInterface $order
  * @param string $key1
  */
 protected function processPaymentStatusRequest(PayUOrderInterface $order, $key1)
 {
     // return false if order has no source
     if (!$order->getSource()) {
         return false;
     }
     // use order source TS value as request TS
     $ts = $order->getSource()->getOrderTs();
     // set required parameters for request
     $parameters = ['pos_id' => $this->posId, 'session_id' => $order->getSessionId(), 'ts' => $ts];
     // generate SIG hash
     $parameters['sig'] = md5(implode('', $parameters) . $key1);
     // create request using cURL
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->getGatewayUrl(self::ACTION_GET_SATUS));
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_TIMEOUT, 20);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $payu_response = curl_exec($ch);
     curl_close($ch);
     return $payu_response;
 }