public function parseData(): self
    {
        if (!is_array($this->raw_data)) {
            throw new RuntimeException('Response must be an array');
        }

        if (array_key_exists('quantity', $this->raw_data)) {
            $this->quantity = (int)$this->raw_data['quantity'];
        }

        if (array_key_exists('transaction_id', $this->raw_data)) {
            $this->transaction_id = $this->raw_data['transaction_id'];
        }

        if (array_key_exists('original_transaction_id', $this->raw_data)) {
            $this->original_transaction_id = $this->raw_data['original_transaction_id'];
        }

        if (array_key_exists('product_id', $this->raw_data)) {
            $this->product_id = $this->raw_data['product_id'];
        }

        if (array_key_exists('web_order_line_item_id', $this->raw_data)) {
            $this->web_order_line_item_id = $this->raw_data['web_order_line_item_id'];
        }

        if (array_key_exists('is_trial_period', $this->raw_data)) {
            $this->is_trial_period = filter_var($this->raw_data['is_trial_period'], FILTER_VALIDATE_BOOLEAN);
        }

        if (array_key_exists('is_in_intro_offer_period', $this->raw_data)) {
            $this->is_in_intro_offer_period = filter_var(
                $this->raw_data['is_in_intro_offer_period'],
                FILTER_VALIDATE_BOOLEAN
            );
        }

        if (array_key_exists('purchase_date_ms', $this->raw_data)) {
            $this->purchase_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['purchase_date_ms'] / 1000)
            );
        }

        if (array_key_exists('original_purchase_date_ms', $this->raw_data)) {
            $this->original_purchase_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['original_purchase_date_ms'] / 1000)
            );
        }

        if (array_key_exists('expires_date_ms', $this->raw_data)) {
            $this->expires_date = Carbon::createFromTimestampUTC((int)round($this->raw_data['expires_date_ms'] / 1000));
        } elseif (array_key_exists('expires_date', $this->raw_data) && is_numeric($this->raw_data['expires_date'])) {
            $this->expires_date = Carbon::createFromTimestampUTC(
                (int)round((int)$this->raw_data['expires_date'] / 1000)
            );
        }

        if (array_key_exists('cancellation_date_ms', $this->raw_data)) {
            $this->cancellation_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['cancellation_date_ms'] / 1000)
            );
        }

        return $this;
    }
public function parseData(): self
    {
        if (!is_array($this->raw_data)) {
            throw new RuntimeException('Response must be an array');
        }

        if (array_key_exists('quantity', $this->raw_data)) {
            $this->quantity = (int)$this->raw_data['quantity'];
        }

        if (array_key_exists('transaction_id', $this->raw_data)) {
            $this->transaction_id = $this->raw_data['transaction_id'];
        }

        if (array_key_exists('original_transaction_id', $this->raw_data)) {
            $this->original_transaction_id = $this->raw_data['original_transaction_id'];
        }

        if (array_key_exists('product_id', $this->raw_data)) {
            $this->product_id = $this->raw_data['product_id'];
        }

        if (array_key_exists('web_order_line_item_id', $this->raw_data)) {
            $this->web_order_line_item_id = $this->raw_data['web_order_line_item_id'];
        }

        if (array_key_exists('is_trial_period', $this->raw_data)) {
            $this->is_trial_period = filter_var($this->raw_data['is_trial_period'], FILTER_VALIDATE_BOOLEAN);
        }

        if (array_key_exists('is_in_intro_offer_period', $this->raw_data)) {
            $this->is_in_intro_offer_period = filter_var(
                $this->raw_data['is_in_intro_offer_period'],
                FILTER_VALIDATE_BOOLEAN
            );
        }

        if (array_key_exists('purchase_date_ms', $this->raw_data)) {
            $this->purchase_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['purchase_date_ms'] / 1000)
            );
        }

        if (array_key_exists('original_purchase_date_ms', $this->raw_data)) {
            $this->original_purchase_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['original_purchase_date_ms'] / 1000)
            );
        }

        if (array_key_exists('expires_date_ms', $this->raw_data)) {
            $this->expires_date = Carbon::createFromTimestampUTC((int)round($this->raw_data['expires_date_ms'] / 1000));
        } elseif (array_key_exists('expires_date', $this->raw_data) && is_numeric($this->raw_data['expires_date'])) {
            $this->expires_date = Carbon::createFromTimestampUTC(
                (int)round((int)$this->raw_data['expires_date'] / 1000)
            );
        }

        if (array_key_exists('cancellation_date_ms', $this->raw_data)) {
            $this->cancellation_date = Carbon::createFromTimestampUTC(
                (int)round($this->raw_data['cancellation_date_ms'] / 1000)
            );
        }

        return $this;
    }
public function parseData ( ) : self { if ( ! is_array ( $ this -> raw_data ) ) { throw new RuntimeException ( 'Response must be an array' ) ; } if ( array_key_exists ( 'quantity' , $ this -> raw_data ) ) { $ this -> quantity = ( int ) $ this -> raw_data [ 'quantity' ] ; } if ( array_key_exists ( 'transaction_id' , $ this -> raw_data ) ) { $ this -> transaction_id = $ this -> raw_data [ 'transaction_id' ] ; } if ( array_key_exists ( 'original_transaction_id' , $ this -> raw_data ) ) { $ this -> original_transaction_id = $ this -> raw_data [ 'original_transaction_id' ] ; } if ( array_key_exists ( 'product_id' , $ this -> raw_data ) ) { $ this -> product_id = $ this -> raw_data [ 'product_id' ] ; } if ( array_key_exists ( 'web_order_line_item_id' , $ this -> raw_data ) ) { $ this -> web_order_line_item_id = $ this -> raw_data [ 'web_order_line_item_id' ] ; } if ( array_key_exists ( 'is_trial_period' , $ this -> raw_data ) ) { $ this -> is_trial_period = filter_var ( $ this -> raw_data [ 'is_trial_period' ] , FILTER_VALIDATE_BOOLEAN ) ; } if ( array_key_exists ( 'is_in_intro_offer_period' , $ this -> raw_data ) ) { $ this -> is_in_intro_offer_period = filter_var ( $ this -> raw_data [ 'is_in_intro_offer_period' ] , FILTER_VALIDATE_BOOLEAN ) ; } if ( array_key_exists ( 'purchase_date_ms' , $ this -> raw_data ) ) { $ this -> purchase_date = Carbon :: createFromTimestampUTC ( ( int ) round ( $ this -> raw_data [ 'purchase_date_ms' ] / 1000 ) ) ; } if ( array_key_exists ( 'original_purchase_date_ms' , $ this -> raw_data ) ) { $ this -> original_purchase_date = Carbon :: createFromTimestampUTC ( ( int ) round ( $ this -> raw_data [ 'original_purchase_date_ms' ] / 1000 ) ) ; } if ( array_key_exists ( 'expires_date_ms' , $ this -> raw_data ) ) { $ this -> expires_date = Carbon :: createFromTimestampUTC ( ( int ) round ( $ this -> raw_data [ 'expires_date_ms' ] / 1000 ) ) ; } elseif ( array_key_exists ( 'expires_date' , $ this -> raw_data ) && is_numeric ( $ this -> raw_data [ 'expires_date' ] ) ) { $ this -> expires_date = Carbon :: createFromTimestampUTC ( ( int ) round ( ( int ) $ this -> raw_data [ 'expires_date' ] / 1000 ) ) ; } if ( array_key_exists ( 'cancellation_date_ms' , $ this -> raw_data ) ) { $ this -> cancellation_date = Carbon :: createFromTimestampUTC ( ( int ) round ( $ this -> raw_data [ 'cancellation_date_ms' ] / 1000 ) ) ; } return $ this ; }
Parse Data from JSON Response.

@return $this
@throws RunTimeException
Parse Data from JSON Response .