Handles response for NotificationType = OrderReferenceNotification

@param stdClass $oData

@return boolean
@throws Exception
165092
protected function _orderReferenceUpdate($oData)
    {
        $sId = $oData->OrderReference->AmazonOrderReferenceId;
        $oOrder = $this->_loadOrderById('BESTITAMAZONORDERREFERENCEID', $sId);

        if ($oOrder !== false && isset($oData->OrderReference->OrderReferenceStatus->State)) {
            $this->getClient()->processOrderReference($oOrder, $oData->OrderReference);
            $this->logIPNResponse(Logger::INFO, 'OK', $oData);
            return true;
        }

        $this->logIPNResponse(Logger::ERROR, "Order with Order Reference ID: {$sId} not found", $oData);
        return false;
    }
381222
public function objectCreate($oData)
    {
        $sBucket       = !empty($oData->bucket->slug) ? $oData->bucket->slug : '';
        $sFilenameOrig = !empty($oData->filename) ? $oData->filename : '';
        $sFilename     = strtolower(substr($sFilenameOrig, 0, strrpos($sFilenameOrig, '.')));
        $sExtension    = strtolower(substr($sFilenameOrig, strrpos($sFilenameOrig, '.')));
        $sSource       = !empty($oData->file) ? $oData->file : '';
        $sMime         = !empty($oData->mime) ? $oData->mime : '';
        $sName         = !empty($oData->name) ? $oData->name : 'file' . $sExtension;

        // --------------------------------------------------------------------------

        try {

            //  Create "normal" version
            $this->sdk()->putObject([
                'Bucket'      => $this->getBucket(),
                'Key'         => $sBucket . '/' . $sFilename . $sExtension,
                'SourceFile'  => $sSource,
                'ContentType' => $sMime,
                'ACL'         => 'public-read',
            ]);

            //  Create "download" version
            $this->sdk()->copyObject([
                'Bucket'             => $this->getBucket(),
                'CopySource'         => $this->getBucket() . '/' . $sBucket . '/' . $sFilename . $sExtension,
                'Key'                => $sBucket . '/' . $sFilename . '-download' . $sExtension,
                'ContentType'        => 'application/octet-stream',
                'ContentDisposition' => 'attachment; filename="' . str_replace('"', '', $sName) . '" ',
                'MetadataDirective'  => 'REPLACE',
                'ACL'                => 'public-read',
            ]);

            return true;

        } catch (\Exception $e) {
            $this->setError('AWS-SDK EXCEPTION: [objectCreate]: ' . $e->getMessage());
            return false;
        }
    }
126707
public function handleConfirmOrderResponseOK( $responseData )
    {
        oxRegistry::get( 'OxpsPaymorrowLogger' )->logWithType( $responseData, 'PM_handleConfirmOrderResponseOK' );
        $this->setResponse( $responseData );

        return true;
    }
280249
private function handleMessage($messageData): \Generator
    {
        $messageType = implode('|', [
            ErrorResponse::class,
            ResultResponse::class,
            Notification::class,
            Request::class,
        ]);

        try {
            /** @var Message $message */
            $message = $this->mapper->load($messageData, $messageType);

            if ($message->jsonrpc !== Message::VERSION) {
                $this->logger->warning('[jsonrpc] Bad JSONRPC version received');
            }
        } catch (MapperException $e) {
            $this->logger->warning('[jsonrpc] Malformed message received');

            return new ErrorResponse(null, new InvalidRequestException());
        }

        if ($message instanceof Response) {
            return yield $this->handleResponse($message);
        }
        if ($message instanceof Request) {
            return yield $this->handleRequest($message);
        }
        if ($message instanceof Notification) {
            return yield $this->handleNotification($message);
        }

        throw new \LogicException(); // @codeCoverageIgnore
    }
753855
public function setPayload($responseData) {

		try {
			$this->data = json_encode($responseData, $this->encodingOptions);
		}

		catch (\Exception $e) {

			// PHP 5.4 wrap exceptions thrown by JsonSerializable in a new exception that needs to be removed

			if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) {
				throw $e->getPrevious() ?: $e;
			}
			throw $e;
		}

		if (JSON_ERROR_NONE !== json_last_error()) {
			throw new \InvalidArgumentException(json_last_error_msg());
		}

		return $this->update();

	}
1089808
public function notify($interests, array $data, $debug = false)
    {
        $postData = [];

        if (is_string($interests)) {
            $interests = [$interests];
        }

        if (count($interests) == 0) {
            throw new ExpoException('Interests array must not be empty.');
        }

        // Gets the expo tokens for the interests
        $recipients = $this->registrar->getInterests($interests);

        foreach ($recipients as $token) {
            $postData[] = $data + ['to' => $token];
        }

        $ch = $this->prepareCurl();

        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));

        $response = $this->executeCurl($ch);

        // If the notification failed completely, throw an exception with the details
        if (!$debug && $this->failedCompletely($response, $interests)) {
            throw ExpoException::failedCompletelyException($response);
        }

        return $response;
    }
1179821
protected function _paymentCapture($oData)
    {
        $sId = $oData->CaptureDetails->AmazonCaptureId;
        $oOrder = $this->_loadOrderById('BESTITAMAZONCAPTUREID', $sId);

        if ($oOrder !== false && isset($oData->CaptureDetails->CaptureStatus->State)) {
            $this->getClient()->setCaptureState($oOrder, $oData->CaptureDetails, true);
            $this->logIPNResponse(Logger::INFO, 'OK', $oData);
            return true;
        }

        $this->logIPNResponse(Logger::ERROR, "Order with Capture ID: {$sId} not found", $oData);
        return false;
    }
1300258
public function createEmailTemplate(array $templateData)
    {
        if ($this->findEmailTemplate($templateData)) {
            throw new Exception("Email template for event {$templateData['EVENT_NAME']} already exists");
        }

        $et = new CEventMessage;
        $res = $et->add($templateData);
        if (!$res) {
            throw new Exception("Can't create email event type {$templateData['EVENT_NAME']}: {$et->LAST_ERROR}");
        }

        return ["Email template({$res}) for event {$templateData['EVENT_NAME']} created"];
    }
309438
private function handleNotification(Notification $notification)
    {
        if (empty($notification->targetTypes())) {
            return;
        }
        $objectsByTypes = [];
        $numTotal = 0;
        foreach ($notification->targetTypes() as $objType) {
            $objType = trim($objType);
            $objects = $this->updatedObjects($objType);
            $num = count($objects);
            if ($num == 0) {
                continue;
            }
            $obj = [];
            $obj['objects'] = $objects;
            $obj['num'] = $num;
            $obj['type'] = $objType;
            $obj['typeLabel'] = isset($objects[0]['targetTypeLabel']) ? $objects[0]['targetTypeLabel'] : $objType;

            $objectsByTypes[$objType] = $obj;
            $numTotal += $num;
        }
        $this->sendEmail($notification, $objectsByTypes, $numTotal);
    }
306994
public function httpNotFoundResponse($configData)
    {
        $components = $this->builder->components();
        
        return new Processors\HTTP\Response\NotFound(
            $components->http(),
            $components->template(),
            $configData
        );
    }
1143795
protected function askQuestionExecute($aData)
    {
        $oMailProfile = TdbDataMailProfile::GetProfile('product-info-request');
        $oMailProfile->AddDataArray($aData);
        // now add product info as well
        /** @var $oActiveProduct TdbShopArticle */
        $oActiveProduct = TdbShop::GetActiveItem();
        $aArticleData = $oActiveProduct->GetObjectPropertiesAsArray();
        $oMailProfile->AddDataArray($aArticleData);
        // add link to article

        $sLink = $oActiveProduct->getLink(true, null, array(TdbShopArticle::CMS_LINKABLE_OBJECT_PARAM_CATEGORY => null));
        $oMailProfile->AddData('sLink', $sLink);
        $oMailProfile->ChangeFromAddress($aData['email'], $aData['name']);
        $oMailProfile->SendUsingObjectView('emails', 'Customer');

        $oMsgManager = TCMSMessageManager::GetInstance();
        $oMsgManager->AddMessage($this->sModuleSpotName, 'QUESTION-SEND');

        $this->getRedirect()->redirect($this->getActivePageService()->getActivePage()->GetRealURLPlain());
    }
235716
public function decodeList(&$apiData)
    {
        $resObj = json_decode($apiData);
        if (isset($resObj->error)) {
            $msg = "Error " . $resObj->error->code . " " . $resObj->error->message;
            if (isset($resObj->error->errors[0])) {
                $msg .= " : " . $resObj->error->errors[0]->reason;
            }

            throw new \Exception($msg);
        } else {
            $this->page_info = [
                'resultsPerPage' => $resObj->pageInfo->resultsPerPage,
                'totalResults' => $resObj->pageInfo->totalResults,
                'kind' => $resObj->kind,
                'etag' => $resObj->etag,
                'prevPageToken' => null,
                'nextPageToken' => null,
            ];

            if (isset($resObj->prevPageToken)) {
                $this->page_info['prevPageToken'] = $resObj->prevPageToken;
            }

            if (isset($resObj->nextPageToken)) {
                $this->page_info['nextPageToken'] = $resObj->nextPageToken;
            }

            $itemsArray = $resObj->items;
            if (!is_array($itemsArray) || count($itemsArray) == 0) {
                return false;
            } else {
                return $itemsArray;
            }
        }
    }
894651
protected function actionListOrder()
    {
        list($selected, $action, $value) = $this->getPostedAction();

        $deleted = $updated = 0;
        $failed_notifications = array();

        foreach ($selected as $id) {

            if ($action === 'status' && $this->access('order_edit')) {

                $updated = (bool) $this->order->update($id, array('status' => $value));

                if ($updated && $this->setNotificationUpdateOrder($id) == static::NOTIFICATION_ERROR) {
                    $failed_notifications[] = $this->text('<a href="@url">@text</a>', array(
                        '@url' => $this->url("admin/sale/order/$id"), '@text' => $id));
                }

                $updated++;
            }

            if ($action === 'delete' && $this->access('order_delete')) {
                $deleted += (int) $this->order->delete($id);
            }
        }

        if ($updated > 0) {
            $message = $this->text('Updated %num item(s)', array('%num' => $updated));
            $this->setMessage($message, 'success');
        }

        if (!empty($failed_notifications)) {
            $vars = array('!list' => implode(', ', $failed_notifications));
            $message = $this->text('Failed to notify customers in orders: !list', $vars);
            $this->setMessage($message, 'warning');
        }

        if ($deleted > 0) {
            $message = $this->text('Deleted %num item(s)', array('%num' => $deleted));
            $this->setMessage($message, 'success');
        }
    }
691963
public function eligibility($orderData)
    {
        $res = $this->request(self::PAYMENTS_PATH . '/eligibility')->setRequestBody($orderData)->post();
        $result = new Eligibility($res);

        if (!$result->isEligible) {
            $this->logger->info(
                "Eligibility check failed for following reasons: " .
                var_export($result->reasons, true)
            );
        }

        return $result;
    }
1093290
public function update_instance($formdata) {
        global $DB;
        $adminconfig = $this->get_admin_config();

        $update = new stdClass();
        $update->id = $formdata->instance;
        $update->name = $formdata->name;
        $update->timemodified = time();
        $update->course = $formdata->course;
        $update->intro = $formdata->intro;
        $update->introformat = $formdata->introformat;
        $update->alwaysshowdescription = !empty($formdata->alwaysshowdescription);
        $update->submissiondrafts = $formdata->submissiondrafts;
        $update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
        $update->sendnotifications = $formdata->sendnotifications;
        $update->sendlatenotifications = $formdata->sendlatenotifications;
        $update->sendstudentnotifications = $adminconfig->sendstudentnotifications;
        if (isset($formdata->sendstudentnotifications)) {
            $update->sendstudentnotifications = $formdata->sendstudentnotifications;
        }
        $update->duedate = $formdata->duedate;
        $update->cutoffdate = $formdata->cutoffdate;
        $update->gradingduedate = $formdata->gradingduedate;
        $update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
        $update->grade = $formdata->grade;
        if (!empty($formdata->completionunlocked)) {
            $update->completionsubmit = !empty($formdata->completionsubmit);
        }
        $update->teamsubmission = $formdata->teamsubmission;
        $update->requireallteammemberssubmit = $formdata->requireallteammemberssubmit;
        if (isset($formdata->teamsubmissiongroupingid)) {
            $update->teamsubmissiongroupingid = $formdata->teamsubmissiongroupingid;
        }
        if (isset($formdata->hidegrader)) {
            $update->hidegrader = $formdata->hidegrader;
        }
        $update->blindmarking = $formdata->blindmarking;
        $update->attemptreopenmethod = ASSIGN_ATTEMPT_REOPEN_METHOD_NONE;
        if (!empty($formdata->attemptreopenmethod)) {
            $update->attemptreopenmethod = $formdata->attemptreopenmethod;
        }
        if (!empty($formdata->maxattempts)) {
            $update->maxattempts = $formdata->maxattempts;
        }
        if (isset($formdata->preventsubmissionnotingroup)) {
            $update->preventsubmissionnotingroup = $formdata->preventsubmissionnotingroup;
        }
        $update->markingworkflow = $formdata->markingworkflow;
        $update->markingallocation = $formdata->markingallocation;
        if (empty($update->markingworkflow)) { // If marking workflow is disabled, make sure allocation is disabled.
            $update->markingallocation = 0;
        }

        $result = $DB->update_record('assign', $update);
        $this->instance = $DB->get_record('assign', array('id'=>$update->id), '*', MUST_EXIST);

        $this->save_intro_draft_files($formdata);

        // Load the assignment so the plugins have access to it.

        // Call save_settings hook for submission plugins.
        foreach ($this->submissionplugins as $plugin) {
            if (!$this->update_plugin_instance($plugin, $formdata)) {
                print_error($plugin->get_error());
                return false;
            }
        }
        foreach ($this->feedbackplugins as $plugin) {
            if (!$this->update_plugin_instance($plugin, $formdata)) {
                print_error($plugin->get_error());
                return false;
            }
        }

        $this->update_calendar($this->get_course_module()->id);
        $completionexpected = (!empty($formdata->completionexpected)) ? $formdata->completionexpected : null;
        \core_completion\api::update_completion_date_event($this->get_course_module()->id, 'assign', $this->instance,
                $completionexpected);
        $this->update_gradebook(false, $this->get_course_module()->id);

        $update = new stdClass();
        $update->id = $this->get_instance()->id;
        $update->nosubmissions = (!$this->is_any_submission_plugin_enabled()) ? 1: 0;
        $DB->update_record('assign', $update);

        return $result;
    }
216256
public static function createFromResponse($responseData)
    {
        $messageStatus = new self(null);
        $messageStatus->setRawResponseData($responseData)
            ->processResponse();

        if ($messageStatus['status'] !== 0 && $messageStatus['status'] !== '0') {
            throw new Exception($messageStatus['err_msg']);
        }

        //show message status instead of integer status code
        $messageStatus['message_status'] = self::$messageStatusType[$messageStatus['message_status']];

        return $messageStatus;
    }
60336
public function sendNotification($order)
    {
        // Deal with customer email
        if ($order->Email && ($this->SendNotificationTo == 'Customer' || $this->SendNotificationTo == "Both")) {
            if ($this->CustomSubject) {
                $subject = $this->CustomSubject;
            } else {
                $subject = _t('Orders.Order', 'Order') . " {$order->FullRef} {$order->Status}";
            }

            $email = Email::create()
                ->setSubject($subject)
                ->setTo($order->Email)
                ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Customer")
                ->setData([
                    "Order" => $order,
                    "SiteConfig" => $this->Parent(),
                    "Notification" => $this
                ]);

            if ($this->FromEmail) {
                $email->setFrom($this->FromEmail);
            }
            
            $this->extend("augmentEmailCustomer", $email, $order);
            
            $email->send();
        }

        // Deal with vendor email
        if ($this->VendorEmail && ($this->SendNotificationTo == 'Vendor' || $this->SendNotificationTo == "Both")) {
            if ($this->CustomSubject) {
                $subject = $this->CustomSubject;
            } else {
                $subject = _t('Orders.Order', 'Order') . " {$order->FullRef} {$order->Status}";
            }
            
            $email = Email::create()
                ->setSubject($subject)
                ->setTo($this->VendorEmail)
                ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Vendor")
                ->setData([
                    "Order" => $order,
                    "Notification" => $this
                ]);

            if ($this->FromEmail) {
                $email->setFrom($this->FromEmail);
            }
            
            $this->extend("augmentEmailVendor", $email, $order);
            
            $email->send();
        }
        
        $this->extend("augmentSend", $order);
    }