예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function buildResponse(stdClass $response)
 {
     if (!isset($response->chargeback)) {
         throw new Syspay_Merchant_UnexpectedResponseException('Unable to retrieve "chargeback" data from response', $response);
     }
     $chargeback = Syspay_Merchant_Entity_Chargeback::buildFromResponse($response->chargeback);
     return $chargeback;
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function buildResponse(stdClass $response)
 {
     if (!isset($response->chargebacks) || !is_array($response->chargebacks)) {
         throw new Syspay_Merchant_UnexpectedResponseException('Unable to retrieve "chargebacks" data from response', $response);
     }
     $chargebacks = array();
     foreach ($response->chargebacks as $r) {
         $chargeback = Syspay_Merchant_Entity_Chargeback::buildFromResponse($r);
         array_push($chargebacks, $chargeback);
     }
     return $chargebacks;
 }
예제 #3
0
 /**
  * Return the entity linked to the EMS call received
  * @return mixed One of the Syspay_Merchant_Entity classes depending on the event received
  * @throws Syspay_Merchant_EMSException If something went wrong while parsing the request
  */
 public function getEvent()
 {
     if (!$this->skipAuthCheck) {
         $this->checkChecksum();
     }
     $content = $this->getContent();
     if (!isset($content->type)) {
         throw new Syspay_Merchant_EMSException('Unable to get event type', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
     }
     if (!isset($content->data)) {
         throw new Syspay_Merchant_EMSException('Unable to get data from content', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
     }
     switch ($content->type) {
         case 'payment':
             if (!isset($content->data->payment)) {
                 throw new Syspay_Merchant_EMSException('Payment event received with no payment data', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
             }
             return Syspay_Merchant_Entity_Payment::buildFromResponse($content->data->payment);
             break;
         case 'refund':
             if (!isset($content->data->refund)) {
                 throw new Syspay_Merchant_EMSException('Refund event received with no refund data', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
             }
             return Syspay_Merchant_Entity_Refund::buildFromResponse($content->data->refund);
             break;
         case 'chargeback':
             if (!isset($content->data->chargeback)) {
                 throw new Syspay_Merchant_EMSException('Chargeback event received with no chargeback data', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
             }
             return Syspay_Merchant_Entity_Chargeback::buildFromResponse($content->data->chargeback);
             break;
         case 'billing_agreement':
             if (!isset($content->data->billing_agreement)) {
                 throw new Syspay_Merchant_EMSException('Billing agreement event received with no billing_agreement data', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
             }
             return Syspay_Merchant_Entity_BillingAgreement::buildFromResponse($content->data->billing_agreement);
             break;
         case 'subscription':
             if (!isset($content->data->subscription)) {
                 throw new Syspay_Merchant_EMSException('Subscription event received with no subscription data', Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
             }
             return Syspay_Merchant_Entity_Subscription::buildFromResponse($content->data->subscription);
         default:
             throw new Syspay_Merchant_EMSException('Unknown type: ' . $content->type, Syspay_Merchant_EMSException::CODE_INVALID_CONTENT);
     }
 }