コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function buildResponse(stdClass $response)
 {
     if (!isset($response->subscription)) {
         throw new Syspay_Merchant_UnexpectedResponseException('Unable to retrieve "subscription" data from response', $response);
     }
     $subscription = Syspay_Merchant_Entity_Subscription::buildFromResponse($response->subscription);
     return $subscription;
 }
コード例 #2
0
ファイル: EMS.php プロジェクト: syspay/merchant-sdk-php
 /**
  * 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);
     }
 }
コード例 #3
0
ファイル: Payment.php プロジェクト: syspay/merchant-sdk-php
 /**
  * Build a payment entity based on a json-decoded payment stdClass
  *
  * @param  stdClass $response The payment data
  * @return Syspay_Merchant_Entity_Payment The payment object
  */
 public static function buildFromResponse(stdClass $response)
 {
     $payment = new self();
     $payment->setId(isset($response->id) ? $response->id : null);
     $payment->setReference(isset($response->reference) ? $response->reference : null);
     $payment->setAmount(isset($response->amount) ? $response->amount : null);
     $payment->setCurrency(isset($response->currency) ? $response->currency : null);
     $payment->setStatus(isset($response->status) ? $response->status : null);
     $payment->setExtra(isset($response->extra) ? $response->extra : null);
     $payment->setDescription(isset($response->description) ? $response->description : null);
     $payment->setWebsite(isset($response->website) ? $response->website : null);
     $payment->setFailureCategory(isset($response->failure_category) ? $response->failure_category : null);
     $payment->setChipAndPinStatus(isset($response->chip_and_pin_status) ? $response->chip_and_pin_status : null);
     $payment->setPaymentType(isset($response->payment_type) ? $response->payment_type : null);
     $payment->setWebsiteUrl(isset($response->website_url) ? $response->website_url : null);
     $payment->setContract(isset($response->contract) ? $response->contract : null);
     $payment->setDescriptor(isset($response->descriptor) ? $response->descriptor : null);
     $payment->setAccountId(isset($response->account_id) ? $response->account_id : null);
     $payment->setMerchantLogin(isset($response->merchant_login) ? $response->merchant_login : null);
     $payment->setMerchantId(isset($response->merchant_id) ? $response->merchant_id : null);
     if (isset($response->settlement_date) && !is_null($response->settlement_date)) {
         $payment->setSettlementDate(Syspay_Merchant_Utils::tsToDateTime($response->settlement_date));
     }
     if (isset($response->processing_time) && !is_null($response->processing_time)) {
         $payment->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time));
     }
     if (isset($response->billing_agreement) && $response->billing_agreement instanceof stdClass) {
         $billingAgreement = Syspay_Merchant_Entity_BillingAgreement::buildFromResponse($response->billing_agreement);
         $payment->setBillingAgreement($billingAgreement);
     }
     if (isset($response->subscription) && $response->subscription instanceof stdClass) {
         $subscription = Syspay_Merchant_Entity_Subscription::buildFromResponse($response->subscription);
         $payment->setSubscription($subscription);
     }
     if (isset($response->payment_method) && $response->payment_method instanceof stdClass) {
         $paymentMethod = Syspay_Merchant_Entity_PaymentMethod::buildFromResponse($response->payment_method);
         $payment->setPaymentMethod($paymentMethod);
     }
     $payment->raw = $response;
     return $payment;
 }
コード例 #4
0
ファイル: Payment.php プロジェクト: antho-girard/syspay
 /**
  * Build a payment entity based on a json-decoded payment stdClass
  *
  * @param  stdClass $response The payment data
  * @return Syspay_Merchant_Entity_Payment The payment object
  */
 public static function buildFromResponse(stdClass $response)
 {
     $payment = new self();
     $payment->setId(isset($response->id) ? $response->id : null);
     $payment->setReference(isset($response->reference) ? $response->reference : null);
     $payment->setAmount(isset($response->amount) ? $response->amount : null);
     $payment->setCurrency(isset($response->currency) ? $response->currency : null);
     $payment->setStatus(isset($response->status) ? $response->status : null);
     $payment->setExtra(isset($response->extra) ? $response->extra : null);
     $payment->setDescription(isset($response->description) ? $response->description : null);
     $payment->setWebsite(isset($response->website) ? $response->website : null);
     $payment->setFailureCategory(isset($response->failure_category) ? $response->failure_category : null);
     $payment->setChipAndPinStatus(isset($response->chip_and_pin_status) ? $response->chip_and_pin_status : null);
     if (isset($response->processing_time) && !is_null($response->processing_time)) {
         $payment->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time));
     }
     if (isset($response->billing_agreement) && $response->billing_agreement instanceof stdClass) {
         $billingAgreement = Syspay_Merchant_Entity_BillingAgreement::buildFromResponse($response->billing_agreement);
         $payment->setBillingAgreement($billingAgreement);
     }
     if (isset($response->subscription) && $response->subscription instanceof stdClass) {
         $subscription = Syspay_Merchant_Entity_Subscription::buildFromResponse($response->subscription);
         $payment->setSubscription($subscription);
     }
     return $payment;
 }