public function testShouldSetSenderProperty()
 {
     $array = array();
     $result = json_decode(OpenPayU_Util::buildJsonFromArray($array));
     $this->assertEquals($result->properties[0]->name, 'sender');
     $this->assertEquals($result->properties[0]->value, OpenPayU_Configuration::getFullSenderName());
 }
Пример #2
0
 /**
  * Function make refund for order
  * @param $orderId
  * @param $description
  * @param int $amount Amount of refund in pennies
  * @return null|OpenPayU_Result
  * @throws OpenPayU_Exception
  */
 public static function create($orderId, $description, $amount = null)
 {
     if (empty($orderId)) {
         throw new OpenPayU_Exception('Invalid orderId value for refund');
     }
     if (empty($description)) {
         throw new OpenPayU_Exception('Invalid description of refund');
     }
     $refund = array('orderId' => $orderId, 'refund' => array('description' => $description));
     if (!empty($amount)) {
         $refund['refund']['amount'] = (int) $amount;
     }
     $pathUrl = OpenPayU_Configuration::getServiceUrl() . 'orders/' . $refund['orderId'] . '/refund';
     $data = OpenPayU_Util::buildJsonFromArray($refund);
     if (empty($data)) {
         throw new OpenPayU_Exception('Empty message RefundCreateResponse');
     }
     $result = self::verifyResponse(OpenPayU_Http::post($pathUrl, $data), 'RefundCreateResponse');
     return $result;
 }
Пример #3
0
 /**
  * Function builds buildOrderNotifyResponse Document
  * @access public
  * @param string $reqId
  * @return string $xml
  */
 public static function buildOrderNotifyResponse($reqId)
 {
     $data = array('resId' => $reqId, 'status' => array('statusCode' => 'SUCCESS'));
     $response = OpenPayU_Util::buildJsonFromArray($data);
     return $response;
 }
Пример #4
0
 /**
  * Updates Order status
  * - Sends to PayU OrderStatusUpdateRequest
  *
  * @access public
  * @param string $orderStatus A array containing full OrderStatus
  * @return OpenPayU_Result $result Response array with OrderStatusUpdateResponse
  * @throws OpenPayU_Exception
  */
 public static function statusUpdate($orderStatusUpdate)
 {
     $data = array();
     if (empty($orderStatusUpdate)) {
         throw new OpenPayU_Exception('Empty order status data');
     }
     $data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate);
     $orderId = $orderStatusUpdate['orderId'];
     $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId . '/status';
     $result = self::verifyResponse(OpenPayU_Http::put($pathUrl, $data), 'OrderStatusUpdateResponse');
     return $result;
 }