repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
wata727/pahout
src/Pahout.php
Pahout.instruct
public function instruct() { foreach ($this->files as $file) { Logger::getInstance()->info('Parse: '.$file); try { $root = \ast\parse_file($file, Config::AST_VERSION); $this->annotations = Annotation::create($file, file_get_contents($file)); // If file is empty, $root is not instance of Node. if ($root instanceof Node) { $this->traverse($file, $root); } } catch (\ParseError $exception) { // When a parsing error occurs, the file is determined to be a syntax error. Logger::getInstance()->info('Parse error occurred: '.$file); // SyntaxError is a special tool. Pahout directly generates Hint without checking AST. if (!in_array('SyntaxError', Config::getInstance()->ignore_tools, true)) { $this->hints[] = new Hint( 'SyntaxError', 'Syntax error occurred.', $file, $exception->getLine(), Hint::DOCUMENT_LINK."/SyntaxError.md" ); } } } Logger::getInstance()->info('Hints: '.count($this->hints)); }
php
public function instruct() { foreach ($this->files as $file) { Logger::getInstance()->info('Parse: '.$file); try { $root = \ast\parse_file($file, Config::AST_VERSION); $this->annotations = Annotation::create($file, file_get_contents($file)); // If file is empty, $root is not instance of Node. if ($root instanceof Node) { $this->traverse($file, $root); } } catch (\ParseError $exception) { // When a parsing error occurs, the file is determined to be a syntax error. Logger::getInstance()->info('Parse error occurred: '.$file); // SyntaxError is a special tool. Pahout directly generates Hint without checking AST. if (!in_array('SyntaxError', Config::getInstance()->ignore_tools, true)) { $this->hints[] = new Hint( 'SyntaxError', 'Syntax error occurred.', $file, $exception->getLine(), Hint::DOCUMENT_LINK."/SyntaxError.md" ); } } } Logger::getInstance()->info('Hints: '.count($this->hints)); }
[ "public", "function", "instruct", "(", ")", "{", "foreach", "(", "$", "this", "->", "files", "as", "$", "file", ")", "{", "Logger", "::", "getInstance", "(", ")", "->", "info", "(", "'Parse: '", ".", "$", "file", ")", ";", "try", "{", "$", "root", ...
Tell you about PHP hints. Parses the file to be analyzed and traverses the obtained AST node with DFS. @return void
[ "Tell", "you", "about", "PHP", "hints", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Pahout.php#L60-L88
train
wata727/pahout
src/Pahout.php
Pahout.traverse
private function traverse(string $file, Node $node) { Logger::getInstance()->debug('Traverse: '.\ast\get_kind_name($node->kind)); foreach ($this->tools as $tool) { Logger::getInstance()->debug('Entrypoint check: '.get_class($tool)); if ($tool::ENTRY_POINT !== $node->kind) { continue; } Logger::getInstance()->debug('Run: '.get_class($tool)); $hints = $tool->run($file, $node); $hints = array_filter($hints, function ($hint) { foreach ($this->annotations as $annotation) { if (!($annotation instanceof Annotation\Rebel)) { continue; } if ($annotation->isAffected($hint)) { Logger::getInstance()->debug('Annotation effecting to hint: line='.$hint->lineno); return false; } } Logger::getInstance()->debug('Detected hints: line='.$hint->lineno); return true; }); if (count($hints) === 0) { continue; } array_push($this->hints, ...$hints); } foreach ($node->children as $type => $child) { if ($child instanceof Node) { $this->traverse($file, $child); } } }
php
private function traverse(string $file, Node $node) { Logger::getInstance()->debug('Traverse: '.\ast\get_kind_name($node->kind)); foreach ($this->tools as $tool) { Logger::getInstance()->debug('Entrypoint check: '.get_class($tool)); if ($tool::ENTRY_POINT !== $node->kind) { continue; } Logger::getInstance()->debug('Run: '.get_class($tool)); $hints = $tool->run($file, $node); $hints = array_filter($hints, function ($hint) { foreach ($this->annotations as $annotation) { if (!($annotation instanceof Annotation\Rebel)) { continue; } if ($annotation->isAffected($hint)) { Logger::getInstance()->debug('Annotation effecting to hint: line='.$hint->lineno); return false; } } Logger::getInstance()->debug('Detected hints: line='.$hint->lineno); return true; }); if (count($hints) === 0) { continue; } array_push($this->hints, ...$hints); } foreach ($node->children as $type => $child) { if ($child instanceof Node) { $this->traverse($file, $child); } } }
[ "private", "function", "traverse", "(", "string", "$", "file", ",", "Node", "$", "node", ")", "{", "Logger", "::", "getInstance", "(", ")", "->", "debug", "(", "'Traverse: '", ".", "\\", "ast", "\\", "get_kind_name", "(", "$", "node", "->", "kind", ")"...
Traverse AST nodes with DFS and check the entrypoint of tools. Each time it compares the kind of Node with the entry point of tools. If it matches, it will perform an detection by the tool. Do this process recursively until the children is not a Node. @param string $file File name to be analyzed. @param Node $node AST node to be analyzed. @return void @suppress PhanUndeclaredConstant
[ "Traverse", "AST", "nodes", "with", "DFS", "and", "check", "the", "entrypoint", "of", "tools", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Pahout.php#L103-L140
train
wata727/pahout
src/Tool/DuplicateKey.php
DuplicateKey.run
public function run(string $file, Node $node): array { $hints = []; $keys = []; foreach ($node->children as $elem) { if (is_null($elem)) { continue; } $key = $elem->children['key']; // If the array does not have key, ignores this element. if (!is_null($key)) { foreach ($keys as $other_key) { if ($this->isEqualsWithoutLineno($key, $other_key)) { $hints[] = new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $elem->lineno, self::HINT_LINK ); } } $keys[] = $key; } } return $hints; }
php
public function run(string $file, Node $node): array { $hints = []; $keys = []; foreach ($node->children as $elem) { if (is_null($elem)) { continue; } $key = $elem->children['key']; // If the array does not have key, ignores this element. if (!is_null($key)) { foreach ($keys as $other_key) { if ($this->isEqualsWithoutLineno($key, $other_key)) { $hints[] = new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $elem->lineno, self::HINT_LINK ); } } $keys[] = $key; } } return $hints; }
[ "public", "function", "run", "(", "string", "$", "file", ",", "Node", "$", "node", ")", ":", "array", "{", "$", "hints", "=", "[", "]", ";", "$", "keys", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "children", "as", "$", "elem", ")",...
Detect duplicate numbers, strings, node key @param string $file File name to be analyzed. @param Node $node AST node to be analyzed. @return Hint[] List of hints obtained from results.
[ "Detect", "duplicate", "numbers", "strings", "node", "key" ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Tool/DuplicateKey.php#L47-L76
train
wata727/pahout
src/Formatter/Pretty.php
Pretty.print
public function print() { // If there is no hints, print a message for that. if (count($this->hints) === 0) { $this->output->writeln('<fg=black;bg=green>Awesome! There is nothing from me to teach you!</>'); $this->output->write("\n"); } else { foreach ($this->hints as $hint) { $this->output->writeln('<info>'.$hint->filename.':'.$hint->lineno.'</>'); $this->output->writeln("\t".$hint->type.': '.$hint->message." [$hint->link]"); $this->output->write("\n"); } } $this->output->writeln(count($this->files).' files checked, '.count($this->hints).' hints detected.'); }
php
public function print() { // If there is no hints, print a message for that. if (count($this->hints) === 0) { $this->output->writeln('<fg=black;bg=green>Awesome! There is nothing from me to teach you!</>'); $this->output->write("\n"); } else { foreach ($this->hints as $hint) { $this->output->writeln('<info>'.$hint->filename.':'.$hint->lineno.'</>'); $this->output->writeln("\t".$hint->type.': '.$hint->message." [$hint->link]"); $this->output->write("\n"); } } $this->output->writeln(count($this->files).' files checked, '.count($this->hints).' hints detected.'); }
[ "public", "function", "print", "(", ")", "{", "// If there is no hints, print a message for that.", "if", "(", "count", "(", "$", "this", "->", "hints", ")", "===", "0", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "'<fg=black;bg=green>Awesome! T...
Print hints to the console throught output interface of symfony console. If there is no hints, a message of blessing will be displayed. @return void
[ "Print", "hints", "to", "the", "console", "throught", "output", "interface", "of", "symfony", "console", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Formatter/Pretty.php#L29-L44
train
wata727/pahout
src/Tool/JSONThrowOnError.php
JSONThrowOnError.shouldCheckOption
private function shouldCheckOption($node): Bool { if (!$node instanceof Node) { return true; } if ($node->kind === \ast\AST_CONST) { return true; } if ($node->kind === \ast\AST_BINARY_OP && $node->flags === \ast\flags\BINARY_BITWISE_OR) { return true; } return false; }
php
private function shouldCheckOption($node): Bool { if (!$node instanceof Node) { return true; } if ($node->kind === \ast\AST_CONST) { return true; } if ($node->kind === \ast\AST_BINARY_OP && $node->flags === \ast\flags\BINARY_BITWISE_OR) { return true; } return false; }
[ "private", "function", "shouldCheckOption", "(", "$", "node", ")", ":", "Bool", "{", "if", "(", "!", "$", "node", "instanceof", "Node", ")", "{", "return", "true", ";", "}", "if", "(", "$", "node", "->", "kind", "===", "\\", "ast", "\\", "AST_CONST",...
Check whether the passed options node should be checked. This function is used to suppress false positives. @param mixed $node Options node. @return boolean Result.
[ "Check", "whether", "the", "passed", "options", "node", "should", "be", "checked", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Tool/JSONThrowOnError.php#L88-L101
train
wata727/pahout
src/Tool/JSONThrowOnError.php
JSONThrowOnError.isIncludeJSONThrowOnErrorOption
private function isIncludeJSONThrowOnErrorOption($node): Bool { if (!$node instanceof Node) { return false; } if ($node->kind === \ast\AST_CONST) { $name = $node->children["name"]; if ($name->kind === \ast\AST_NAME && $name->children["name"] === "JSON_THROW_ON_ERROR") { return true; } } if ($node->kind === \ast\AST_BINARY_OP && $node->flags === \ast\flags\BINARY_BITWISE_OR) { return $this->isIncludeJSONThrowOnErrorOption($node->children["left"]) || $this->isIncludeJSONThrowOnErrorOption($node->children["right"]); } return false; }
php
private function isIncludeJSONThrowOnErrorOption($node): Bool { if (!$node instanceof Node) { return false; } if ($node->kind === \ast\AST_CONST) { $name = $node->children["name"]; if ($name->kind === \ast\AST_NAME && $name->children["name"] === "JSON_THROW_ON_ERROR") { return true; } } if ($node->kind === \ast\AST_BINARY_OP && $node->flags === \ast\flags\BINARY_BITWISE_OR) { return $this->isIncludeJSONThrowOnErrorOption($node->children["left"]) || $this->isIncludeJSONThrowOnErrorOption($node->children["right"]); } return false; }
[ "private", "function", "isIncludeJSONThrowOnErrorOption", "(", "$", "node", ")", ":", "Bool", "{", "if", "(", "!", "$", "node", "instanceof", "Node", ")", "{", "return", "false", ";", "}", "if", "(", "$", "node", "->", "kind", "===", "\\", "ast", "\\",...
Check whether the passed node has `JSON_THROW_ON_ERROR` This function is also aware of inclusive or. @param mixed $node Node or others. @return boolean Result.
[ "Check", "whether", "the", "passed", "node", "has", "JSON_THROW_ON_ERROR" ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Tool/JSONThrowOnError.php#L111-L130
train
wata727/pahout
src/Tool/DeclareStrictTypes.php
DeclareStrictTypes.run
public function run(string $file, Node $node): array { // This inspection only works to top level statements in each file. if ($this->inspectedFile === $file) { return []; } $found = false; foreach ($node->children as $child) { if (!$child instanceof Node) { continue; } if ($child->kind !== \ast\AST_DECLARE) { continue; } $declares = $child->children["declares"]; if ($declares->kind !== \ast\AST_CONST_DECL) { continue; } foreach ($declares->children as $declare) { if ($declare->kind === \ast\AST_CONST_ELEM && $declare->children["name"] === "strict_types") { $found = true; } } } $this->inspectedFile = $file; if (!$found) { return [new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $node->lineno, self::HINT_LINK )]; } return []; }
php
public function run(string $file, Node $node): array { // This inspection only works to top level statements in each file. if ($this->inspectedFile === $file) { return []; } $found = false; foreach ($node->children as $child) { if (!$child instanceof Node) { continue; } if ($child->kind !== \ast\AST_DECLARE) { continue; } $declares = $child->children["declares"]; if ($declares->kind !== \ast\AST_CONST_DECL) { continue; } foreach ($declares->children as $declare) { if ($declare->kind === \ast\AST_CONST_ELEM && $declare->children["name"] === "strict_types") { $found = true; } } } $this->inspectedFile = $file; if (!$found) { return [new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $node->lineno, self::HINT_LINK )]; } return []; }
[ "public", "function", "run", "(", "string", "$", "file", ",", "Node", "$", "node", ")", ":", "array", "{", "// This inspection only works to top level statements in each file.", "if", "(", "$", "this", "->", "inspectedFile", "===", "$", "file", ")", "{", "return...
Check whether the passed node has `strict_types` declaration. @param string $file File name to be analyzed. @param Node $node AST node to be analyzed. @return Hint[] List of hints obtained from results.
[ "Check", "whether", "the", "passed", "node", "has", "strict_types", "declaration", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Tool/DeclareStrictTypes.php#L59-L100
train
wata727/pahout
src/Tool/ShortArraySyntax.php
ShortArraySyntax.run
public function run(string $file, Node $node): array { if ($node->flags !== \ast\flags\ARRAY_SYNTAX_LONG) { Logger::getInstance()->debug('Ignore flags: '.$node->flags); return []; } return [new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $node->lineno, self::HINT_LINK )]; }
php
public function run(string $file, Node $node): array { if ($node->flags !== \ast\flags\ARRAY_SYNTAX_LONG) { Logger::getInstance()->debug('Ignore flags: '.$node->flags); return []; } return [new Hint( self::HINT_TYPE, self::HINT_MESSAGE, $file, $node->lineno, self::HINT_LINK )]; }
[ "public", "function", "run", "(", "string", "$", "file", ",", "Node", "$", "node", ")", ":", "array", "{", "if", "(", "$", "node", "->", "flags", "!==", "\\", "ast", "\\", "flags", "\\", "ARRAY_SYNTAX_LONG", ")", "{", "Logger", "::", "getInstance", "...
Detect ARRAY_SYNTAX_LONG node. @param string $file File name to be analyzed. @param Node $node AST node to be analyzed. @return Hint[] List of hints obtained from results.
[ "Detect", "ARRAY_SYNTAX_LONG", "node", "." ]
da1f41a2c560e912ed9ea1be0d7b5417275d29f1
https://github.com/wata727/pahout/blob/da1f41a2c560e912ed9ea1be0d7b5417275d29f1/src/Tool/ShortArraySyntax.php#L46-L60
train
appaydin/pd-user
Controller/SecurityController.php
SecurityController.registerConfirm
public function registerConfirm(\Swift_Mailer $mailer, EventDispatcherInterface $dispatcher, TranslatorInterface $translator, $token) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]); if (null === $user) { throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token)); } // Enabled User $user->setConfirmationToken(null); $user->setEnabled(true); // Send Welcome if ($this->getParameter('pd_user.welcome_email')) { $this->sendEmail($user, $mailer, 'Registration', 'Welcome', 'Welcome'); } // Update User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::REGISTER_CONFIRM, new UserEvent($user))->getResponse()) { return $response; } // Register Success return $this->render($this->getParameter('pd_user.template_path') . '/Registration/registerSuccess.html.twig', [ 'user' => $user, ]); }
php
public function registerConfirm(\Swift_Mailer $mailer, EventDispatcherInterface $dispatcher, TranslatorInterface $translator, $token) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]); if (null === $user) { throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token)); } // Enabled User $user->setConfirmationToken(null); $user->setEnabled(true); // Send Welcome if ($this->getParameter('pd_user.welcome_email')) { $this->sendEmail($user, $mailer, 'Registration', 'Welcome', 'Welcome'); } // Update User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::REGISTER_CONFIRM, new UserEvent($user))->getResponse()) { return $response; } // Register Success return $this->render($this->getParameter('pd_user.template_path') . '/Registration/registerSuccess.html.twig', [ 'user' => $user, ]); }
[ "public", "function", "registerConfirm", "(", "\\", "Swift_Mailer", "$", "mailer", ",", "EventDispatcherInterface", "$", "dispatcher", ",", "TranslatorInterface", "$", "translator", ",", "$", "token", ")", "{", "// Get Doctrine", "$", "em", "=", "$", "this", "->...
Registration Confirm Token. @param $token @return \Symfony\Component\HttpFoundation\Response
[ "Registration", "Confirm", "Token", "." ]
b233534d93a12942b6b4ddc646a0732a3dff65a0
https://github.com/appaydin/pd-user/blob/b233534d93a12942b6b4ddc646a0732a3dff65a0/Controller/SecurityController.php#L166-L199
train
appaydin/pd-user
Controller/SecurityController.php
SecurityController.resetting
public function resetting(Request $request, EventDispatcherInterface $dispatcher, \Swift_Mailer $mailer, TranslatorInterface $translator) { // Check Auth if ($this->checkAuth()) { return $this->redirectToRoute($this->getParameter('pd_user.login_redirect')); } // Build Form $form = $this->createForm($this->getParameter('pd_user.resetting_type')); // Handle Form Submit $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['email' => $form->get('username')->getData()]); if (null === $user) { $form->get('username')->addError(new FormError($translator->trans('security.user_not_found'))); } else { // Create TTL if ($user->isPasswordRequestNonExpired($this->getParameter('pd_user.resetting_request_time'))) { $form->get('username')->addError(new FormError($translator->trans('security.resetpw_wait_resendig', ['%s' => $this->getParameter('pd_user.resetting_request_time')]))); } else { // Create Confirmation Token if (empty($user->getConfirmationToken()) || null === $user->getConfirmationToken()) { $user->createConfirmationToken(); $user->setPasswordRequestedAt(new \DateTime()); } // Send Resetting Email $emailBody = [ 'confirmationUrl' => $this->generateUrl('security_resetting_password', ['token' => $user->getConfirmationToken()], UrlGeneratorInterface::ABSOLUTE_URL), ]; $this->sendEmail($user, $mailer, 'Account Password Resetting', $emailBody, 'Resetting'); // Update User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::RESETTING, new UserEvent($user))->getResponse()) { return $response; } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingSuccess.html.twig', [ 'sendEmail' => true, ]); } } } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resetting.html.twig', [ 'form' => $form->createView(), ]); }
php
public function resetting(Request $request, EventDispatcherInterface $dispatcher, \Swift_Mailer $mailer, TranslatorInterface $translator) { // Check Auth if ($this->checkAuth()) { return $this->redirectToRoute($this->getParameter('pd_user.login_redirect')); } // Build Form $form = $this->createForm($this->getParameter('pd_user.resetting_type')); // Handle Form Submit $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['email' => $form->get('username')->getData()]); if (null === $user) { $form->get('username')->addError(new FormError($translator->trans('security.user_not_found'))); } else { // Create TTL if ($user->isPasswordRequestNonExpired($this->getParameter('pd_user.resetting_request_time'))) { $form->get('username')->addError(new FormError($translator->trans('security.resetpw_wait_resendig', ['%s' => $this->getParameter('pd_user.resetting_request_time')]))); } else { // Create Confirmation Token if (empty($user->getConfirmationToken()) || null === $user->getConfirmationToken()) { $user->createConfirmationToken(); $user->setPasswordRequestedAt(new \DateTime()); } // Send Resetting Email $emailBody = [ 'confirmationUrl' => $this->generateUrl('security_resetting_password', ['token' => $user->getConfirmationToken()], UrlGeneratorInterface::ABSOLUTE_URL), ]; $this->sendEmail($user, $mailer, 'Account Password Resetting', $emailBody, 'Resetting'); // Update User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::RESETTING, new UserEvent($user))->getResponse()) { return $response; } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingSuccess.html.twig', [ 'sendEmail' => true, ]); } } } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resetting.html.twig', [ 'form' => $form->createView(), ]); }
[ "public", "function", "resetting", "(", "Request", "$", "request", ",", "EventDispatcherInterface", "$", "dispatcher", ",", "\\", "Swift_Mailer", "$", "mailer", ",", "TranslatorInterface", "$", "translator", ")", "{", "// Check Auth", "if", "(", "$", "this", "->...
Resetting Request. @param Request $request @throws \Exception @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
[ "Resetting", "Request", "." ]
b233534d93a12942b6b4ddc646a0732a3dff65a0
https://github.com/appaydin/pd-user/blob/b233534d93a12942b6b4ddc646a0732a3dff65a0/Controller/SecurityController.php#L210-L271
train
appaydin/pd-user
Controller/SecurityController.php
SecurityController.resettingPassword
public function resettingPassword(Request $request, UserPasswordEncoderInterface $encoder, EventDispatcherInterface $dispatcher, \Swift_Mailer $mailer, TranslatorInterface $translator, $token) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]); if (null === $user) { throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token)); } // Build Form $form = $this->createForm(ResettingPasswordType::class, $user); // Handle Form Submit $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // Encode Password & Set Token $password = $encoder->encodePassword($user, $form->get('plainPassword')->getData()); $user->setPassword($password) ->setConfirmationToken(null) ->setPasswordRequestedAt(null); // Save User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::RESETTING_COMPLETE, new UserEvent($user))->getResponse()) { return $response; } // Send Resetting Complete $this->sendEmail($user, $mailer, 'Account Password Resetting', 'Password resetting completed.', 'Resetting_Completed'); // Render Success return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingSuccess.html.twig', [ 'sendEmail' => false, ]); } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingPassword.html.twig', [ 'token' => $token, 'form' => $form->createView(), ]); }
php
public function resettingPassword(Request $request, UserPasswordEncoderInterface $encoder, EventDispatcherInterface $dispatcher, \Swift_Mailer $mailer, TranslatorInterface $translator, $token) { // Get Doctrine $em = $this->getDoctrine()->getManager(); // Find User $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['confirmationToken' => $token]); if (null === $user) { throw $this->createNotFoundException(sprintf($translator->trans('security.token_notfound'), $token)); } // Build Form $form = $this->createForm(ResettingPasswordType::class, $user); // Handle Form Submit $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // Encode Password & Set Token $password = $encoder->encodePassword($user, $form->get('plainPassword')->getData()); $user->setPassword($password) ->setConfirmationToken(null) ->setPasswordRequestedAt(null); // Save User $em->persist($user); $em->flush(); // Dispatch Register Event if ($response = $dispatcher->dispatch(UserEvent::RESETTING_COMPLETE, new UserEvent($user))->getResponse()) { return $response; } // Send Resetting Complete $this->sendEmail($user, $mailer, 'Account Password Resetting', 'Password resetting completed.', 'Resetting_Completed'); // Render Success return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingSuccess.html.twig', [ 'sendEmail' => false, ]); } // Render return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingPassword.html.twig', [ 'token' => $token, 'form' => $form->createView(), ]); }
[ "public", "function", "resettingPassword", "(", "Request", "$", "request", ",", "UserPasswordEncoderInterface", "$", "encoder", ",", "EventDispatcherInterface", "$", "dispatcher", ",", "\\", "Swift_Mailer", "$", "mailer", ",", "TranslatorInterface", "$", "translator", ...
Reset Password Form. @param Request $request @param $token @return \Symfony\Component\HttpFoundation\Response
[ "Reset", "Password", "Form", "." ]
b233534d93a12942b6b4ddc646a0732a3dff65a0
https://github.com/appaydin/pd-user/blob/b233534d93a12942b6b4ddc646a0732a3dff65a0/Controller/SecurityController.php#L281-L328
train
appaydin/pd-user
Controller/SecurityController.php
SecurityController.sendEmail
private function sendEmail(UserInterface $user, \Swift_Mailer $mailer, $subject, $body, $templateId) { if (\is_array($body)) { $body['email'] = $user->getEmail(); $body['fullname'] = $user->getProfile()->getFullName(); } else { $body = [ 'email' => $user->getEmail(), 'fullname' => $user->getProfile()->getFullName(), 'content' => $body, ]; } // Create Message $message = (new PdSwiftMessage()) ->setTemplateId($templateId) ->setFrom($this->getParameter('pd_user.mail_sender_address'), $this->getParameter('pd_user.mail_sender_name')) ->setTo($user->getEmail()) ->setSubject($subject) ->setBody(serialize($body), 'text/html'); return (bool)$mailer->send($message); }
php
private function sendEmail(UserInterface $user, \Swift_Mailer $mailer, $subject, $body, $templateId) { if (\is_array($body)) { $body['email'] = $user->getEmail(); $body['fullname'] = $user->getProfile()->getFullName(); } else { $body = [ 'email' => $user->getEmail(), 'fullname' => $user->getProfile()->getFullName(), 'content' => $body, ]; } // Create Message $message = (new PdSwiftMessage()) ->setTemplateId($templateId) ->setFrom($this->getParameter('pd_user.mail_sender_address'), $this->getParameter('pd_user.mail_sender_name')) ->setTo($user->getEmail()) ->setSubject($subject) ->setBody(serialize($body), 'text/html'); return (bool)$mailer->send($message); }
[ "private", "function", "sendEmail", "(", "UserInterface", "$", "user", ",", "\\", "Swift_Mailer", "$", "mailer", ",", "$", "subject", ",", "$", "body", ",", "$", "templateId", ")", "{", "if", "(", "\\", "is_array", "(", "$", "body", ")", ")", "{", "$...
Send Mail. @return bool
[ "Send", "Mail", "." ]
b233534d93a12942b6b4ddc646a0732a3dff65a0
https://github.com/appaydin/pd-user/blob/b233534d93a12942b6b4ddc646a0732a3dff65a0/Controller/SecurityController.php#L345-L367
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidloginclient.php
bestitAmazonPay4OxidLoginClient.isActive
public function isActive() { if ($this->_isActive === null) { //Checkbox for active Login checked $this->_isActive = ( (bool)$this->getConfig()->getConfigParam('blAmazonLoginActive') === true && (string)$this->getConfig()->getConfigParam('sAmazonLoginClientId') !== '' && (string)$this->getConfig()->getConfigParam('sAmazonSellerId') !== '' ); } return $this->_isActive; }
php
public function isActive() { if ($this->_isActive === null) { //Checkbox for active Login checked $this->_isActive = ( (bool)$this->getConfig()->getConfigParam('blAmazonLoginActive') === true && (string)$this->getConfig()->getConfigParam('sAmazonLoginClientId') !== '' && (string)$this->getConfig()->getConfigParam('sAmazonSellerId') !== '' ); } return $this->_isActive; }
[ "public", "function", "isActive", "(", ")", "{", "if", "(", "$", "this", "->", "_isActive", "===", "null", ")", "{", "//Checkbox for active Login checked", "$", "this", "->", "_isActive", "=", "(", "(", "bool", ")", "$", "this", "->", "getConfig", "(", "...
Method checks if Amazon Login is active and can be used @return bool
[ "Method", "checks", "if", "Amazon", "Login", "is", "active", "and", "can", "be", "used" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidloginclient.php#L40-L52
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidloginclient.php
bestitAmazonPay4OxidLoginClient.createOxidUser
public function createOxidUser($oUserData) { $aFullName = explode(' ', trim($oUserData->name)); $sLastName = array_pop($aFullName); $sFirstName = implode(' ', $aFullName); /** @var oxUser $oUser */ $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); $oUser->assign(array( 'oxregister' => 0, 'oxshopid' => $this->getConfig()->getShopId(), 'oxactive' => 1, 'oxusername' => $oUserData->email, 'oxfname' => $this->getAddressUtil()->encodeString($sFirstName), 'oxlname' => $this->getAddressUtil()->encodeString($sLastName), 'bestitamazonid' => $oUserData->user_id )); //Set user random password just to have it $sNewPass = substr(md5(time() . rand(0, 5000)), 0, 8); $oUser->setPassword($sNewPass); //Save all user data $blSuccess = $oUser->save(); //Add user to two default OXID groups $oUser->addToGroup('oxidnewcustomer'); $oUser->addToGroup('oxidnotyetordered'); return $blSuccess; }
php
public function createOxidUser($oUserData) { $aFullName = explode(' ', trim($oUserData->name)); $sLastName = array_pop($aFullName); $sFirstName = implode(' ', $aFullName); /** @var oxUser $oUser */ $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); $oUser->assign(array( 'oxregister' => 0, 'oxshopid' => $this->getConfig()->getShopId(), 'oxactive' => 1, 'oxusername' => $oUserData->email, 'oxfname' => $this->getAddressUtil()->encodeString($sFirstName), 'oxlname' => $this->getAddressUtil()->encodeString($sLastName), 'bestitamazonid' => $oUserData->user_id )); //Set user random password just to have it $sNewPass = substr(md5(time() . rand(0, 5000)), 0, 8); $oUser->setPassword($sNewPass); //Save all user data $blSuccess = $oUser->save(); //Add user to two default OXID groups $oUser->addToGroup('oxidnewcustomer'); $oUser->addToGroup('oxidnotyetordered'); return $blSuccess; }
[ "public", "function", "createOxidUser", "(", "$", "oUserData", ")", "{", "$", "aFullName", "=", "explode", "(", "' '", ",", "trim", "(", "$", "oUserData", "->", "name", ")", ")", ";", "$", "sLastName", "=", "array_pop", "(", "$", "aFullName", ")", ";",...
Create new oxid user with details from Amazon @var stdClass $oUserData @return boolean @throws oxSystemComponentException
[ "Create", "new", "oxid", "user", "with", "details", "from", "Amazon" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidloginclient.php#L145-L175
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidloginclient.php
bestitAmazonPay4OxidLoginClient.getAmazonLanguage
public function getAmazonLanguage() { //Get all languages from module settings $aLanguages = $this->getConfig()->getConfigParam('aAmazonLanguages'); $sLanguageAbbr = $this->getLanguage()->getLanguageAbbr(); //Return Amazon Lang string if it exists in array else return null return isset($aLanguages[$sLanguageAbbr]) ? $aLanguages[$sLanguageAbbr] : $sLanguageAbbr; }
php
public function getAmazonLanguage() { //Get all languages from module settings $aLanguages = $this->getConfig()->getConfigParam('aAmazonLanguages'); $sLanguageAbbr = $this->getLanguage()->getLanguageAbbr(); //Return Amazon Lang string if it exists in array else return null return isset($aLanguages[$sLanguageAbbr]) ? $aLanguages[$sLanguageAbbr] : $sLanguageAbbr; }
[ "public", "function", "getAmazonLanguage", "(", ")", "{", "//Get all languages from module settings", "$", "aLanguages", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getConfigParam", "(", "'aAmazonLanguages'", ")", ";", "$", "sLanguageAbbr", "=", "$", "th...
Method returns language for Amazon GUI elements @return string
[ "Method", "returns", "language", "for", "Amazon", "GUI", "elements" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidloginclient.php#L212-L220
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidloginclient.php
bestitAmazonPay4OxidLoginClient.getLangIdByAmazonLanguage
public function getLangIdByAmazonLanguage($sAmazonLanguageString) { //Get all languages from module settings $aLanguages = $this->getConfig()->getConfigParam('aAmazonLanguages'); $sAbbreviation = array_search($sAmazonLanguageString, $aLanguages); $aAllLangIds = $this->getLanguage()->getAllShopLanguageIds(); return array_search($sAbbreviation, $aAllLangIds); }
php
public function getLangIdByAmazonLanguage($sAmazonLanguageString) { //Get all languages from module settings $aLanguages = $this->getConfig()->getConfigParam('aAmazonLanguages'); $sAbbreviation = array_search($sAmazonLanguageString, $aLanguages); $aAllLangIds = $this->getLanguage()->getAllShopLanguageIds(); return array_search($sAbbreviation, $aAllLangIds); }
[ "public", "function", "getLangIdByAmazonLanguage", "(", "$", "sAmazonLanguageString", ")", "{", "//Get all languages from module settings", "$", "aLanguages", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getConfigParam", "(", "'aAmazonLanguages'", ")", ";", "...
Returns Language Id by Amazon Language string @param string $sAmazonLanguageString Amazon Language string @return int|bool
[ "Returns", "Language", "Id", "by", "Amazon", "Language", "string" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidloginclient.php#L229-L236
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidloginclient.php
bestitAmazonPay4OxidLoginClient.getOrderLanguageId
public function getOrderLanguageId(oxOrder $oOrder) { //Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string $oData = $this->getClient()->getOrderReferenceDetails($oOrder, array(), true); //If request did not return us the language string return the existing Order lang ID if (isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage) === false) { return (int)$oOrder->getFieldData('oxlang'); } //If we have a language string match it to the one in the language mapping array $sAmazonLanguageString = (string)$oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage; //Get OXID Language Id by Amazon Language string $iLangId = $this->getLangIdByAmazonLanguage($sAmazonLanguageString); return ($iLangId !== false) ? (int)$iLangId : (int)$oOrder->getFieldData('oxlang'); }
php
public function getOrderLanguageId(oxOrder $oOrder) { //Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string $oData = $this->getClient()->getOrderReferenceDetails($oOrder, array(), true); //If request did not return us the language string return the existing Order lang ID if (isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage) === false) { return (int)$oOrder->getFieldData('oxlang'); } //If we have a language string match it to the one in the language mapping array $sAmazonLanguageString = (string)$oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage; //Get OXID Language Id by Amazon Language string $iLangId = $this->getLangIdByAmazonLanguage($sAmazonLanguageString); return ($iLangId !== false) ? (int)$iLangId : (int)$oOrder->getFieldData('oxlang'); }
[ "public", "function", "getOrderLanguageId", "(", "oxOrder", "$", "oOrder", ")", "{", "//Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string", "$", "oData", "=", "$", "this", "->", "getClient", "(", ")", "->", "getOrderReferenceDetails", "(", "$", ...
Returns Language ID to use for made order @param oxOrder $oOrder Order object @return int @throws Exception
[ "Returns", "Language", "ID", "to", "use", "for", "made", "order" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidloginclient.php#L246-L262
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init._deactivateOldModule
protected static function _deactivateOldModule() { $sModule = self::OLD_MODULE_ID; /** * @var oxModule $oModule */ $oModule = self::_getModule(); if ($oModule->load($sModule) === false) { self::_getUtilsView()->addErrorToDisplay(new oxException('EXCEPTION_MODULE_NOT_LOADED')); return false; } try { $oModuleCache = self::_getModuleCache($oModule); $oModuleInstaller = self::_getModuleInstaller($oModuleCache); return $oModuleInstaller->deactivate($oModule); } catch (oxException $oEx) { self::_getUtilsView()->addErrorToDisplay($oEx); if (method_exists($oEx, 'debugOut')) { $oEx->debugOut(); } } return false; }
php
protected static function _deactivateOldModule() { $sModule = self::OLD_MODULE_ID; /** * @var oxModule $oModule */ $oModule = self::_getModule(); if ($oModule->load($sModule) === false) { self::_getUtilsView()->addErrorToDisplay(new oxException('EXCEPTION_MODULE_NOT_LOADED')); return false; } try { $oModuleCache = self::_getModuleCache($oModule); $oModuleInstaller = self::_getModuleInstaller($oModuleCache); return $oModuleInstaller->deactivate($oModule); } catch (oxException $oEx) { self::_getUtilsView()->addErrorToDisplay($oEx); if (method_exists($oEx, 'debugOut')) { $oEx->debugOut(); } } return false; }
[ "protected", "static", "function", "_deactivateOldModule", "(", ")", "{", "$", "sModule", "=", "self", "::", "OLD_MODULE_ID", ";", "/**\n * @var oxModule $oModule\n */", "$", "oModule", "=", "self", "::", "_getModule", "(", ")", ";", "if", "(", "$"...
Deactivates the old module. @return bool
[ "Deactivates", "the", "old", "module", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L144-L171
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init._removeTempVersionNumberFromDatabase
protected static function _removeTempVersionNumberFromDatabase() { $oConfig = self::_getConfig(); $sModuleId = self::_getDatabase()->quote(self::TMP_DB_ID); $sQuotedShopId = self::_getDatabase()->quote($oConfig->getShopId()); $sDeleteSql = "DELETE FROM `oxconfig` WHERE oxmodule = {$sModuleId} AND oxshopid = {$sQuotedShopId}"; self::_getDatabase()->execute($sDeleteSql); }
php
protected static function _removeTempVersionNumberFromDatabase() { $oConfig = self::_getConfig(); $sModuleId = self::_getDatabase()->quote(self::TMP_DB_ID); $sQuotedShopId = self::_getDatabase()->quote($oConfig->getShopId()); $sDeleteSql = "DELETE FROM `oxconfig` WHERE oxmodule = {$sModuleId} AND oxshopid = {$sQuotedShopId}"; self::_getDatabase()->execute($sDeleteSql); }
[ "protected", "static", "function", "_removeTempVersionNumberFromDatabase", "(", ")", "{", "$", "oConfig", "=", "self", "::", "_getConfig", "(", ")", ";", "$", "sModuleId", "=", "self", "::", "_getDatabase", "(", ")", "->", "quote", "(", "self", "::", "TMP_DB...
Removes the temporary version number of the module from the database. @throws oxConnectionException
[ "Removes", "the", "temporary", "version", "number", "of", "the", "module", "from", "the", "database", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L177-L189
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init._executeSqlFile
protected static function _executeSqlFile($sFile) { $blSuccess = false; $sFileWithPath = dirname(__FILE__) . '/../../../_db/' . $sFile; if (file_exists($sFileWithPath)) { $sSqlFile = file_get_contents($sFileWithPath); $aSqlRows = explode(';', $sSqlFile); $aSqlRows = array_map('trim', $aSqlRows); foreach ($aSqlRows as $sSqlRow) { if ($sSqlRow !== '') { self::_getDatabase()->execute($sSqlRow); } } $blSuccess = true; } return $blSuccess; }
php
protected static function _executeSqlFile($sFile) { $blSuccess = false; $sFileWithPath = dirname(__FILE__) . '/../../../_db/' . $sFile; if (file_exists($sFileWithPath)) { $sSqlFile = file_get_contents($sFileWithPath); $aSqlRows = explode(';', $sSqlFile); $aSqlRows = array_map('trim', $aSqlRows); foreach ($aSqlRows as $sSqlRow) { if ($sSqlRow !== '') { self::_getDatabase()->execute($sSqlRow); } } $blSuccess = true; } return $blSuccess; }
[ "protected", "static", "function", "_executeSqlFile", "(", "$", "sFile", ")", "{", "$", "blSuccess", "=", "false", ";", "$", "sFileWithPath", "=", "dirname", "(", "__FILE__", ")", ".", "'/../../../_db/'", ".", "$", "sFile", ";", "if", "(", "file_exists", "...
Executes a sql file. @param string $sFile @return bool @throws oxConnectionException
[ "Executes", "a", "sql", "file", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L199-L219
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init.onActivate
public static function onActivate() { $sSql = "SELECT COUNT(OXID) FROM oxpayments WHERE OXID IN ('jagamazon', 'bestitamazon')"; //Insert payment records to DB $iRes = self::_getDatabase()->getOne($sSql); if ($iRes !== false && (int)$iRes === 0) { self::_executeSqlFile('install.sql'); //Update Views $oDbHandler = self::_getDbMetaDataHandler(); $oDbHandler->updateViews(); } $sPaymentTable = getViewName('oxpayments'); $sSql = "UPDATE {$sPaymentTable} SET OXACTIVE = 1 WHERE OXID = 'bestitamazon'"; //Make payment active self::_getDatabase()->execute($sSql); $oConfig = self::_getConfig(); $sUpdateFrom = $oConfig->getShopConfVar('sUpdateFrom', null, self::TMP_DB_ID); if ($sUpdateFrom !== null) { $blRemoveTempVersionNumber = version_compare($sUpdateFrom, '2.2.2', '<') && self::_executeSqlFile('update_2.2.2.sql'); if (version_compare($sUpdateFrom, '2.4.0', '<') && self::_executeSqlFile('update_2.4.0.sql') ) { $blRemoveTempVersionNumber = true; self::_deactivateOldModule(); } if (version_compare($sUpdateFrom, '2.6.0', '<')) { $blRemoveTempVersionNumber = true; $sNewMode = ((string)self::_getConfig()->getConfigParam('sAmazonMode') === 'Sync') ? bestitAmazonPay4OxidClient::BASIC_FLOW : bestitAmazonPay4OxidClient::OPTIMIZED_FLOW; self::_getConfig()->setConfigParam('sAmazonMode', $sNewMode); } if ($blRemoveTempVersionNumber === true) { self::_removeTempVersionNumberFromDatabase(); } } // Keep signature after module deactivation on reactivate $sShopId = $oConfig->getShopId(); $sSql = "SELECT OXVARVALUE FROM oxconfig WHERE OXVARNAME = 'sAmazonSignature' AND OXSHOPID = '{$sShopId}'"; $sValue = self::_getDatabase()->getOne($sSql); if ($sValue !== false && $sValue !== '') { $sQuery = "UPDATE oxconfig SET OXVARTYPE = 'str' WHERE OXVARNAME = 'sAmazonSignature' AND OXSHOPID = '{$sShopId}'"; self::_getDatabase()->execute($sQuery); } // copy multi currency option value from possible hidden feature to module config if ((bool)$oConfig->getConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency') === true) { $oConfig->setConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency', true); $oConfig->saveShopConfVar( 'bool', 'blBestitAmazonPay4OxidEnableMultiCurrency', true, $oConfig->getShopId(), 'module:bestitamazonpay4oxid' ); } self::clearTmp(); }
php
public static function onActivate() { $sSql = "SELECT COUNT(OXID) FROM oxpayments WHERE OXID IN ('jagamazon', 'bestitamazon')"; //Insert payment records to DB $iRes = self::_getDatabase()->getOne($sSql); if ($iRes !== false && (int)$iRes === 0) { self::_executeSqlFile('install.sql'); //Update Views $oDbHandler = self::_getDbMetaDataHandler(); $oDbHandler->updateViews(); } $sPaymentTable = getViewName('oxpayments'); $sSql = "UPDATE {$sPaymentTable} SET OXACTIVE = 1 WHERE OXID = 'bestitamazon'"; //Make payment active self::_getDatabase()->execute($sSql); $oConfig = self::_getConfig(); $sUpdateFrom = $oConfig->getShopConfVar('sUpdateFrom', null, self::TMP_DB_ID); if ($sUpdateFrom !== null) { $blRemoveTempVersionNumber = version_compare($sUpdateFrom, '2.2.2', '<') && self::_executeSqlFile('update_2.2.2.sql'); if (version_compare($sUpdateFrom, '2.4.0', '<') && self::_executeSqlFile('update_2.4.0.sql') ) { $blRemoveTempVersionNumber = true; self::_deactivateOldModule(); } if (version_compare($sUpdateFrom, '2.6.0', '<')) { $blRemoveTempVersionNumber = true; $sNewMode = ((string)self::_getConfig()->getConfigParam('sAmazonMode') === 'Sync') ? bestitAmazonPay4OxidClient::BASIC_FLOW : bestitAmazonPay4OxidClient::OPTIMIZED_FLOW; self::_getConfig()->setConfigParam('sAmazonMode', $sNewMode); } if ($blRemoveTempVersionNumber === true) { self::_removeTempVersionNumberFromDatabase(); } } // Keep signature after module deactivation on reactivate $sShopId = $oConfig->getShopId(); $sSql = "SELECT OXVARVALUE FROM oxconfig WHERE OXVARNAME = 'sAmazonSignature' AND OXSHOPID = '{$sShopId}'"; $sValue = self::_getDatabase()->getOne($sSql); if ($sValue !== false && $sValue !== '') { $sQuery = "UPDATE oxconfig SET OXVARTYPE = 'str' WHERE OXVARNAME = 'sAmazonSignature' AND OXSHOPID = '{$sShopId}'"; self::_getDatabase()->execute($sQuery); } // copy multi currency option value from possible hidden feature to module config if ((bool)$oConfig->getConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency') === true) { $oConfig->setConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency', true); $oConfig->saveShopConfVar( 'bool', 'blBestitAmazonPay4OxidEnableMultiCurrency', true, $oConfig->getShopId(), 'module:bestitamazonpay4oxid' ); } self::clearTmp(); }
[ "public", "static", "function", "onActivate", "(", ")", "{", "$", "sSql", "=", "\"SELECT COUNT(OXID)\n FROM oxpayments\n WHERE OXID IN ('jagamazon', 'bestitamazon')\"", ";", "//Insert payment records to DB", "$", "iRes", "=", "self", "::", "_getDatabase", ...
Execute required sql statements. @throws oxConnectionException
[ "Execute", "required", "sql", "statements", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L225-L306
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init.getCurrentVersion
public static function getCurrentVersion() { $aVersions = (array)self::_getConfig()->getConfigParam('aModuleVersions'); $aPossibleModuleNames = array( 'jagAmazonPayment4Oxid', 'bestitAmazonPay4Oxid' ); foreach ($aPossibleModuleNames as $sPossibleModuleName) { if (isset($aVersions[$sPossibleModuleName]) === true) { return $aVersions[$sPossibleModuleName]; } elseif (isset($aVersions[strtolower($sPossibleModuleName)]) === true) { return $aVersions[strtolower($sPossibleModuleName)]; } } return null; }
php
public static function getCurrentVersion() { $aVersions = (array)self::_getConfig()->getConfigParam('aModuleVersions'); $aPossibleModuleNames = array( 'jagAmazonPayment4Oxid', 'bestitAmazonPay4Oxid' ); foreach ($aPossibleModuleNames as $sPossibleModuleName) { if (isset($aVersions[$sPossibleModuleName]) === true) { return $aVersions[$sPossibleModuleName]; } elseif (isset($aVersions[strtolower($sPossibleModuleName)]) === true) { return $aVersions[strtolower($sPossibleModuleName)]; } } return null; }
[ "public", "static", "function", "getCurrentVersion", "(", ")", "{", "$", "aVersions", "=", "(", "array", ")", "self", "::", "_getConfig", "(", ")", "->", "getConfigParam", "(", "'aModuleVersions'", ")", ";", "$", "aPossibleModuleNames", "=", "array", "(", "'...
Returns the current installed version. @return null|string
[ "Returns", "the", "current", "installed", "version", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L327-L345
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_init.php
bestitAmazonPay4Oxid_init.clearTmp
public static function clearTmp() { $sTmpDir = self::_getConfig()->getConfigParam('sCompileDir'); $sTmpDir = rtrim($sTmpDir, '/').'/'; $sSmartyDir = $sTmpDir.'smarty/'; foreach (self::_streamSafeGlob($sTmpDir, '*.txt') as $sFileName) { unlink($sFileName); } foreach (self::_streamSafeGlob($sSmartyDir, '*.php') as $sFileName) { unlink($sFileName); } }
php
public static function clearTmp() { $sTmpDir = self::_getConfig()->getConfigParam('sCompileDir'); $sTmpDir = rtrim($sTmpDir, '/').'/'; $sSmartyDir = $sTmpDir.'smarty/'; foreach (self::_streamSafeGlob($sTmpDir, '*.txt') as $sFileName) { unlink($sFileName); } foreach (self::_streamSafeGlob($sSmartyDir, '*.php') as $sFileName) { unlink($sFileName); } }
[ "public", "static", "function", "clearTmp", "(", ")", "{", "$", "sTmpDir", "=", "self", "::", "_getConfig", "(", ")", "->", "getConfigParam", "(", "'sCompileDir'", ")", ";", "$", "sTmpDir", "=", "rtrim", "(", "$", "sTmpDir", ",", "'/'", ")", ".", "'/'"...
Clear tmp dir and smarty cache. @return void
[ "Clear", "tmp", "dir", "and", "smarty", "cache", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_init.php#L383-L396
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient._getAmazonClient
protected function _getAmazonClient($aConfig = array()) { if ($this->_oAmazonClient === null) { $aConfig = array_merge( $aConfig, array( 'merchant_id' => $this->getConfig()->getConfigParam('sAmazonSellerId'), 'access_key' => $this->getConfig()->getConfigParam('sAmazonAWSAccessKeyId'), 'secret_key' => $this->getConfig()->getConfigParam('sAmazonSignature'), 'client_id' => $this->getConfig()->getConfigParam('sAmazonLoginClientId'), 'region' => $this->getConfig()->getConfigParam('sAmazonLocale') ) ); $this->_oAmazonClient = new Client($aConfig); $this->_oAmazonClient->setSandbox((bool)$this->getConfig()->getConfigParam('blAmazonSandboxActive')); $this->_oAmazonClient->setLogger($this->_getLogger()); } return $this->_oAmazonClient; }
php
protected function _getAmazonClient($aConfig = array()) { if ($this->_oAmazonClient === null) { $aConfig = array_merge( $aConfig, array( 'merchant_id' => $this->getConfig()->getConfigParam('sAmazonSellerId'), 'access_key' => $this->getConfig()->getConfigParam('sAmazonAWSAccessKeyId'), 'secret_key' => $this->getConfig()->getConfigParam('sAmazonSignature'), 'client_id' => $this->getConfig()->getConfigParam('sAmazonLoginClientId'), 'region' => $this->getConfig()->getConfigParam('sAmazonLocale') ) ); $this->_oAmazonClient = new Client($aConfig); $this->_oAmazonClient->setSandbox((bool)$this->getConfig()->getConfigParam('blAmazonSandboxActive')); $this->_oAmazonClient->setLogger($this->_getLogger()); } return $this->_oAmazonClient; }
[ "protected", "function", "_getAmazonClient", "(", "$", "aConfig", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "_oAmazonClient", "===", "null", ")", "{", "$", "aConfig", "=", "array_merge", "(", "$", "aConfig", ",", "array", "(", "'m...
Returns the amazon api client. @param array $aConfig @return Client @throws Exception
[ "Returns", "the", "amazon", "api", "client", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L129-L149
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient._addSandboxSimulationParams
protected function _addSandboxSimulationParams($sMethod, array &$aParams) { //If Sandbox mode is inactive or Sandbox Simulation is not selected don't add any Simulation Params if ((bool) $this->getConfig()->getConfigParam('blAmazonSandboxActive') !== true || (bool) $this->getConfig()->getConfigParam('sSandboxSimulation') === false ) { return; } $sSandboxSimulation = (string) $this->getConfig()->getConfigParam('sSandboxSimulation'); $aMap = array( 'setOrderReferenceDetails' => array( 'SetOrderReferenceDetailsPaymentMethodNotAllowed' => array( 'OrderReferenceAttributes.SellerNote' => '{"SandboxSimulation":{"Constraint":"PaymentMethodNotAllowed"}}' ) ), 'closeOrderReference' => array( 'CloseOrderReferenceAmazonClosed' => array( 'ClosureReason' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'authorize' => array( 'AuthorizeInvalidPaymentMethod' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"InvalidPaymentMethod","PaymentMethodUpdateTimeInMins":5}}' ), 'AuthorizeAmazonRejected' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ), 'AuthorizeTransactionTimedOut' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"TransactionTimedOut"}}' ), 'AuthorizeExpiredUnused' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"ExpiredUnused","ExpirationTimeInMins":1}}' ), 'AuthorizeAmazonClosed' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'capture' => array( 'CapturePending' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Pending"}}' ), 'CaptureAmazonRejected' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ), 'CaptureAmazonClosed' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'refund' => array( 'CaptureAmazonClosed' => array( 'SellerRefundNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ) ) ); if (isset($aMap[$sMethod][$sSandboxSimulation])) { $aParams = array_merge($aParams, $aMap[$sMethod][$sSandboxSimulation]); } }
php
protected function _addSandboxSimulationParams($sMethod, array &$aParams) { //If Sandbox mode is inactive or Sandbox Simulation is not selected don't add any Simulation Params if ((bool) $this->getConfig()->getConfigParam('blAmazonSandboxActive') !== true || (bool) $this->getConfig()->getConfigParam('sSandboxSimulation') === false ) { return; } $sSandboxSimulation = (string) $this->getConfig()->getConfigParam('sSandboxSimulation'); $aMap = array( 'setOrderReferenceDetails' => array( 'SetOrderReferenceDetailsPaymentMethodNotAllowed' => array( 'OrderReferenceAttributes.SellerNote' => '{"SandboxSimulation":{"Constraint":"PaymentMethodNotAllowed"}}' ) ), 'closeOrderReference' => array( 'CloseOrderReferenceAmazonClosed' => array( 'ClosureReason' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'authorize' => array( 'AuthorizeInvalidPaymentMethod' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"InvalidPaymentMethod","PaymentMethodUpdateTimeInMins":5}}' ), 'AuthorizeAmazonRejected' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ), 'AuthorizeTransactionTimedOut' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"TransactionTimedOut"}}' ), 'AuthorizeExpiredUnused' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"ExpiredUnused","ExpirationTimeInMins":1}}' ), 'AuthorizeAmazonClosed' => array( 'SellerAuthorizationNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'capture' => array( 'CapturePending' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Pending"}}' ), 'CaptureAmazonRejected' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ), 'CaptureAmazonClosed' => array( 'SellerCaptureNote' => '{"SandboxSimulation": {"State":"Closed","ReasonCode":"AmazonClosed"}}' ) ), 'refund' => array( 'CaptureAmazonClosed' => array( 'SellerRefundNote' => '{"SandboxSimulation": {"State":"Declined","ReasonCode":"AmazonRejected"}}' ) ) ); if (isset($aMap[$sMethod][$sSandboxSimulation])) { $aParams = array_merge($aParams, $aMap[$sMethod][$sSandboxSimulation]); } }
[ "protected", "function", "_addSandboxSimulationParams", "(", "$", "sMethod", ",", "array", "&", "$", "aParams", ")", "{", "//If Sandbox mode is inactive or Sandbox Simulation is not selected don't add any Simulation Params", "if", "(", "(", "bool", ")", "$", "this", "->", ...
Amazon add sandbox simulation params @param string $sMethod @param array $aParams
[ "Amazon", "add", "sandbox", "simulation", "params" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L167-L227
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.getAmazonProperty
public function getAmazonProperty($sPropertyName, $blCommon = false) { $sSandboxPrefix = ''; if ($blCommon === false && (bool)$this->getConfig()->getConfigParam('blAmazonSandboxActive') === true) { $sSandboxPrefix = 'Sandbox'; } $sAmazonLocale = $this->getConfig()->getConfigParam('sAmazonLocale'); $sPropertyName = '_'.$sPropertyName.$sAmazonLocale.$sSandboxPrefix; if (property_exists($this, $sPropertyName)) { return $this->$sPropertyName; } return null; }
php
public function getAmazonProperty($sPropertyName, $blCommon = false) { $sSandboxPrefix = ''; if ($blCommon === false && (bool)$this->getConfig()->getConfigParam('blAmazonSandboxActive') === true) { $sSandboxPrefix = 'Sandbox'; } $sAmazonLocale = $this->getConfig()->getConfigParam('sAmazonLocale'); $sPropertyName = '_'.$sPropertyName.$sAmazonLocale.$sSandboxPrefix; if (property_exists($this, $sPropertyName)) { return $this->$sPropertyName; } return null; }
[ "public", "function", "getAmazonProperty", "(", "$", "sPropertyName", ",", "$", "blCommon", "=", "false", ")", "{", "$", "sSandboxPrefix", "=", "''", ";", "if", "(", "$", "blCommon", "===", "false", "&&", "(", "bool", ")", "$", "this", "->", "getConfig",...
Returns class property by given property name and other params @param string $sPropertyName Property name @param boolean $blCommon Include 'Sandbox' in property name or not @return mixed
[ "Returns", "class", "property", "by", "given", "property", "name", "and", "other", "params" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L237-L253
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.processOrderReference
public function processOrderReference(oxOrder $oOrder, stdClass $oOrderReference) { $sOrderReferenceStatus = $oOrderReference ->OrderReferenceStatus ->State; //Do re-authorization if order was suspended and now it's opened if ($sOrderReferenceStatus === 'Open' && (string)$oOrder->getFieldData('oxtransstatus') === 'AMZ-Order-Suspended' ) { $this->authorize($oOrder); } else { $oOrder->assign(array('oxtransstatus' => 'AMZ-Order-'.$sOrderReferenceStatus)); $oOrder->save(); } }
php
public function processOrderReference(oxOrder $oOrder, stdClass $oOrderReference) { $sOrderReferenceStatus = $oOrderReference ->OrderReferenceStatus ->State; //Do re-authorization if order was suspended and now it's opened if ($sOrderReferenceStatus === 'Open' && (string)$oOrder->getFieldData('oxtransstatus') === 'AMZ-Order-Suspended' ) { $this->authorize($oOrder); } else { $oOrder->assign(array('oxtransstatus' => 'AMZ-Order-'.$sOrderReferenceStatus)); $oOrder->save(); } }
[ "public", "function", "processOrderReference", "(", "oxOrder", "$", "oOrder", ",", "stdClass", "$", "oOrderReference", ")", "{", "$", "sOrderReferenceStatus", "=", "$", "oOrderReference", "->", "OrderReferenceStatus", "->", "State", ";", "//Do re-authorization if order ...
Process order reference. @param oxOrder $oOrder @param stdClass $oOrderReference @throws Exception
[ "Process", "order", "reference", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L262-L277
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.getOrderReferenceDetails
public function getOrderReferenceDetails($oOrder = null, array $aParams = array(), $blReadonly = false) { $aRequestParameters = array(); $sAmazonOrderReferenceId = ($oOrder === null) ? (string)$this->getSession()->getVariable('amazonOrderReferenceId') : ''; if ($oOrder !== null) { $aRequestParameters['amazon_order_reference_id'] = $oOrder->getFieldData('bestitamazonorderreferenceid'); } elseif ($sAmazonOrderReferenceId !== '') { $aRequestParameters['amazon_order_reference_id'] = $sAmazonOrderReferenceId; $sLoginToken = (string)$this->getSession()->getVariable('amazonLoginToken'); if ($sLoginToken !== '') { $aRequestParameters['address_consent_token'] = $sLoginToken; } } //Make request $aRequestParameters = array_merge($aRequestParameters, $aParams); $oData = $this->_convertResponse($this->_getAmazonClient()->getOrderReferenceDetails($aRequestParameters)); //Update Order info if ($blReadonly === false && $oOrder !== null && isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderReferenceStatus->State) ) { $this->processOrderReference( $oOrder, $oData->GetOrderReferenceDetailsResult->OrderReferenceDetails ); } return $oData; }
php
public function getOrderReferenceDetails($oOrder = null, array $aParams = array(), $blReadonly = false) { $aRequestParameters = array(); $sAmazonOrderReferenceId = ($oOrder === null) ? (string)$this->getSession()->getVariable('amazonOrderReferenceId') : ''; if ($oOrder !== null) { $aRequestParameters['amazon_order_reference_id'] = $oOrder->getFieldData('bestitamazonorderreferenceid'); } elseif ($sAmazonOrderReferenceId !== '') { $aRequestParameters['amazon_order_reference_id'] = $sAmazonOrderReferenceId; $sLoginToken = (string)$this->getSession()->getVariable('amazonLoginToken'); if ($sLoginToken !== '') { $aRequestParameters['address_consent_token'] = $sLoginToken; } } //Make request $aRequestParameters = array_merge($aRequestParameters, $aParams); $oData = $this->_convertResponse($this->_getAmazonClient()->getOrderReferenceDetails($aRequestParameters)); //Update Order info if ($blReadonly === false && $oOrder !== null && isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderReferenceStatus->State) ) { $this->processOrderReference( $oOrder, $oData->GetOrderReferenceDetailsResult->OrderReferenceDetails ); } return $oData; }
[ "public", "function", "getOrderReferenceDetails", "(", "$", "oOrder", "=", "null", ",", "array", "$", "aParams", "=", "array", "(", ")", ",", "$", "blReadonly", "=", "false", ")", "{", "$", "aRequestParameters", "=", "array", "(", ")", ";", "$", "sAmazon...
Amazon GetOrderReferenceDetails method @param oxOrder $oOrder @param array $aParams Custom parameters to send @param bool $blReadonly @return stdClass @throws Exception
[ "Amazon", "GetOrderReferenceDetails", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L289-L323
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.setOrderReferenceDetails
public function setOrderReferenceDetails($oBasket = null, array $aRequestParameters = array()) { //Set default params $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId'); if ($oBasket !== null) { $oActiveShop = $this->getConfig()->getActiveShop(); $sShopName = $oActiveShop->getFieldData('oxname'); $sOxidVersion = $oActiveShop->getFieldData('oxversion'); $sModuleVersion = bestitAmazonPay4Oxid_init::getCurrentVersion(); $aRequestParameters = array_merge( $aRequestParameters, array( 'amount' => $oBasket->getPrice()->getBruttoPrice(), 'currency_code' => $oBasket->getBasketCurrency()->name, 'platform_id' => 'A26EQAZK19E0U2', 'store_name' => $sShopName, 'custom_information' => "created by best it, OXID eShop v{$sOxidVersion}, v{$sModuleVersion}" ) ); } $this->_addSandboxSimulationParams('setOrderReferenceDetails', $aRequestParameters); return $this->_convertResponse($this->_getAmazonClient()->setOrderReferenceDetails($aRequestParameters)); }
php
public function setOrderReferenceDetails($oBasket = null, array $aRequestParameters = array()) { //Set default params $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId'); if ($oBasket !== null) { $oActiveShop = $this->getConfig()->getActiveShop(); $sShopName = $oActiveShop->getFieldData('oxname'); $sOxidVersion = $oActiveShop->getFieldData('oxversion'); $sModuleVersion = bestitAmazonPay4Oxid_init::getCurrentVersion(); $aRequestParameters = array_merge( $aRequestParameters, array( 'amount' => $oBasket->getPrice()->getBruttoPrice(), 'currency_code' => $oBasket->getBasketCurrency()->name, 'platform_id' => 'A26EQAZK19E0U2', 'store_name' => $sShopName, 'custom_information' => "created by best it, OXID eShop v{$sOxidVersion}, v{$sModuleVersion}" ) ); } $this->_addSandboxSimulationParams('setOrderReferenceDetails', $aRequestParameters); return $this->_convertResponse($this->_getAmazonClient()->setOrderReferenceDetails($aRequestParameters)); }
[ "public", "function", "setOrderReferenceDetails", "(", "$", "oBasket", "=", "null", ",", "array", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "//Set default params", "$", "aRequestParameters", "[", "'amazon_order_reference_id'", "]", "=", "$", "th...
Amazon SetOrderReferenceDetails method @param oxBasket $oBasket OXID Basket object @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "SetOrderReferenceDetails", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L334-L360
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.confirmOrderReference
public function confirmOrderReference(array $aRequestParameters = array()) { //Set params $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId'); return $this->_convertResponse($this->_getAmazonClient()->confirmOrderReference($aRequestParameters)); }
php
public function confirmOrderReference(array $aRequestParameters = array()) { //Set params $aRequestParameters['amazon_order_reference_id'] = $this->getSession()->getVariable('amazonOrderReferenceId'); return $this->_convertResponse($this->_getAmazonClient()->confirmOrderReference($aRequestParameters)); }
[ "public", "function", "confirmOrderReference", "(", "array", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "//Set params", "$", "aRequestParameters", "[", "'amazon_order_reference_id'", "]", "=", "$", "this", "->", "getSession", "(", ")", "->", "g...
Amazon ConfirmOrderReference method @param array $aRequestParameters Custom parameters to send @return stdClass response XML @throws Exception
[ "Amazon", "ConfirmOrderReference", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L370-L376
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient._setOrderTransactionErrorStatus
protected function _setOrderTransactionErrorStatus(oxOrder $oOrder, stdClass $oData, $sStatus = null) { if (isset($oData->Error->Code) && (bool) $oData->Error->Code !== false) { if ($sStatus === null) { $sStatus = 'AMZ-Error-'.$oData->Error->Code; } $oOrder->assign(array('oxtransstatus' => $sStatus)); $oOrder->save(); return true; } return false; }
php
protected function _setOrderTransactionErrorStatus(oxOrder $oOrder, stdClass $oData, $sStatus = null) { if (isset($oData->Error->Code) && (bool) $oData->Error->Code !== false) { if ($sStatus === null) { $sStatus = 'AMZ-Error-'.$oData->Error->Code; } $oOrder->assign(array('oxtransstatus' => $sStatus)); $oOrder->save(); return true; } return false; }
[ "protected", "function", "_setOrderTransactionErrorStatus", "(", "oxOrder", "$", "oOrder", ",", "stdClass", "$", "oData", ",", "$", "sStatus", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "oData", "->", "Error", "->", "Code", ")", "&&", "(", "boo...
Sets the order status @param oxOrder $oOrder @param stdClass $oData @param string $sStatus @return bool
[ "Sets", "the", "order", "status" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L387-L401
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.closeOrderReference
public function closeOrderReference($oOrder = null, $aRequestParameters = array(), $blUpdateOrderStatus = true) { $oData = $this->_callOrderRequest( 'closeOrderReference', $oOrder, $aRequestParameters, array('amazon_order_reference_id'), $blProcessable, 'AMZ-Order-Closed' ); //Update Order info if ($blUpdateOrderStatus === true && $blProcessable === true) { $oOrder->assign(array( 'oxtransstatus' => 'AMZ-Order-Closed' )); $oOrder->save(); } return $oData; }
php
public function closeOrderReference($oOrder = null, $aRequestParameters = array(), $blUpdateOrderStatus = true) { $oData = $this->_callOrderRequest( 'closeOrderReference', $oOrder, $aRequestParameters, array('amazon_order_reference_id'), $blProcessable, 'AMZ-Order-Closed' ); //Update Order info if ($blUpdateOrderStatus === true && $blProcessable === true) { $oOrder->assign(array( 'oxtransstatus' => 'AMZ-Order-Closed' )); $oOrder->save(); } return $oData; }
[ "public", "function", "closeOrderReference", "(", "$", "oOrder", "=", "null", ",", "$", "aRequestParameters", "=", "array", "(", ")", ",", "$", "blUpdateOrderStatus", "=", "true", ")", "{", "$", "oData", "=", "$", "this", "->", "_callOrderRequest", "(", "'...
Amazon CloseOrderReference method @param oxOrder $oOrder OXID Order object @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "CloseOrderReference", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L528-L548
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.authorize
public function authorize($oOrder = null, $aRequestParameters = array(), $blForceSync = false) { $sMode = $this->getConfig()->getConfigParam('sAmazonMode'); $aRequestParameters['transaction_timeout'] = ($sMode === bestitAmazonPay4OxidClient::BASIC_FLOW || $blForceSync) ? 0 : 1440; $oData = $this->_callOrderRequest( 'authorize', $oOrder, $aRequestParameters, array( 'amazon_order_reference_id', 'authorization_amount', 'currency_code', 'authorization_reference_id', 'seller_authorization_note' ), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus->State) ) { $oDetails = $oData->AuthorizeResult->AuthorizationDetails; $oOrder->assign(array( 'bestitamazonauthorizationid' => $oDetails->AmazonAuthorizationId, 'oxtransstatus' => 'AMZ-Authorize-'.$oDetails->AuthorizationStatus->State )); $oOrder->save(); } return $oData; }
php
public function authorize($oOrder = null, $aRequestParameters = array(), $blForceSync = false) { $sMode = $this->getConfig()->getConfigParam('sAmazonMode'); $aRequestParameters['transaction_timeout'] = ($sMode === bestitAmazonPay4OxidClient::BASIC_FLOW || $blForceSync) ? 0 : 1440; $oData = $this->_callOrderRequest( 'authorize', $oOrder, $aRequestParameters, array( 'amazon_order_reference_id', 'authorization_amount', 'currency_code', 'authorization_reference_id', 'seller_authorization_note' ), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus->State) ) { $oDetails = $oData->AuthorizeResult->AuthorizationDetails; $oOrder->assign(array( 'bestitamazonauthorizationid' => $oDetails->AmazonAuthorizationId, 'oxtransstatus' => 'AMZ-Authorize-'.$oDetails->AuthorizationStatus->State )); $oOrder->save(); } return $oData; }
[ "public", "function", "authorize", "(", "$", "oOrder", "=", "null", ",", "$", "aRequestParameters", "=", "array", "(", ")", ",", "$", "blForceSync", "=", "false", ")", "{", "$", "sMode", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getConfigPa...
Amazon Authorize method @param oxOrder $oOrder OXID Order object @param array $aRequestParameters Custom parameters to send @param bool $blForceSync If true we force the sync mode @return stdClass @throws Exception
[ "Amazon", "Authorize", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L581-L614
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.processAuthorization
public function processAuthorization(oxOrder $oOrder, stdClass $oAuthorizationDetails) { $oAuthorizationStatus = $oAuthorizationDetails->AuthorizationStatus; //Update Order with primary response info $oOrder->assign(array('oxtransstatus' => 'AMZ-Authorize-'.$oAuthorizationStatus->State)); $oOrder->save(); // Handle Declined response if ($oAuthorizationStatus->State === 'Declined' && $this->getConfig()->getConfigParam('sAmazonMode') === bestitAmazonPay4OxidClient::OPTIMIZED_FLOW ) { switch ($oAuthorizationStatus->ReasonCode) { case "InvalidPaymentMethod": /** @var bestitAmazonPay4Oxid_oxEmail $oEmail */ $oEmail = $this->getObjectFactory()->createOxidObject('oxEmail'); $oEmail->sendAmazonInvalidPaymentEmail($oOrder); break; case "AmazonRejected": /** @var bestitAmazonPay4Oxid_oxEmail $oEmail */ $oEmail = $this->getObjectFactory()->createOxidObject('oxEmail'); $oEmail->sendAmazonRejectedPaymentEmail($oOrder); $this->closeOrderReference($oOrder, array(), false); break; default: $this->closeOrderReference($oOrder, array(), false); } } //Authorize handling was selected Direct Capture after Authorize and Authorization status is Open if ($oAuthorizationStatus->State === 'Open' && $this->getConfig()->getConfigParam('sAmazonCapture') === 'DIRECT' ) { $this->capture($oOrder); } }
php
public function processAuthorization(oxOrder $oOrder, stdClass $oAuthorizationDetails) { $oAuthorizationStatus = $oAuthorizationDetails->AuthorizationStatus; //Update Order with primary response info $oOrder->assign(array('oxtransstatus' => 'AMZ-Authorize-'.$oAuthorizationStatus->State)); $oOrder->save(); // Handle Declined response if ($oAuthorizationStatus->State === 'Declined' && $this->getConfig()->getConfigParam('sAmazonMode') === bestitAmazonPay4OxidClient::OPTIMIZED_FLOW ) { switch ($oAuthorizationStatus->ReasonCode) { case "InvalidPaymentMethod": /** @var bestitAmazonPay4Oxid_oxEmail $oEmail */ $oEmail = $this->getObjectFactory()->createOxidObject('oxEmail'); $oEmail->sendAmazonInvalidPaymentEmail($oOrder); break; case "AmazonRejected": /** @var bestitAmazonPay4Oxid_oxEmail $oEmail */ $oEmail = $this->getObjectFactory()->createOxidObject('oxEmail'); $oEmail->sendAmazonRejectedPaymentEmail($oOrder); $this->closeOrderReference($oOrder, array(), false); break; default: $this->closeOrderReference($oOrder, array(), false); } } //Authorize handling was selected Direct Capture after Authorize and Authorization status is Open if ($oAuthorizationStatus->State === 'Open' && $this->getConfig()->getConfigParam('sAmazonCapture') === 'DIRECT' ) { $this->capture($oOrder); } }
[ "public", "function", "processAuthorization", "(", "oxOrder", "$", "oOrder", ",", "stdClass", "$", "oAuthorizationDetails", ")", "{", "$", "oAuthorizationStatus", "=", "$", "oAuthorizationDetails", "->", "AuthorizationStatus", ";", "//Update Order with primary response info...
Processes the authorization @param oxOrder $oOrder @param stdClass $oAuthorizationDetails @throws Exception
[ "Processes", "the", "authorization" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L623-L658
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.getAuthorizationDetails
public function getAuthorizationDetails($oOrder = null, array $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'getAuthorizationDetails', $oOrder, $aRequestParameters, array('amazon_authorization_id'), $blProcessable ); if ($blProcessable === true && isset($oData->GetAuthorizationDetailsResult->AuthorizationDetails->AuthorizationStatus->State) ) { $this->processAuthorization($oOrder, $oData->GetAuthorizationDetailsResult->AuthorizationDetails); } return $oData; }
php
public function getAuthorizationDetails($oOrder = null, array $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'getAuthorizationDetails', $oOrder, $aRequestParameters, array('amazon_authorization_id'), $blProcessable ); if ($blProcessable === true && isset($oData->GetAuthorizationDetailsResult->AuthorizationDetails->AuthorizationStatus->State) ) { $this->processAuthorization($oOrder, $oData->GetAuthorizationDetailsResult->AuthorizationDetails); } return $oData; }
[ "public", "function", "getAuthorizationDetails", "(", "$", "oOrder", "=", "null", ",", "array", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "$", "oData", "=", "$", "this", "->", "_callOrderRequest", "(", "'getAuthorizationDetails'", ",", "$", ...
Amazon GetAuthorizationDetails method @param oxOrder $oOrder OXID Order object @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "GetAuthorizationDetails", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L669-L686
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.capture
public function capture($oOrder = null, $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'capture', $oOrder, $aRequestParameters, array( 'amazon_authorization_id', 'capture_amount', 'currency_code', 'capture_reference_id', 'seller_capture_note' ), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->CaptureResult->CaptureDetails)) { $this->setCaptureState($oOrder, $oData->CaptureResult->CaptureDetails); $this->closeOrderReference($oOrder, array(), false); } return $oData; }
php
public function capture($oOrder = null, $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'capture', $oOrder, $aRequestParameters, array( 'amazon_authorization_id', 'capture_amount', 'currency_code', 'capture_reference_id', 'seller_capture_note' ), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->CaptureResult->CaptureDetails)) { $this->setCaptureState($oOrder, $oData->CaptureResult->CaptureDetails); $this->closeOrderReference($oOrder, array(), false); } return $oData; }
[ "public", "function", "capture", "(", "$", "oOrder", "=", "null", ",", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "$", "oData", "=", "$", "this", "->", "_callOrderRequest", "(", "'capture'", ",", "$", "oOrder", ",", "$", "aRequestParame...
Amazon Capture method @param oxOrder $oOrder OXID Order object @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "Capture", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L722-L745
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.getCaptureDetails
public function getCaptureDetails($oOrder = null, $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'getCaptureDetails', $oOrder, $aRequestParameters, array('amazon_capture_id'), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->GetCaptureDetailsResult->CaptureDetails)) { $this->setCaptureState($oOrder, $oData->GetCaptureDetailsResult->CaptureDetails, true); } return $oData; }
php
public function getCaptureDetails($oOrder = null, $aRequestParameters = array()) { $oData = $this->_callOrderRequest( 'getCaptureDetails', $oOrder, $aRequestParameters, array('amazon_capture_id'), $blProcessable ); //Update Order info if ($blProcessable === true && isset($oData->GetCaptureDetailsResult->CaptureDetails)) { $this->setCaptureState($oOrder, $oData->GetCaptureDetailsResult->CaptureDetails, true); } return $oData; }
[ "public", "function", "getCaptureDetails", "(", "$", "oOrder", "=", "null", ",", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "$", "oData", "=", "$", "this", "->", "_callOrderRequest", "(", "'getCaptureDetails'", ",", "$", "oOrder", ",", "$...
Amazon GetCaptureDetails method @param oxOrder $oOrder OXID Order object @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "GetCaptureDetails", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L757-L773
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.saveCapture
public function saveCapture($oOrder = null) { if ((string)$oOrder->getFieldData('bestitAmazonCaptureId') !== '') { return $this->getCaptureDetails($oOrder); } elseif ((string)$oOrder->getFieldData('bestitAmazonAuthorizationId') !== '') { return $this->capture($oOrder); } return false; }
php
public function saveCapture($oOrder = null) { if ((string)$oOrder->getFieldData('bestitAmazonCaptureId') !== '') { return $this->getCaptureDetails($oOrder); } elseif ((string)$oOrder->getFieldData('bestitAmazonAuthorizationId') !== '') { return $this->capture($oOrder); } return false; }
[ "public", "function", "saveCapture", "(", "$", "oOrder", "=", "null", ")", "{", "if", "(", "(", "string", ")", "$", "oOrder", "->", "getFieldData", "(", "'bestitAmazonCaptureId'", ")", "!==", "''", ")", "{", "return", "$", "this", "->", "getCaptureDetails"...
Save capture call. @param oxOrder $oOrder @return stdClass|bool @throws Exception
[ "Save", "capture", "call", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L783-L792
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.refund
public function refund($oOrder = null, $fPrice, $aRequestParameters = array()) { //Refund ID if ($oOrder !== null) { $aRequestParameters['refund_amount'] = $fPrice; $this->_mapOrderToRequestParameters( $oOrder, $aRequestParameters, array('amazon_capture_id', 'currency_code', 'refund_reference_id', 'seller_refund_note') ); } //Make request $this->_addSandboxSimulationParams('refund', $aRequestParameters); $oData = $this->_convertResponse($this->_getAmazonClient()->refund($aRequestParameters)); //Update/Insert Refund info if ($oData && $oOrder !== null) { $sError = ''; $sAmazonRefundId = ''; if (isset($oData->Error)) { $sState = 'Error'; $sError = $oData->Error->Message; } else { $sState = $oData->RefundResult->RefundDetails->RefundStatus->State; $sAmazonRefundId = $oData->RefundResult->RefundDetails->AmazonRefundId; } $sId = $oOrder->getFieldData('bestitamazonorderreferenceid').'_'.$this->getUtilsDate()->getTime(); $sQuery = " INSERT bestitamazonrefunds SET ID = {$this->getDatabase()->quote($sId)}, OXORDERID = {$this->getDatabase()->quote($oOrder->getId())}, BESTITAMAZONREFUNDID = {$this->getDatabase()->quote($sAmazonRefundId)}, AMOUNT = {$fPrice}, STATE = {$this->getDatabase()->quote($sState)}, ERROR = {$this->getDatabase()->quote($sError)}, TIMESTAMP = NOW()"; $this->getDatabase()->execute($sQuery); } return $oData; }
php
public function refund($oOrder = null, $fPrice, $aRequestParameters = array()) { //Refund ID if ($oOrder !== null) { $aRequestParameters['refund_amount'] = $fPrice; $this->_mapOrderToRequestParameters( $oOrder, $aRequestParameters, array('amazon_capture_id', 'currency_code', 'refund_reference_id', 'seller_refund_note') ); } //Make request $this->_addSandboxSimulationParams('refund', $aRequestParameters); $oData = $this->_convertResponse($this->_getAmazonClient()->refund($aRequestParameters)); //Update/Insert Refund info if ($oData && $oOrder !== null) { $sError = ''; $sAmazonRefundId = ''; if (isset($oData->Error)) { $sState = 'Error'; $sError = $oData->Error->Message; } else { $sState = $oData->RefundResult->RefundDetails->RefundStatus->State; $sAmazonRefundId = $oData->RefundResult->RefundDetails->AmazonRefundId; } $sId = $oOrder->getFieldData('bestitamazonorderreferenceid').'_'.$this->getUtilsDate()->getTime(); $sQuery = " INSERT bestitamazonrefunds SET ID = {$this->getDatabase()->quote($sId)}, OXORDERID = {$this->getDatabase()->quote($oOrder->getId())}, BESTITAMAZONREFUNDID = {$this->getDatabase()->quote($sAmazonRefundId)}, AMOUNT = {$fPrice}, STATE = {$this->getDatabase()->quote($sState)}, ERROR = {$this->getDatabase()->quote($sError)}, TIMESTAMP = NOW()"; $this->getDatabase()->execute($sQuery); } return $oData; }
[ "public", "function", "refund", "(", "$", "oOrder", "=", "null", ",", "$", "fPrice", ",", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "//Refund ID", "if", "(", "$", "oOrder", "!==", "null", ")", "{", "$", "aRequestParameters", "[", "'r...
Amazon Refund method @param oxOrder $oOrder OXID Order object @param float $fPrice Price to refund @param array $aRequestParameters Custom parameters to send @return stdClass @throws Exception
[ "Amazon", "Refund", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L804-L849
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.getRefundDetails
public function getRefundDetails($sAmazonRefundId) { //Set default params $aRequestParameters['amazon_refund_id'] = $sAmazonRefundId; //Make request $oData = $this->_convertResponse($this->_getAmazonClient()->getRefundDetails($aRequestParameters)); //Update/Insert Refund info if ((array)$oData !== array()) { $sError = ''; if (isset($oData->Error) === true) { $sState = 'Error'; $sError = $oData->Error->Message; } else { $sState = $oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State; } $this->updateRefund($sAmazonRefundId, $sState, $sError); } return $oData; }
php
public function getRefundDetails($sAmazonRefundId) { //Set default params $aRequestParameters['amazon_refund_id'] = $sAmazonRefundId; //Make request $oData = $this->_convertResponse($this->_getAmazonClient()->getRefundDetails($aRequestParameters)); //Update/Insert Refund info if ((array)$oData !== array()) { $sError = ''; if (isset($oData->Error) === true) { $sState = 'Error'; $sError = $oData->Error->Message; } else { $sState = $oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State; } $this->updateRefund($sAmazonRefundId, $sState, $sError); } return $oData; }
[ "public", "function", "getRefundDetails", "(", "$", "sAmazonRefundId", ")", "{", "//Set default params", "$", "aRequestParameters", "[", "'amazon_refund_id'", "]", "=", "$", "sAmazonRefundId", ";", "//Make request", "$", "oData", "=", "$", "this", "->", "_convertRes...
Amazon GetRefundDetails method @var string $sAmazonRefundId @return stdClass @throws Exception
[ "Amazon", "GetRefundDetails", "method" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L879-L902
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidclient.php
bestitAmazonPay4OxidClient.setOrderAttributes
public function setOrderAttributes(oxOrder $oOrder, array $aRequestParameters = array()) { $this->_mapOrderToRequestParameters( $oOrder, $aRequestParameters, array('amazon_order_reference_id', 'seller_order_id') ); return $this->_getAmazonClient()->setOrderAttributes($aRequestParameters); }
php
public function setOrderAttributes(oxOrder $oOrder, array $aRequestParameters = array()) { $this->_mapOrderToRequestParameters( $oOrder, $aRequestParameters, array('amazon_order_reference_id', 'seller_order_id') ); return $this->_getAmazonClient()->setOrderAttributes($aRequestParameters); }
[ "public", "function", "setOrderAttributes", "(", "oxOrder", "$", "oOrder", ",", "array", "$", "aRequestParameters", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_mapOrderToRequestParameters", "(", "$", "oOrder", ",", "$", "aRequestParameters", ",", "a...
Sets the order attributes. @param oxOrder $oOrder @param array $aRequestParameters @return ResponseParser @throws Exception
[ "Sets", "the", "order", "attributes", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidclient.php#L913-L922
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_user.php
bestitAmazonPay4Oxid_user.render
public function render() { $sOrderReferenceId = $this->_getContainer()->getConfig()->getRequestParameter('amazonOrderReferenceId'); if ($sOrderReferenceId) { $this->_getContainer()->getSession()->setVariable('amazonOrderReferenceId', $sOrderReferenceId); } return parent::render(); }
php
public function render() { $sOrderReferenceId = $this->_getContainer()->getConfig()->getRequestParameter('amazonOrderReferenceId'); if ($sOrderReferenceId) { $this->_getContainer()->getSession()->setVariable('amazonOrderReferenceId', $sOrderReferenceId); } return parent::render(); }
[ "public", "function", "render", "(", ")", "{", "$", "sOrderReferenceId", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getRequestParameter", "(", "'amazonOrderReferenceId'", ")", ";", "if", "(", "$", "sOrderReferenceId"...
Set Amazon reference ID to session @return mixed @throws oxSystemComponentException
[ "Set", "Amazon", "reference", "ID", "to", "session" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_user.php#L36-L45
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidaddressutil.php
bestitAmazonPay4OxidAddressUtil._parseSingleAddress
protected function _parseSingleAddress($sString, $sIsoCountryCode = null) { // Array of iso2 codes of countries that have address format <street_no> <street> $aStreetNoStreetCountries = $this->getConfig()->getConfigParam('aAmazonStreetNoStreetCountries'); if (in_array($sIsoCountryCode, $aStreetNoStreetCountries)) { // matches streetname/streetnumber like "streetnumber streetname" preg_match('/\s*(?P<Number>\d[^\s]*)*\s*(?P<Name>[^\d]*[^\d\s])\s*(?P<AddInfo>.*)/', $sString, $aResult); } else { // default: matches streetname/streetnumber like "streetname streetnumber" preg_match('/\s*(?P<Name>[^\d]*[^\d\s])\s*((?P<Number>\d[^\s]*)\s*(?P<AddInfo>.*))*/', $sString, $aResult); } return $aResult; }
php
protected function _parseSingleAddress($sString, $sIsoCountryCode = null) { // Array of iso2 codes of countries that have address format <street_no> <street> $aStreetNoStreetCountries = $this->getConfig()->getConfigParam('aAmazonStreetNoStreetCountries'); if (in_array($sIsoCountryCode, $aStreetNoStreetCountries)) { // matches streetname/streetnumber like "streetnumber streetname" preg_match('/\s*(?P<Number>\d[^\s]*)*\s*(?P<Name>[^\d]*[^\d\s])\s*(?P<AddInfo>.*)/', $sString, $aResult); } else { // default: matches streetname/streetnumber like "streetname streetnumber" preg_match('/\s*(?P<Name>[^\d]*[^\d\s])\s*((?P<Number>\d[^\s]*)\s*(?P<AddInfo>.*))*/', $sString, $aResult); } return $aResult; }
[ "protected", "function", "_parseSingleAddress", "(", "$", "sString", ",", "$", "sIsoCountryCode", "=", "null", ")", "{", "// Array of iso2 codes of countries that have address format <street_no> <street>", "$", "aStreetNoStreetCountries", "=", "$", "this", "->", "getConfig", ...
Returns parsed Street name and Street number in array @param string $sString Full address @param string $sIsoCountryCode ISO2 code of country of address @return string
[ "Returns", "parsed", "Street", "name", "and", "Street", "number", "in", "array" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidaddressutil.php#L18-L32
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidaddressutil.php
bestitAmazonPay4OxidAddressUtil._parseAddressFields
protected function _parseAddressFields($oAmazonData, array &$aResult) { // Cleanup address fields and store them to an array $aAmazonAddresses = array( 1 => is_string($oAmazonData->AddressLine1) ? trim($oAmazonData->AddressLine1) : '', 2 => is_string($oAmazonData->AddressLine2) ? trim($oAmazonData->AddressLine2) : '', 3 => is_string($oAmazonData->AddressLine3) ? trim($oAmazonData->AddressLine3) : '' ); // Array of iso2 codes of countries that have another addressline order $aReverseOrderCountries = $this->getConfig()->getConfigParam('aAmazonReverseOrderCountries'); $aMap = array_flip($aReverseOrderCountries); $aCheckOrder = isset($aMap[$oAmazonData->CountryCode]) === true ? array (2, 1) : array(1, 2); $sStreet = ''; $sCompany = ''; foreach ($aCheckOrder as $iCheck) { if ($aAmazonAddresses[$iCheck] !== '') { if ($sStreet !== '') { $sCompany = $aAmazonAddresses[$iCheck]; break; } $sStreet = $aAmazonAddresses[$iCheck]; } } if ($aAmazonAddresses[3] !== '') { $sCompany = ($sCompany === '') ? $aAmazonAddresses[3] : "{$sCompany}, {$aAmazonAddresses[3]}"; } $aResult['CompanyName'] = $sCompany; $aAddress = $this->_parseSingleAddress($sStreet, $oAmazonData->CountryCode); $aResult['Street'] = isset($aAddress['Name']) === true ? $aAddress['Name'] : ''; $aResult['StreetNr'] = isset($aAddress['Number']) === true ? $aAddress['Number'] : ''; $aResult['AddInfo'] = isset($aAddress['AddInfo']) === true ? $aAddress['AddInfo'] : ''; }
php
protected function _parseAddressFields($oAmazonData, array &$aResult) { // Cleanup address fields and store them to an array $aAmazonAddresses = array( 1 => is_string($oAmazonData->AddressLine1) ? trim($oAmazonData->AddressLine1) : '', 2 => is_string($oAmazonData->AddressLine2) ? trim($oAmazonData->AddressLine2) : '', 3 => is_string($oAmazonData->AddressLine3) ? trim($oAmazonData->AddressLine3) : '' ); // Array of iso2 codes of countries that have another addressline order $aReverseOrderCountries = $this->getConfig()->getConfigParam('aAmazonReverseOrderCountries'); $aMap = array_flip($aReverseOrderCountries); $aCheckOrder = isset($aMap[$oAmazonData->CountryCode]) === true ? array (2, 1) : array(1, 2); $sStreet = ''; $sCompany = ''; foreach ($aCheckOrder as $iCheck) { if ($aAmazonAddresses[$iCheck] !== '') { if ($sStreet !== '') { $sCompany = $aAmazonAddresses[$iCheck]; break; } $sStreet = $aAmazonAddresses[$iCheck]; } } if ($aAmazonAddresses[3] !== '') { $sCompany = ($sCompany === '') ? $aAmazonAddresses[3] : "{$sCompany}, {$aAmazonAddresses[3]}"; } $aResult['CompanyName'] = $sCompany; $aAddress = $this->_parseSingleAddress($sStreet, $oAmazonData->CountryCode); $aResult['Street'] = isset($aAddress['Name']) === true ? $aAddress['Name'] : ''; $aResult['StreetNr'] = isset($aAddress['Number']) === true ? $aAddress['Number'] : ''; $aResult['AddInfo'] = isset($aAddress['AddInfo']) === true ? $aAddress['AddInfo'] : ''; }
[ "protected", "function", "_parseAddressFields", "(", "$", "oAmazonData", ",", "array", "&", "$", "aResult", ")", "{", "// Cleanup address fields and store them to an array", "$", "aAmazonAddresses", "=", "array", "(", "1", "=>", "is_string", "(", "$", "oAmazonData", ...
Parses the amazon address fields. @param \stdClass $oAmazonData @param array $aResult
[ "Parses", "the", "amazon", "address", "fields", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidaddressutil.php#L40-L78
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidaddressutil.php
bestitAmazonPay4OxidAddressUtil.parseAmazonAddress
public function parseAmazonAddress($oAmazonData) { //Cast to array $aResult = (array)$oAmazonData; //Parsing first and last names $aFullName = explode(' ', trim($oAmazonData->Name)); $aResult['LastName'] = array_pop($aFullName); $aResult['FirstName'] = implode(' ', $aFullName); $sTable = getViewName('oxcountry'); $oAmazonData->CountryCode = (string)$oAmazonData->CountryCode === 'UK' ? 'GB' : $oAmazonData->CountryCode; $sSql = "SELECT OXID FROM {$sTable} WHERE OXISOALPHA2 = ".$this->getDatabase()->quote($oAmazonData->CountryCode); //Country ID $aResult['CountryId'] = $this->getDatabase()->getOne($sSql); //Parsing address $this->_parseAddressFields($oAmazonData, $aResult); //If shop runs in non UTF-8 mode encode values to ANSI if ($this->getConfig()->isUtf() === false) { foreach ($aResult as $sKey => $sValue) { $aResult[$sKey] = $this->encodeString($sValue); } } return $aResult; }
php
public function parseAmazonAddress($oAmazonData) { //Cast to array $aResult = (array)$oAmazonData; //Parsing first and last names $aFullName = explode(' ', trim($oAmazonData->Name)); $aResult['LastName'] = array_pop($aFullName); $aResult['FirstName'] = implode(' ', $aFullName); $sTable = getViewName('oxcountry'); $oAmazonData->CountryCode = (string)$oAmazonData->CountryCode === 'UK' ? 'GB' : $oAmazonData->CountryCode; $sSql = "SELECT OXID FROM {$sTable} WHERE OXISOALPHA2 = ".$this->getDatabase()->quote($oAmazonData->CountryCode); //Country ID $aResult['CountryId'] = $this->getDatabase()->getOne($sSql); //Parsing address $this->_parseAddressFields($oAmazonData, $aResult); //If shop runs in non UTF-8 mode encode values to ANSI if ($this->getConfig()->isUtf() === false) { foreach ($aResult as $sKey => $sValue) { $aResult[$sKey] = $this->encodeString($sValue); } } return $aResult; }
[ "public", "function", "parseAmazonAddress", "(", "$", "oAmazonData", ")", "{", "//Cast to array", "$", "aResult", "=", "(", "array", ")", "$", "oAmazonData", ";", "//Parsing first and last names", "$", "aFullName", "=", "explode", "(", "' '", ",", "trim", "(", ...
Returns Parsed address from Amazon by specific rules @param object $oAmazonData Address object @return array Parsed Address @throws oxConnectionException
[ "Returns", "Parsed", "address", "from", "Amazon", "by", "specific", "rules" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidaddressutil.php#L88-L118
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidaddressutil.php
bestitAmazonPay4OxidAddressUtil.encodeString
public function encodeString($sString) { //If shop is running in UTF-8 nothing to do here if ($this->getConfig()->isUtf() === true) { return $sString; } $sShopEncoding = $this->getLanguage()->translateString('charset'); return iconv('UTF-8', $sShopEncoding, $sString); }
php
public function encodeString($sString) { //If shop is running in UTF-8 nothing to do here if ($this->getConfig()->isUtf() === true) { return $sString; } $sShopEncoding = $this->getLanguage()->translateString('charset'); return iconv('UTF-8', $sShopEncoding, $sString); }
[ "public", "function", "encodeString", "(", "$", "sString", ")", "{", "//If shop is running in UTF-8 nothing to do here", "if", "(", "$", "this", "->", "getConfig", "(", ")", "->", "isUtf", "(", ")", "===", "true", ")", "{", "return", "$", "sString", ";", "}"...
If shop is using non-Utf8 chars, encode string according used encoding @param string $sString the string to encode @return string encoded string
[ "If", "shop", "is", "using", "non", "-", "Utf8", "chars", "encode", "string", "according", "used", "encoding" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidaddressutil.php#L128-L137
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getActiveUser
public function getActiveUser() { if ($this->_oActiveUserObject === null) { $this->_oActiveUserObject = false; /** @var oxUser $oUser */ $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); if ($oUser->loadActiveUser() === true) { $this->_oActiveUserObject = $oUser; } } return $this->_oActiveUserObject; }
php
public function getActiveUser() { if ($this->_oActiveUserObject === null) { $this->_oActiveUserObject = false; /** @var oxUser $oUser */ $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); if ($oUser->loadActiveUser() === true) { $this->_oActiveUserObject = $oUser; } } return $this->_oActiveUserObject; }
[ "public", "function", "getActiveUser", "(", ")", "{", "if", "(", "$", "this", "->", "_oActiveUserObject", "===", "null", ")", "{", "$", "this", "->", "_oActiveUserObject", "=", "false", ";", "/** @var oxUser $oUser */", "$", "oUser", "=", "$", "this", "->", ...
Returns the active user object. @return oxUser|bool @throws oxSystemComponentException
[ "Returns", "the", "active", "user", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L96-L110
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getConfig
public function getConfig() { if ($this->_oConfigObject === null) { $this->_oConfigObject = oxRegistry::getConfig(); } return $this->_oConfigObject; }
php
public function getConfig() { if ($this->_oConfigObject === null) { $this->_oConfigObject = oxRegistry::getConfig(); } return $this->_oConfigObject; }
[ "public", "function", "getConfig", "(", ")", "{", "if", "(", "$", "this", "->", "_oConfigObject", "===", "null", ")", "{", "$", "this", "->", "_oConfigObject", "=", "oxRegistry", "::", "getConfig", "(", ")", ";", "}", "return", "$", "this", "->", "_oCo...
Returns the config object. @return oxConfig
[ "Returns", "the", "config", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L141-L148
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getDatabase
public function getDatabase() { if ($this->_oDatabaseObject === null) { $this->_oDatabaseObject = oxDb::getDb(oxDb::FETCH_MODE_ASSOC); } return $this->_oDatabaseObject; }
php
public function getDatabase() { if ($this->_oDatabaseObject === null) { $this->_oDatabaseObject = oxDb::getDb(oxDb::FETCH_MODE_ASSOC); } return $this->_oDatabaseObject; }
[ "public", "function", "getDatabase", "(", ")", "{", "if", "(", "$", "this", "->", "_oDatabaseObject", "===", "null", ")", "{", "$", "this", "->", "_oDatabaseObject", "=", "oxDb", "::", "getDb", "(", "oxDb", "::", "FETCH_MODE_ASSOC", ")", ";", "}", "retur...
Returns the database object. @return DatabaseInterface @throws oxConnectionException
[ "Returns", "the", "database", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L156-L163
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getIpnHandler
public function getIpnHandler() { if ($this->_oIpnHandlerObject === null) { $this->_oIpnHandlerObject = oxRegistry::get('bestitAmazonPay4OxidIpnHandler'); } return $this->_oIpnHandlerObject; }
php
public function getIpnHandler() { if ($this->_oIpnHandlerObject === null) { $this->_oIpnHandlerObject = oxRegistry::get('bestitAmazonPay4OxidIpnHandler'); } return $this->_oIpnHandlerObject; }
[ "public", "function", "getIpnHandler", "(", ")", "{", "if", "(", "$", "this", "->", "_oIpnHandlerObject", "===", "null", ")", "{", "$", "this", "->", "_oIpnHandlerObject", "=", "oxRegistry", "::", "get", "(", "'bestitAmazonPay4OxidIpnHandler'", ")", ";", "}", ...
Returns the ipn handler object. @return bestitAmazonPay4OxidIpnHandler
[ "Returns", "the", "ipn", "handler", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L170-L177
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getLanguage
public function getLanguage() { if ($this->_oLanguageObject === null) { $this->_oLanguageObject = oxRegistry::getLang(); } return $this->_oLanguageObject; }
php
public function getLanguage() { if ($this->_oLanguageObject === null) { $this->_oLanguageObject = oxRegistry::getLang(); } return $this->_oLanguageObject; }
[ "public", "function", "getLanguage", "(", ")", "{", "if", "(", "$", "this", "->", "_oLanguageObject", "===", "null", ")", "{", "$", "this", "->", "_oLanguageObject", "=", "oxRegistry", "::", "getLang", "(", ")", ";", "}", "return", "$", "this", "->", "...
Returns the language object. @return oxLang
[ "Returns", "the", "language", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L184-L191
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidcontainer.php
bestitAmazonPay4OxidContainer.getSession
public function getSession() { if ($this->_oSessionObject === null) { $this->_oSessionObject = oxRegistry::getSession(); } return $this->_oSessionObject; }
php
public function getSession() { if ($this->_oSessionObject === null) { $this->_oSessionObject = oxRegistry::getSession(); } return $this->_oSessionObject; }
[ "public", "function", "getSession", "(", ")", "{", "if", "(", "$", "this", "->", "_oSessionObject", "===", "null", ")", "{", "$", "this", "->", "_oSessionObject", "=", "oxRegistry", "::", "getSession", "(", ")", ";", "}", "return", "$", "this", "->", "...
Returns the session object. @return oxSession
[ "Returns", "the", "session", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidcontainer.php#L234-L241
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_payment.php
bestitAmazonPay4Oxid_payment.setPrimaryAmazonUserData
public function setPrimaryAmazonUserData() { $oUtils = $this->_getContainer()->getUtils(); $sShopSecureHomeUrl = $this->_getContainer()->getConfig()->getShopSecureHomeUrl(); //Get primary user data from Amazon $oData = $this->_getContainer()->getClient()->getOrderReferenceDetails(); $oOrderReferenceDetail = isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails) ? $oData->GetOrderReferenceDetailsResult->OrderReferenceDetails : null; if ($oOrderReferenceDetail === null || isset($oOrderReferenceDetail->Destination->PhysicalDestination) === false ) { $oUtils->redirect($sShopSecureHomeUrl.'cl=user&fnc=cleanAmazonPay', false); return; } //Creating and(or) logging user $sStatus = (string)$oOrderReferenceDetail->OrderReferenceStatus->State; if ($sStatus === 'Draft') { //Manage primary user data $oAmazonData = $oOrderReferenceDetail->Destination->PhysicalDestination; $this->_managePrimaryUserData($oAmazonData); //Recalculate basket to get shipping price for created user $this->_getContainer()->getSession()->getBasket()->onUpdate(); //Redirect with registered user or new shipping address to payment page $oUtils->redirect($sShopSecureHomeUrl.'cl=payment', false); return; } $oUtils->redirect($sShopSecureHomeUrl.'cl=user&fnc=cleanAmazonPay', false); }
php
public function setPrimaryAmazonUserData() { $oUtils = $this->_getContainer()->getUtils(); $sShopSecureHomeUrl = $this->_getContainer()->getConfig()->getShopSecureHomeUrl(); //Get primary user data from Amazon $oData = $this->_getContainer()->getClient()->getOrderReferenceDetails(); $oOrderReferenceDetail = isset($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails) ? $oData->GetOrderReferenceDetailsResult->OrderReferenceDetails : null; if ($oOrderReferenceDetail === null || isset($oOrderReferenceDetail->Destination->PhysicalDestination) === false ) { $oUtils->redirect($sShopSecureHomeUrl.'cl=user&fnc=cleanAmazonPay', false); return; } //Creating and(or) logging user $sStatus = (string)$oOrderReferenceDetail->OrderReferenceStatus->State; if ($sStatus === 'Draft') { //Manage primary user data $oAmazonData = $oOrderReferenceDetail->Destination->PhysicalDestination; $this->_managePrimaryUserData($oAmazonData); //Recalculate basket to get shipping price for created user $this->_getContainer()->getSession()->getBasket()->onUpdate(); //Redirect with registered user or new shipping address to payment page $oUtils->redirect($sShopSecureHomeUrl.'cl=payment', false); return; } $oUtils->redirect($sShopSecureHomeUrl.'cl=user&fnc=cleanAmazonPay', false); }
[ "public", "function", "setPrimaryAmazonUserData", "(", ")", "{", "$", "oUtils", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getUtils", "(", ")", ";", "$", "sShopSecureHomeUrl", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConf...
Get's primary user details and logins user if one is not logged in Add's new address if user is logged in. @throws Exception
[ "Get", "s", "primary", "user", "details", "and", "logins", "user", "if", "one", "is", "not", "logged", "in", "Add", "s", "new", "address", "if", "user", "is", "logged", "in", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_payment.php#L181-L215
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_payment.php
bestitAmazonPay4Oxid_payment.validatePayment
public function validatePayment() { $oSession = $this->_getContainer()->getSession(); $oConfig = $this->_getContainer()->getConfig(); //Don't do anything with order remark if we not under Amazon Pay if ((string)$oSession->getVariable('amazonOrderReferenceId') === '' || (string)$oConfig->getRequestParameter('paymentid') !== 'bestitamazon' ) { return parent::validatePayment(); } // order remark $sOrderRemark = (string)$oConfig->getRequestParameter('order_remark', true); if ($sOrderRemark !== '') { $oSession->setVariable('ordrem', $sOrderRemark); } else { $oSession->deleteVariable('ordrem'); } return parent::validatePayment(); }
php
public function validatePayment() { $oSession = $this->_getContainer()->getSession(); $oConfig = $this->_getContainer()->getConfig(); //Don't do anything with order remark if we not under Amazon Pay if ((string)$oSession->getVariable('amazonOrderReferenceId') === '' || (string)$oConfig->getRequestParameter('paymentid') !== 'bestitamazon' ) { return parent::validatePayment(); } // order remark $sOrderRemark = (string)$oConfig->getRequestParameter('order_remark', true); if ($sOrderRemark !== '') { $oSession->setVariable('ordrem', $sOrderRemark); } else { $oSession->deleteVariable('ordrem'); } return parent::validatePayment(); }
[ "public", "function", "validatePayment", "(", ")", "{", "$", "oSession", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getSession", "(", ")", ";", "$", "oConfig", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")...
Set's order remark to session @return mixed @throws oxSystemComponentException
[ "Set", "s", "order", "remark", "to", "session" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_payment.php#L223-L245
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._addToMessages
protected function _addToMessages($sText) { $aViewData = $this->getViewData(); $aViewData['sMessage'] = isset($aViewData['sMessage']) ? $aViewData['sMessage'].$sText : $sText; $this->setViewData($aViewData); }
php
protected function _addToMessages($sText) { $aViewData = $this->getViewData(); $aViewData['sMessage'] = isset($aViewData['sMessage']) ? $aViewData['sMessage'].$sText : $sText; $this->setViewData($aViewData); }
[ "protected", "function", "_addToMessages", "(", "$", "sText", ")", "{", "$", "aViewData", "=", "$", "this", "->", "getViewData", "(", ")", ";", "$", "aViewData", "[", "'sMessage'", "]", "=", "isset", "(", "$", "aViewData", "[", "'sMessage'", "]", ")", ...
Adds the text to the message. @param $sText
[ "Adds", "the", "text", "to", "the", "message", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L40-L45
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._processOrderStates
protected function _processOrderStates($sQuery, $sClientFunction) { $aResponses = array(); $aResult = $this->_getContainer()->getDatabase()->getAll($sQuery); foreach ($aResult as $aRow) { $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($aRow['OXID'])) { $oData = $this->_getContainer()->getClient()->{$sClientFunction}($oOrder); $aResponses[$aRow['OXORDERNR']] = $oData; } } return $aResponses; }
php
protected function _processOrderStates($sQuery, $sClientFunction) { $aResponses = array(); $aResult = $this->_getContainer()->getDatabase()->getAll($sQuery); foreach ($aResult as $aRow) { $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($aRow['OXID'])) { $oData = $this->_getContainer()->getClient()->{$sClientFunction}($oOrder); $aResponses[$aRow['OXORDERNR']] = $oData; } } return $aResponses; }
[ "protected", "function", "_processOrderStates", "(", "$", "sQuery", ",", "$", "sClientFunction", ")", "{", "$", "aResponses", "=", "array", "(", ")", ";", "$", "aResult", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getDatabase", "(", ")", "...
Processes the order states. @param string $sQuery @param string $sClientFunction @return array @throws oxSystemComponentException @throws oxConnectionException
[ "Processes", "the", "order", "states", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L57-L72
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._updateAuthorizedOrders
protected function _updateAuthorizedOrders() { $aProcessed = $this->_processOrderStates( "SELECT OXID, OXORDERNR FROM oxorder WHERE BESTITAMAZONORDERREFERENCEID != '' AND BESTITAMAZONAUTHORIZATIONID != '' AND OXTRANSSTATUS = 'AMZ-Authorize-Pending'", 'getAuthorizationDetails' ); foreach ($aProcessed as $sOrderNumber => $oData) { if (isset($oData->GetAuthorizationDetailsResult->AuthorizationDetails->AuthorizationStatus->State)) { $sState = $oData->GetAuthorizationDetailsResult ->AuthorizationDetails ->AuthorizationStatus->State; $this->_addToMessages("Authorized Order #{$sOrderNumber} - Status updated to: {$sState}<br/>"); } } }
php
protected function _updateAuthorizedOrders() { $aProcessed = $this->_processOrderStates( "SELECT OXID, OXORDERNR FROM oxorder WHERE BESTITAMAZONORDERREFERENCEID != '' AND BESTITAMAZONAUTHORIZATIONID != '' AND OXTRANSSTATUS = 'AMZ-Authorize-Pending'", 'getAuthorizationDetails' ); foreach ($aProcessed as $sOrderNumber => $oData) { if (isset($oData->GetAuthorizationDetailsResult->AuthorizationDetails->AuthorizationStatus->State)) { $sState = $oData->GetAuthorizationDetailsResult ->AuthorizationDetails ->AuthorizationStatus->State; $this->_addToMessages("Authorized Order #{$sOrderNumber} - Status updated to: {$sState}<br/>"); } } }
[ "protected", "function", "_updateAuthorizedOrders", "(", ")", "{", "$", "aProcessed", "=", "$", "this", "->", "_processOrderStates", "(", "\"SELECT OXID, OXORDERNR FROM oxorder\n WHERE BESTITAMAZONORDERREFERENCEID != ''\n AND BESTITAMAZONAUTHORIZATIONID != ''\n ...
Authorize unauthorized orders or orders with pending status @throws oxSystemComponentException @throws oxConnectionException
[ "Authorize", "unauthorized", "orders", "or", "orders", "with", "pending", "status" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L79-L97
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._captureOrders
protected function _captureOrders() { $sSQLAddShippedCase = ''; //Capture orders if in module settings was set to capture just shipped orders if ((string)$this->_getContainer()->getConfig()->getConfigParam('sAmazonCapture') === 'SHIPPED') { $sSQLAddShippedCase = ' AND OXSENDDATE > 0'; } $aProcessed = $this->_processOrderStates( "SELECT OXID, OXORDERNR FROM oxorder WHERE BESTITAMAZONAUTHORIZATIONID != '' AND OXTRANSSTATUS = 'AMZ-Authorize-Open' {$sSQLAddShippedCase}", 'capture' ); foreach ($aProcessed as $sOrderNumber => $oData) { if (isset($oData->CaptureResult->CaptureDetails->CaptureStatus->State)) { $sState = $oData->CaptureResult->CaptureDetails->CaptureStatus->State; $this->_addToMessages("Capture Order #{$sOrderNumber} - Status updated to: {$sState}<br/>"); } } }
php
protected function _captureOrders() { $sSQLAddShippedCase = ''; //Capture orders if in module settings was set to capture just shipped orders if ((string)$this->_getContainer()->getConfig()->getConfigParam('sAmazonCapture') === 'SHIPPED') { $sSQLAddShippedCase = ' AND OXSENDDATE > 0'; } $aProcessed = $this->_processOrderStates( "SELECT OXID, OXORDERNR FROM oxorder WHERE BESTITAMAZONAUTHORIZATIONID != '' AND OXTRANSSTATUS = 'AMZ-Authorize-Open' {$sSQLAddShippedCase}", 'capture' ); foreach ($aProcessed as $sOrderNumber => $oData) { if (isset($oData->CaptureResult->CaptureDetails->CaptureStatus->State)) { $sState = $oData->CaptureResult->CaptureDetails->CaptureStatus->State; $this->_addToMessages("Capture Order #{$sOrderNumber} - Status updated to: {$sState}<br/>"); } } }
[ "protected", "function", "_captureOrders", "(", ")", "{", "$", "sSQLAddShippedCase", "=", "''", ";", "//Capture orders if in module settings was set to capture just shipped orders", "if", "(", "(", "string", ")", "$", "this", "->", "_getContainer", "(", ")", "->", "ge...
Capture orders with Authorize status=open @throws oxSystemComponentException @throws oxConnectionException
[ "Capture", "orders", "with", "Authorize", "status", "=", "open" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L154-L177
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._updateRefundDetails
protected function _updateRefundDetails() { $sQuery = "SELECT BESTITAMAZONREFUNDID FROM bestitamazonrefunds WHERE STATE = 'Pending' AND BESTITAMAZONREFUNDID != ''"; $aResult = $this->_getContainer()->getDatabase()->getAll($sQuery); foreach ($aResult as $aRow) { $oData = $this->_getContainer()->getClient()->getRefundDetails($aRow['BESTITAMAZONREFUNDID']); if (isset($oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State)) { $this->_addToMessages( "Refund ID: {$oData->GetRefundDetailsResult->RefundDetails->RefundReferenceId} - " ."Status: {$oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State}<br/>" ); } } }
php
protected function _updateRefundDetails() { $sQuery = "SELECT BESTITAMAZONREFUNDID FROM bestitamazonrefunds WHERE STATE = 'Pending' AND BESTITAMAZONREFUNDID != ''"; $aResult = $this->_getContainer()->getDatabase()->getAll($sQuery); foreach ($aResult as $aRow) { $oData = $this->_getContainer()->getClient()->getRefundDetails($aRow['BESTITAMAZONREFUNDID']); if (isset($oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State)) { $this->_addToMessages( "Refund ID: {$oData->GetRefundDetailsResult->RefundDetails->RefundReferenceId} - " ."Status: {$oData->GetRefundDetailsResult->RefundDetails->RefundStatus->State}<br/>" ); } } }
[ "protected", "function", "_updateRefundDetails", "(", ")", "{", "$", "sQuery", "=", "\"SELECT BESTITAMAZONREFUNDID\n FROM bestitamazonrefunds\n WHERE STATE = 'Pending'\n AND BESTITAMAZONREFUNDID != ''\"", ";", "$", "aResult", "=", "$", "this", "->",...
Check and update refund details for made refunds @throws Exception
[ "Check", "and", "update", "refund", "details", "for", "made", "refunds" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L183-L202
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron.render
public function render() { //Increase execution time for the script to run without timeouts set_time_limit(3600); //If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders if ((bool)$this->_getContainer()->getConfig()->getConfigParam('blAmazonERP') === true) { $this->setViewData(array('sError' => 'ERP mode is ON (Module settings)')); } elseif ((string)$this->_getContainer()->getConfig()->getConfigParam('sAmazonAuthorize') !== 'CRON') { $this->setViewData(array('sError' => 'Trigger Authorise via Cronjob mode is turned Off (Module settings)')); } else { //Authorize unauthorized or Authorize-Pending orders $this->_updateAuthorizedOrders(); //Check for declined orders $this->_updateDeclinedOrders(); //Check for suspended orders $this->_updateSuspendedOrders(); //Capture handling $this->_captureOrders(); //Check refund stats $this->_updateRefundDetails(); //Check for order which can be closed $this->_closeOrders(); $this->_addToMessages('Done'); } return $this->_sThisTemplate; }
php
public function render() { //Increase execution time for the script to run without timeouts set_time_limit(3600); //If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders if ((bool)$this->_getContainer()->getConfig()->getConfigParam('blAmazonERP') === true) { $this->setViewData(array('sError' => 'ERP mode is ON (Module settings)')); } elseif ((string)$this->_getContainer()->getConfig()->getConfigParam('sAmazonAuthorize') !== 'CRON') { $this->setViewData(array('sError' => 'Trigger Authorise via Cronjob mode is turned Off (Module settings)')); } else { //Authorize unauthorized or Authorize-Pending orders $this->_updateAuthorizedOrders(); //Check for declined orders $this->_updateDeclinedOrders(); //Check for suspended orders $this->_updateSuspendedOrders(); //Capture handling $this->_captureOrders(); //Check refund stats $this->_updateRefundDetails(); //Check for order which can be closed $this->_closeOrders(); $this->_addToMessages('Done'); } return $this->_sThisTemplate; }
[ "public", "function", "render", "(", ")", "{", "//Increase execution time for the script to run without timeouts", "set_time_limit", "(", "3600", ")", ";", "//If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders", "if", "(", "(", "bool", ")", "$", "th...
The render function @throws Exception @throws oxSystemComponentException
[ "The", "render", "function" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L231-L264
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._getOperationName
protected function _getOperationName() { $operation = lcfirst($this->_getContainer()->getConfig()->getRequestParameter('operation')); if (method_exists($this->_getContainer()->getClient(), $operation)) { return $operation; } $this->setViewData(array('sError' => "Operation '{$operation}' does not exist")); return false; }
php
protected function _getOperationName() { $operation = lcfirst($this->_getContainer()->getConfig()->getRequestParameter('operation')); if (method_exists($this->_getContainer()->getClient(), $operation)) { return $operation; } $this->setViewData(array('sError' => "Operation '{$operation}' does not exist")); return false; }
[ "protected", "function", "_getOperationName", "(", ")", "{", "$", "operation", "=", "lcfirst", "(", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getRequestParameter", "(", "'operation'", ")", ")", ";", "if", "(", "metho...
Method returns Operation name @return mixed @throws oxSystemComponentException
[ "Method", "returns", "Operation", "name" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L272-L282
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._getOrder
protected function _getOrder() { $sOrderId = $this->_getContainer()->getConfig()->getRequestParameter('oxid'); if ($sOrderId !== null) { /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($sOrderId) === true) { return $oOrder; } } return null; }
php
protected function _getOrder() { $sOrderId = $this->_getContainer()->getConfig()->getRequestParameter('oxid'); if ($sOrderId !== null) { /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($sOrderId) === true) { return $oOrder; } } return null; }
[ "protected", "function", "_getOrder", "(", ")", "{", "$", "sOrderId", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getRequestParameter", "(", "'oxid'", ")", ";", "if", "(", "$", "sOrderId", "!==", "null", ")", ...
Method returns Order object @return null|oxOrder @throws oxSystemComponentException
[ "Method", "returns", "Order", "object" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L290-L304
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron._getParams
protected function _getParams() { $aResult = array(); $aParams = (array)$this->_getContainer()->getConfig()->getRequestParameter('aParams'); foreach ($aParams as $sKey => $sValue) { $aResult[html_entity_decode($sKey)] = html_entity_decode($sValue); } return $aResult; }
php
protected function _getParams() { $aResult = array(); $aParams = (array)$this->_getContainer()->getConfig()->getRequestParameter('aParams'); foreach ($aParams as $sKey => $sValue) { $aResult[html_entity_decode($sKey)] = html_entity_decode($sValue); } return $aResult; }
[ "protected", "function", "_getParams", "(", ")", "{", "$", "aResult", "=", "array", "(", ")", ";", "$", "aParams", "=", "(", "array", ")", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getRequestParameter", "(", "'aP...
Method returns Parameters from GET aParam array @return array @throws oxSystemComponentException
[ "Method", "returns", "Parameters", "from", "GET", "aParam", "array" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L312-L322
train
bestit/amazon-pay-oxid
application/controllers/bestitamazoncron.php
bestitAmazonCron.amazonCall
public function amazonCall() { $sOperation = $this->_getOperationName(); if ($sOperation !== false) { $oResult = $this->_getContainer()->getClient()->{$sOperation}( $this->_getOrder(), $this->_getParams() ); $this->_addToMessages('<pre>'.print_r($oResult, true).'</pre>'); return; } $this->setViewData(array( 'sError' => 'Please specify operation you want to call (&operation=) ' .'and use &oxid= parameter to specify order ID or use &aParams[\'key\']=value' )); }
php
public function amazonCall() { $sOperation = $this->_getOperationName(); if ($sOperation !== false) { $oResult = $this->_getContainer()->getClient()->{$sOperation}( $this->_getOrder(), $this->_getParams() ); $this->_addToMessages('<pre>'.print_r($oResult, true).'</pre>'); return; } $this->setViewData(array( 'sError' => 'Please specify operation you want to call (&operation=) ' .'and use &oxid= parameter to specify order ID or use &aParams[\'key\']=value' )); }
[ "public", "function", "amazonCall", "(", ")", "{", "$", "sOperation", "=", "$", "this", "->", "_getOperationName", "(", ")", ";", "if", "(", "$", "sOperation", "!==", "false", ")", "{", "$", "oResult", "=", "$", "this", "->", "_getContainer", "(", ")",...
Makes request to Amazon methods amazonCall method Calling examples: index.php?cl=bestitamazoncron&fnc=amazonCall&operation=Authorize&oxid=87feca21ce31c34f0d3dceb8197a2375 index.php?cl=bestitamazoncron&fnc=amazonCall&operation=Authorize&aParams[AmazonOrderReferenceId]=51fd6a7381e7a0220b0f166fe331e420&aParams[AmazonAuthorizationId]=S02-8774768-9373076-A060413 @throws oxSystemComponentException
[ "Makes", "request", "to", "Amazon", "methods" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazoncron.php#L333-L351
train
bestit/amazon-pay-oxid
application/controllers/bestitamazonipn.php
bestitAmazonIpn.render
public function render() { //If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders if ($this->_getContainer()->getConfig()->getConfigParam('blAmazonERP') === true) { return $this->_processError('IPN response handling disabled - ERP mode is ON (Module settings)'); } //Check if IPN response handling is turned ON if ($this->_getContainer()->getConfig()->getConfigParam('sAmazonAuthorize') !== 'IPN') { return $this->_processError('IPN response handling disabled (Module settings)'); } //Get SNS message $sBody = file_get_contents($this->_sInput); if ($sBody === '') { return $this->_processError('SNS message empty or Error while reading SNS message occurred'); } //Perform IPN action if ($this->_getContainer()->getIpnHandler()->processIPNAction($sBody) !== true) { return $this->_processError('Error while handling Amazon response'); } return $this->_sThisTemplate; }
php
public function render() { //If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders if ($this->_getContainer()->getConfig()->getConfigParam('blAmazonERP') === true) { return $this->_processError('IPN response handling disabled - ERP mode is ON (Module settings)'); } //Check if IPN response handling is turned ON if ($this->_getContainer()->getConfig()->getConfigParam('sAmazonAuthorize') !== 'IPN') { return $this->_processError('IPN response handling disabled (Module settings)'); } //Get SNS message $sBody = file_get_contents($this->_sInput); if ($sBody === '') { return $this->_processError('SNS message empty or Error while reading SNS message occurred'); } //Perform IPN action if ($this->_getContainer()->getIpnHandler()->processIPNAction($sBody) !== true) { return $this->_processError('Error while handling Amazon response'); } return $this->_sThisTemplate; }
[ "public", "function", "render", "(", ")", "{", "//If ERP mode is enabled do nothing, if IPN or CRON authorize unauthorized orders", "if", "(", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getConfigParam", "(", "'blAmazonERP'", ")", ...
The controller entry point. @return string @throws Exception @throws oxConnectionException @throws oxSystemComponentException
[ "The", "controller", "entry", "point", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/bestitamazonipn.php#L70-L95
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxid.php
bestitAmazonPay4Oxid.getIsSelectedCurrencyAvailable
public function getIsSelectedCurrencyAvailable() { $oConfig = $this->getConfig(); $blEnableMultiCurrency = (bool)$oConfig->getConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency'); if ($blEnableMultiCurrency === true) { return true; } if ($this->_isSelectedCurrencyAvailable === null) { $this->_isSelectedCurrencyAvailable = true; $aMap = array( 'DE' => 'EUR', 'UK' => 'GBP', 'US' => 'USD' ); $sLocale = (string)$oConfig->getConfigParam('sAmazonLocale'); $sCurrency = (string)$this->getSession()->getBasket()->getBasketCurrency()->name; //If Locale is DE and currency is not EURO don't allow Amazon checkout process if (isset($aMap[$sLocale]) && $aMap[$sLocale] !== $sCurrency) { $this->_isSelectedCurrencyAvailable = false; } } return $this->_isSelectedCurrencyAvailable; }
php
public function getIsSelectedCurrencyAvailable() { $oConfig = $this->getConfig(); $blEnableMultiCurrency = (bool)$oConfig->getConfigParam('blBestitAmazonPay4OxidEnableMultiCurrency'); if ($blEnableMultiCurrency === true) { return true; } if ($this->_isSelectedCurrencyAvailable === null) { $this->_isSelectedCurrencyAvailable = true; $aMap = array( 'DE' => 'EUR', 'UK' => 'GBP', 'US' => 'USD' ); $sLocale = (string)$oConfig->getConfigParam('sAmazonLocale'); $sCurrency = (string)$this->getSession()->getBasket()->getBasketCurrency()->name; //If Locale is DE and currency is not EURO don't allow Amazon checkout process if (isset($aMap[$sLocale]) && $aMap[$sLocale] !== $sCurrency) { $this->_isSelectedCurrencyAvailable = false; } } return $this->_isSelectedCurrencyAvailable; }
[ "public", "function", "getIsSelectedCurrencyAvailable", "(", ")", "{", "$", "oConfig", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "blEnableMultiCurrency", "=", "(", "bool", ")", "$", "oConfig", "->", "getConfigParam", "(", "'blBestitAmazonPay4OxidE...
Returns true if currency meets locale @return boolean
[ "Returns", "true", "if", "currency", "meets", "locale" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxid.php#L25-L52
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxid.php
bestitAmazonPay4Oxid.isActive
public function isActive() { //If check was made once return result if ($this->_blActive !== null) { return $this->_blActive; } //Check if payment method itself is active $sTable = getViewName('oxpayments'); $sSql = "SELECT OXACTIVE FROM {$sTable} WHERE OXID = 'bestitamazon'"; $blPaymentActive = (bool)$this->getDatabase()->getOne($sSql); if ($blPaymentActive === false) { return $this->_blActive = false; } //Check if payment has at least one shipping method assigned $sO2PTable = getViewName('oxobject2payment'); $sDelSetTable = getViewName('oxdeliveryset'); $sSql = "SELECT OXOBJECTID FROM {$sO2PTable} AS o2p RIGHT JOIN {$sDelSetTable} AS d ON (o2p.OXOBJECTID = d.OXID AND d.OXACTIVE = 1) WHERE OXPAYMENTID = 'bestitamazon' AND OXTYPE='oxdelset' LIMIT 1"; $sShippingId = (string)$this->getDatabase()->getOne($sSql); if ($sShippingId === '') { return $this->_blActive = false; } //Check if shipping method has at least one shipping cost assigned $sTable = getViewName('oxdel2delset'); $sSql = "SELECT OXID FROM {$sTable} WHERE OXDELSETID = {$this->getDatabase()->quote($sShippingId)} LIMIT 1"; $sShippingCostRelated = (string)$this->getDatabase()->getOne($sSql); if ($sShippingCostRelated === '') { return $this->_blActive = false; } //Check if selected currency is available for selected Amazon locale if ($this->getIsSelectedCurrencyAvailable() === false) { return $this->_blActive = false; } $oConfig = $this->getConfig(); //If Amazon SellerId is empty if ((string)$oConfig->getConfigParam('sAmazonSellerId') === '') { return $this->_blActive = false; } //If basket items price = 0 if ((string)$oConfig->getRequestParameter('cl') !== 'details' && (int)$this->getSession()->getBasket()->getPrice()->getBruttoPrice() === 0 ) { return $this->_blActive = false; } return $this->_blActive = true; }
php
public function isActive() { //If check was made once return result if ($this->_blActive !== null) { return $this->_blActive; } //Check if payment method itself is active $sTable = getViewName('oxpayments'); $sSql = "SELECT OXACTIVE FROM {$sTable} WHERE OXID = 'bestitamazon'"; $blPaymentActive = (bool)$this->getDatabase()->getOne($sSql); if ($blPaymentActive === false) { return $this->_blActive = false; } //Check if payment has at least one shipping method assigned $sO2PTable = getViewName('oxobject2payment'); $sDelSetTable = getViewName('oxdeliveryset'); $sSql = "SELECT OXOBJECTID FROM {$sO2PTable} AS o2p RIGHT JOIN {$sDelSetTable} AS d ON (o2p.OXOBJECTID = d.OXID AND d.OXACTIVE = 1) WHERE OXPAYMENTID = 'bestitamazon' AND OXTYPE='oxdelset' LIMIT 1"; $sShippingId = (string)$this->getDatabase()->getOne($sSql); if ($sShippingId === '') { return $this->_blActive = false; } //Check if shipping method has at least one shipping cost assigned $sTable = getViewName('oxdel2delset'); $sSql = "SELECT OXID FROM {$sTable} WHERE OXDELSETID = {$this->getDatabase()->quote($sShippingId)} LIMIT 1"; $sShippingCostRelated = (string)$this->getDatabase()->getOne($sSql); if ($sShippingCostRelated === '') { return $this->_blActive = false; } //Check if selected currency is available for selected Amazon locale if ($this->getIsSelectedCurrencyAvailable() === false) { return $this->_blActive = false; } $oConfig = $this->getConfig(); //If Amazon SellerId is empty if ((string)$oConfig->getConfigParam('sAmazonSellerId') === '') { return $this->_blActive = false; } //If basket items price = 0 if ((string)$oConfig->getRequestParameter('cl') !== 'details' && (int)$this->getSession()->getBasket()->getPrice()->getBruttoPrice() === 0 ) { return $this->_blActive = false; } return $this->_blActive = true; }
[ "public", "function", "isActive", "(", ")", "{", "//If check was made once return result", "if", "(", "$", "this", "->", "_blActive", "!==", "null", ")", "{", "return", "$", "this", "->", "_blActive", ";", "}", "//Check if payment method itself is active", "$", "s...
Method checks if Amazon Pay is active and can be used @return bool @throws oxConnectionException
[ "Method", "checks", "if", "Amazon", "Pay", "is", "active", "and", "can", "be", "used" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxid.php#L60-L127
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxid.php
bestitAmazonPay4Oxid.cleanUpUnusedAccounts
public function cleanUpUnusedAccounts() { $sTable = getViewName('oxuser'); $sSql = "SELECT oxid, oxusername FROM {$sTable} WHERE oxusername LIKE '%-%-%@amazon.com' AND oxcreate < (NOW() - INTERVAL 1440 MINUTE)"; $aData = $this->getDatabase()->getAll($sSql); foreach ($aData as $aUser) { //Delete user from OXID $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); if ($oUser->load($aUser['oxid'])) { $oUser->delete(); } } }
php
public function cleanUpUnusedAccounts() { $sTable = getViewName('oxuser'); $sSql = "SELECT oxid, oxusername FROM {$sTable} WHERE oxusername LIKE '%-%-%@amazon.com' AND oxcreate < (NOW() - INTERVAL 1440 MINUTE)"; $aData = $this->getDatabase()->getAll($sSql); foreach ($aData as $aUser) { //Delete user from OXID $oUser = $this->getObjectFactory()->createOxidObject('oxUser'); if ($oUser->load($aUser['oxid'])) { $oUser->delete(); } } }
[ "public", "function", "cleanUpUnusedAccounts", "(", ")", "{", "$", "sTable", "=", "getViewName", "(", "'oxuser'", ")", ";", "$", "sSql", "=", "\"SELECT oxid, oxusername\n FROM {$sTable}\n WHERE oxusername LIKE '%-%-%@amazon.com'\n AND oxcreate < (...
Deletes previously created user accounts which was not used @throws oxConnectionException @throws oxSystemComponentException
[ "Deletes", "previously", "created", "user", "accounts", "which", "was", "not", "used" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxid.php#L161-L179
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder._manageFullUserData
protected function _manageFullUserData($oUser, $oAmazonData) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oConfig = $oContainer->getConfig(); //Parse data from Amazon for OXID $aParsedData = $oContainer->getAddressUtil()->parseAmazonAddress( $oAmazonData->Destination->PhysicalDestination ); $aDefaultMap = array( 'oxcompany' => $aParsedData['CompanyName'], 'oxfname' => $aParsedData['FirstName'], 'oxlname' => $aParsedData['LastName'], 'oxcity' => $aParsedData['City'], 'oxstateid' => $aParsedData['StateOrRegion'], 'oxcountryid' => $aParsedData['CountryId'], 'oxzip' => $aParsedData['PostalCode'], 'oxfon' => $aParsedData['Phone'], 'oxstreet' => $aParsedData['Street'], 'oxstreetnr' => $aParsedData['StreetNr'], 'oxaddinfo' => $aParsedData['AddInfo'] ); //Getting Email $sEmail = $oAmazonData->Buyer->Email; // If we find user account in OXID with same email that we got from Amazon then add new shipping address $oDatabase = $oContainer->getDatabase(); $sQuery = "SELECT OXID FROM oxuser WHERE OXUSERNAME = {$oDatabase->quote($sEmail)} AND OXSHOPID = {$oDatabase->quote($oConfig->getShopId())}"; $sUserWithSuchEmailOxid = (string)$oDatabase->getOne($sQuery); if ($sUserWithSuchEmailOxid !== '') { //Load existing user from oxid $oUser->load($sUserWithSuchEmailOxid); /** @var oxAddress $oDelAddress */ $oDelAddress = $oContainer->getObjectFactory()->createOxidObject('oxAddress'); //Maybe we have already shipping address added for this user ? If yes then use it /** * @var oxAddress[] $aUserAddresses */ $aUserAddresses = $oUser->getUserAddresses(); foreach ($aUserAddresses as $oAddress) { if ((string)$oAddress->getFieldData('oxfname') === (string)$aParsedData['FirstName'] && (string)$oAddress->getFieldData('oxlname') === (string)$aParsedData['LastName'] && (string)$oAddress->getFieldData('oxstreet') === (string)$aParsedData['Street'] && (string)$oAddress->getFieldData('oxstreetnr') === (string)$aParsedData['StreetNr'] ) { $oDelAddress->load($oAddress->getId()); break; } } $oDelAddress->assign(array_merge($aDefaultMap, array('oxuserid' => $sUserWithSuchEmailOxid))); $sDeliveryAddressId = $oDelAddress->save(); $oSession->setVariable('blshowshipaddress', 1); $oSession->setVariable('deladrid', $sDeliveryAddressId); } else { // If the user is new and not found in OXID update data from Amazon $oUser->assign(array_merge($aDefaultMap, array('oxusername' => $sEmail))); $oUser->save(); $sDeliveryAddressId = (string) $oSession->getVariable('deladrid'); // Set Amazon address as shipping if ($sDeliveryAddressId !== '') { /** @var oxAddress $oDelAddress */ $oDelAddress = $oContainer->getObjectFactory()->createOxidObject('oxAddress'); $oDelAddress->load($sDeliveryAddressId); $oDelAddress->assign($aDefaultMap); $oDelAddress->save(); } } return $oUser; }
php
protected function _manageFullUserData($oUser, $oAmazonData) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oConfig = $oContainer->getConfig(); //Parse data from Amazon for OXID $aParsedData = $oContainer->getAddressUtil()->parseAmazonAddress( $oAmazonData->Destination->PhysicalDestination ); $aDefaultMap = array( 'oxcompany' => $aParsedData['CompanyName'], 'oxfname' => $aParsedData['FirstName'], 'oxlname' => $aParsedData['LastName'], 'oxcity' => $aParsedData['City'], 'oxstateid' => $aParsedData['StateOrRegion'], 'oxcountryid' => $aParsedData['CountryId'], 'oxzip' => $aParsedData['PostalCode'], 'oxfon' => $aParsedData['Phone'], 'oxstreet' => $aParsedData['Street'], 'oxstreetnr' => $aParsedData['StreetNr'], 'oxaddinfo' => $aParsedData['AddInfo'] ); //Getting Email $sEmail = $oAmazonData->Buyer->Email; // If we find user account in OXID with same email that we got from Amazon then add new shipping address $oDatabase = $oContainer->getDatabase(); $sQuery = "SELECT OXID FROM oxuser WHERE OXUSERNAME = {$oDatabase->quote($sEmail)} AND OXSHOPID = {$oDatabase->quote($oConfig->getShopId())}"; $sUserWithSuchEmailOxid = (string)$oDatabase->getOne($sQuery); if ($sUserWithSuchEmailOxid !== '') { //Load existing user from oxid $oUser->load($sUserWithSuchEmailOxid); /** @var oxAddress $oDelAddress */ $oDelAddress = $oContainer->getObjectFactory()->createOxidObject('oxAddress'); //Maybe we have already shipping address added for this user ? If yes then use it /** * @var oxAddress[] $aUserAddresses */ $aUserAddresses = $oUser->getUserAddresses(); foreach ($aUserAddresses as $oAddress) { if ((string)$oAddress->getFieldData('oxfname') === (string)$aParsedData['FirstName'] && (string)$oAddress->getFieldData('oxlname') === (string)$aParsedData['LastName'] && (string)$oAddress->getFieldData('oxstreet') === (string)$aParsedData['Street'] && (string)$oAddress->getFieldData('oxstreetnr') === (string)$aParsedData['StreetNr'] ) { $oDelAddress->load($oAddress->getId()); break; } } $oDelAddress->assign(array_merge($aDefaultMap, array('oxuserid' => $sUserWithSuchEmailOxid))); $sDeliveryAddressId = $oDelAddress->save(); $oSession->setVariable('blshowshipaddress', 1); $oSession->setVariable('deladrid', $sDeliveryAddressId); } else { // If the user is new and not found in OXID update data from Amazon $oUser->assign(array_merge($aDefaultMap, array('oxusername' => $sEmail))); $oUser->save(); $sDeliveryAddressId = (string) $oSession->getVariable('deladrid'); // Set Amazon address as shipping if ($sDeliveryAddressId !== '') { /** @var oxAddress $oDelAddress */ $oDelAddress = $oContainer->getObjectFactory()->createOxidObject('oxAddress'); $oDelAddress->load($sDeliveryAddressId); $oDelAddress->assign($aDefaultMap); $oDelAddress->save(); } } return $oUser; }
[ "protected", "function", "_manageFullUserData", "(", "$", "oUser", ",", "$", "oAmazonData", ")", "{", "$", "oContainer", "=", "$", "this", "->", "_getContainer", "(", ")", ";", "$", "oSession", "=", "$", "oContainer", "->", "getSession", "(", ")", ";", "...
Manages received user data from Amazon @param oxUser $oUser Customers user object @param object $oAmazonData User data received from Amazon WS @return oxUser @throws oxConnectionException @throws oxSystemComponentException
[ "Manages", "received", "user", "data", "from", "Amazon" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L42-L127
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder._callSyncAmazonAuthorize
protected function _callSyncAmazonAuthorize($oBasket, $sAmazonOrderReferenceId, $blOptimizedFlow) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oUtils = $oContainer->getUtils(); $oConfig = $oContainer->getConfig(); //Authorize method call in Amazon $aParams = array( 'amazon_order_reference_id' => $sAmazonOrderReferenceId, 'authorization_amount' => $oBasket->getPrice()->getBruttoPrice(), 'currency_code' => $oBasket->getBasketCurrency()->name, 'authorization_reference_id' => $sAmazonOrderReferenceId.'_' .$oContainer->getUtilsDate()->getTime() ); $oData = $oContainer->getClient()->authorize(null, $aParams, true); //Error handling if (!$oData || $oData->Error) { $oUtils->redirect($oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false); return false; } $oAuthorizationStatus = $oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus; //Response handling if ((string)$oAuthorizationStatus->State === 'Declined' || (string)$oAuthorizationStatus->State === 'Closed') { //Redirect to order page to re-select the payment if ($blOptimizedFlow === true && (string)$oAuthorizationStatus->ReasonCode === 'TransactionTimedOut') { return false; } elseif ((string)$oAuthorizationStatus->ReasonCode === 'InvalidPaymentMethod') { $oSession->setVariable('blAmazonSyncChangePayment', 1); $oUtils->redirect($oConfig->getShopSecureHomeUrl().'cl=order&action=changePayment', false); return false; } //Cancel ORO in amazon and redirect $aParams['amazon_order_reference_id'] = $oSession->getVariable('amazonOrderReferenceId'); $oContainer->getClient()->cancelOrderReference(null, $aParams); $oUtils->redirect( $oConfig->getShopSecureHomeUrl() .'cl=user&fnc=cleanAmazonPay&error=BESTITAMAZONPAY_PAYMENT_DECLINED_OR_REJECTED', false ); return false; } //Open Response handling if ((string)$oAuthorizationStatus->State === 'Open') { //Set response into session for later saving into order info $oSession->setVariable( 'sAmazonSyncResponseState', (string)$oAuthorizationStatus->State ); $oSession->setVariable( 'sAmazonSyncResponseAuthorizationId', (string)$oData->AuthorizeResult->AuthorizationDetails->AmazonAuthorizationId ); } else { //Unexpected behaviour $oUtils->redirect( $oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false ); return false; } return true; }
php
protected function _callSyncAmazonAuthorize($oBasket, $sAmazonOrderReferenceId, $blOptimizedFlow) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oUtils = $oContainer->getUtils(); $oConfig = $oContainer->getConfig(); //Authorize method call in Amazon $aParams = array( 'amazon_order_reference_id' => $sAmazonOrderReferenceId, 'authorization_amount' => $oBasket->getPrice()->getBruttoPrice(), 'currency_code' => $oBasket->getBasketCurrency()->name, 'authorization_reference_id' => $sAmazonOrderReferenceId.'_' .$oContainer->getUtilsDate()->getTime() ); $oData = $oContainer->getClient()->authorize(null, $aParams, true); //Error handling if (!$oData || $oData->Error) { $oUtils->redirect($oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false); return false; } $oAuthorizationStatus = $oData->AuthorizeResult->AuthorizationDetails->AuthorizationStatus; //Response handling if ((string)$oAuthorizationStatus->State === 'Declined' || (string)$oAuthorizationStatus->State === 'Closed') { //Redirect to order page to re-select the payment if ($blOptimizedFlow === true && (string)$oAuthorizationStatus->ReasonCode === 'TransactionTimedOut') { return false; } elseif ((string)$oAuthorizationStatus->ReasonCode === 'InvalidPaymentMethod') { $oSession->setVariable('blAmazonSyncChangePayment', 1); $oUtils->redirect($oConfig->getShopSecureHomeUrl().'cl=order&action=changePayment', false); return false; } //Cancel ORO in amazon and redirect $aParams['amazon_order_reference_id'] = $oSession->getVariable('amazonOrderReferenceId'); $oContainer->getClient()->cancelOrderReference(null, $aParams); $oUtils->redirect( $oConfig->getShopSecureHomeUrl() .'cl=user&fnc=cleanAmazonPay&error=BESTITAMAZONPAY_PAYMENT_DECLINED_OR_REJECTED', false ); return false; } //Open Response handling if ((string)$oAuthorizationStatus->State === 'Open') { //Set response into session for later saving into order info $oSession->setVariable( 'sAmazonSyncResponseState', (string)$oAuthorizationStatus->State ); $oSession->setVariable( 'sAmazonSyncResponseAuthorizationId', (string)$oData->AuthorizeResult->AuthorizationDetails->AmazonAuthorizationId ); } else { //Unexpected behaviour $oUtils->redirect( $oConfig->getShopSecureHomeUrl() . 'cl=user&fnc=cleanAmazonPay', false ); return false; } return true; }
[ "protected", "function", "_callSyncAmazonAuthorize", "(", "$", "oBasket", ",", "$", "sAmazonOrderReferenceId", ",", "$", "blOptimizedFlow", ")", "{", "$", "oContainer", "=", "$", "this", "->", "_getContainer", "(", ")", ";", "$", "oSession", "=", "$", "oContai...
Calls Authorize method in Amazon depending on settings @param Basket $oBasket @param string $sAmazonOrderReferenceId @param bool $blOptimizedFlow @return bool @throws Exception
[ "Calls", "Authorize", "method", "in", "Amazon", "depending", "on", "settings" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L139-L209
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder._performAmazonActions
protected function _performAmazonActions($blAuthorizeAsync) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oConfig = $oContainer->getConfig(); //Save Amazon reference ID to oxorder table $this->_setFieldData('bestitamazonorderreferenceid', $oSession->getVariable('amazonOrderReferenceId')); $this->save(); $oContainer->getClient()->setOrderAttributes($this); //If ERP mode is enabled do nothing just set oxorder->oxtransstatus to specified value if ((bool)$oConfig->getConfigParam('blAmazonERP') === true) { $this->_setFieldData('oxtransstatus', $oConfig->getConfigParam('sAmazonERPModeStatus')); $this->save(); return; } //If we had Sync mode enabled don't call Authorize once again if ($blAuthorizeAsync === false) { $sAmazonSyncResponseState = (string)$oSession->getVariable('sAmazonSyncResponseState'); $sAmazonSyncResponseAuthorizationId = (string)$oSession->getVariable('sAmazonSyncResponseAuthorizationId'); if ($sAmazonSyncResponseState !== '' && $sAmazonSyncResponseAuthorizationId !== '') { $this->assign(array( 'bestitamazonauthorizationid' => $sAmazonSyncResponseAuthorizationId, 'oxtransstatus' => 'AMZ-Authorize-'.$sAmazonSyncResponseState )); $this->save(); } //If Capture handling was set to "Direct Capture after Authorize" and Authorization status is Open if ((string)$oConfig->getConfigParam('sAmazonCapture') === 'DIRECT' && (string)$oSession->getVariable('sAmazonSyncResponseState') === 'Open' ) { $oContainer->getClient()->capture($this); } return; } //Call Amazon authorize (Dedicated for Async mode) $oContainer->getClient()->authorize($this); return; }
php
protected function _performAmazonActions($blAuthorizeAsync) { $oContainer = $this->_getContainer(); $oSession = $oContainer->getSession(); $oConfig = $oContainer->getConfig(); //Save Amazon reference ID to oxorder table $this->_setFieldData('bestitamazonorderreferenceid', $oSession->getVariable('amazonOrderReferenceId')); $this->save(); $oContainer->getClient()->setOrderAttributes($this); //If ERP mode is enabled do nothing just set oxorder->oxtransstatus to specified value if ((bool)$oConfig->getConfigParam('blAmazonERP') === true) { $this->_setFieldData('oxtransstatus', $oConfig->getConfigParam('sAmazonERPModeStatus')); $this->save(); return; } //If we had Sync mode enabled don't call Authorize once again if ($blAuthorizeAsync === false) { $sAmazonSyncResponseState = (string)$oSession->getVariable('sAmazonSyncResponseState'); $sAmazonSyncResponseAuthorizationId = (string)$oSession->getVariable('sAmazonSyncResponseAuthorizationId'); if ($sAmazonSyncResponseState !== '' && $sAmazonSyncResponseAuthorizationId !== '') { $this->assign(array( 'bestitamazonauthorizationid' => $sAmazonSyncResponseAuthorizationId, 'oxtransstatus' => 'AMZ-Authorize-'.$sAmazonSyncResponseState )); $this->save(); } //If Capture handling was set to "Direct Capture after Authorize" and Authorization status is Open if ((string)$oConfig->getConfigParam('sAmazonCapture') === 'DIRECT' && (string)$oSession->getVariable('sAmazonSyncResponseState') === 'Open' ) { $oContainer->getClient()->capture($this); } return; } //Call Amazon authorize (Dedicated for Async mode) $oContainer->getClient()->authorize($this); return; }
[ "protected", "function", "_performAmazonActions", "(", "$", "blAuthorizeAsync", ")", "{", "$", "oContainer", "=", "$", "this", "->", "_getContainer", "(", ")", ";", "$", "oSession", "=", "$", "oContainer", "->", "getSession", "(", ")", ";", "$", "oConfig", ...
Async Authorize call and data update @param bool $blAuthorizeAsync @throws Exception @throws oxSystemComponentException
[ "Async", "Authorize", "call", "and", "data", "update" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L291-L335
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder.finalizeOrder
public function finalizeOrder(Basket $oBasket, $oUser, $blRecalculatingOrder = false) { if ($this->_preFinalizeOrder($oBasket, $oUser, $blIsAmazonOrder, $blAuthorizeAsync) === false) { return oxOrder::ORDER_STATE_PAYMENTERROR; } //Original OXID method which creates and order $iRet = $this->_parentFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder); //If order was successfull perform some Amazon actions if ($blIsAmazonOrder === true) { //If order was successfull update order details with reference ID if ($iRet < 2) { $this->_performAmazonActions($blAuthorizeAsync); } else { $this->_getContainer()->getClient()->cancelOrderReference($this); } } return $iRet; }
php
public function finalizeOrder(Basket $oBasket, $oUser, $blRecalculatingOrder = false) { if ($this->_preFinalizeOrder($oBasket, $oUser, $blIsAmazonOrder, $blAuthorizeAsync) === false) { return oxOrder::ORDER_STATE_PAYMENTERROR; } //Original OXID method which creates and order $iRet = $this->_parentFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder); //If order was successfull perform some Amazon actions if ($blIsAmazonOrder === true) { //If order was successfull update order details with reference ID if ($iRet < 2) { $this->_performAmazonActions($blAuthorizeAsync); } else { $this->_getContainer()->getClient()->cancelOrderReference($this); } } return $iRet; }
[ "public", "function", "finalizeOrder", "(", "Basket", "$", "oBasket", ",", "$", "oUser", ",", "$", "blRecalculatingOrder", "=", "false", ")", "{", "if", "(", "$", "this", "->", "_preFinalizeOrder", "(", "$", "oBasket", ",", "$", "oUser", ",", "$", "blIsA...
Confirm Order details to Amazon if payment id is bestitamazon and amazonreferenceid exists Update user details with the full details received from amazon @param Basket $oBasket @param User $oUser @param bool|false $blRecalculatingOrder @return int @throws Exception
[ "Confirm", "Order", "details", "to", "Amazon", "if", "payment", "id", "is", "bestitamazon", "and", "amazonreferenceid", "exists", "Update", "user", "details", "with", "the", "full", "details", "received", "from", "amazon" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L360-L380
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder.validateDeliveryAddress
public function validateDeliveryAddress($oUser) { $oBasket = $this->_getContainer()->getSession()->getBasket(); if ($oBasket && (string)$oBasket->getPaymentId() === 'bestitamazon') { return 0; } else { return parent::validateDeliveryAddress($oUser); } }
php
public function validateDeliveryAddress($oUser) { $oBasket = $this->_getContainer()->getSession()->getBasket(); if ($oBasket && (string)$oBasket->getPaymentId() === 'bestitamazon') { return 0; } else { return parent::validateDeliveryAddress($oUser); } }
[ "public", "function", "validateDeliveryAddress", "(", "$", "oUser", ")", "{", "$", "oBasket", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getSession", "(", ")", "->", "getBasket", "(", ")", ";", "if", "(", "$", "oBasket", "&&", "(", "stri...
Skips delivery address validation when payment==bestitamazon @param oxUser $oUser user object @return int @throws oxSystemComponentException
[ "Skips", "delivery", "address", "validation", "when", "payment", "==", "bestitamazon" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L390-L399
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxorder.php
bestitAmazonPay4Oxid_oxOrder.getAmazonChangePaymentLink
public function getAmazonChangePaymentLink() { $oClient = $this->_getContainer()->getClient(); //Main part of the link related to selected locale in config $sLink = $oClient->getAmazonProperty('sAmazonPayChangeLink', true); //Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string $oData = $oClient->getOrderReferenceDetails($this, array(), true); //If we have language string add it to link if (!empty($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage)) { $sAmazonLanguageString = (string)$oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage; $sLink .= str_replace('-', '_', $sAmazonLanguageString); } return $sLink; }
php
public function getAmazonChangePaymentLink() { $oClient = $this->_getContainer()->getClient(); //Main part of the link related to selected locale in config $sLink = $oClient->getAmazonProperty('sAmazonPayChangeLink', true); //Send GetOrderReferenceDetails request to Amazon to get OrderLanguage string $oData = $oClient->getOrderReferenceDetails($this, array(), true); //If we have language string add it to link if (!empty($oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage)) { $sAmazonLanguageString = (string)$oData->GetOrderReferenceDetailsResult->OrderReferenceDetails->OrderLanguage; $sLink .= str_replace('-', '_', $sAmazonLanguageString); } return $sLink; }
[ "public", "function", "getAmazonChangePaymentLink", "(", ")", "{", "$", "oClient", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getClient", "(", ")", ";", "//Main part of the link related to selected locale in config", "$", "sLink", "=", "$", "oClient",...
Method returns payment method change link for Invalid payment method order @return string @throws Exception
[ "Method", "returns", "payment", "method", "change", "link", "for", "Invalid", "payment", "method", "order" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxorder.php#L407-L423
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_main.php
bestitAmazonPay4Oxid_main.refundAmazonOrder
public function refundAmazonOrder() { $oConfig = $this->_getContainer()->getConfig(); $sId = $this->getEditObjectId(); if ((int)$sId !== -1 && $sId !== null && (int)$oConfig->getRequestParameter('blAmazonConfirmRefund') === 1 ) { /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); $oOrder->load($sId); $fAmazonRefundAmount = (float)str_replace( ',', '.', $oConfig->getRequestParameter('fAmazonRefundAmount') ); if ($fAmazonRefundAmount > 0) { $this->_getContainer()->getClient()->refund($oOrder, $fAmazonRefundAmount); } else { $this->_aViewData['bestitrefunderror'] = $this->_getContainer()->getLanguage() ->translateString('BESTITAMAZONPAY_INVALID_REFUND_AMOUNT'); } } else { $this->_aViewData['bestitrefunderror'] = $this->_getContainer()->getLanguage() ->translateString('BESTITAMAZONPAY_PLEASE_CHECK_REFUND_CHECKBOX'); } }
php
public function refundAmazonOrder() { $oConfig = $this->_getContainer()->getConfig(); $sId = $this->getEditObjectId(); if ((int)$sId !== -1 && $sId !== null && (int)$oConfig->getRequestParameter('blAmazonConfirmRefund') === 1 ) { /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); $oOrder->load($sId); $fAmazonRefundAmount = (float)str_replace( ',', '.', $oConfig->getRequestParameter('fAmazonRefundAmount') ); if ($fAmazonRefundAmount > 0) { $this->_getContainer()->getClient()->refund($oOrder, $fAmazonRefundAmount); } else { $this->_aViewData['bestitrefunderror'] = $this->_getContainer()->getLanguage() ->translateString('BESTITAMAZONPAY_INVALID_REFUND_AMOUNT'); } } else { $this->_aViewData['bestitrefunderror'] = $this->_getContainer()->getLanguage() ->translateString('BESTITAMAZONPAY_PLEASE_CHECK_REFUND_CHECKBOX'); } }
[ "public", "function", "refundAmazonOrder", "(", ")", "{", "$", "oConfig", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", ";", "$", "sId", "=", "$", "this", "->", "getEditObjectId", "(", ")", ";", "if", "(", "(", "int"...
Sends refund request to Amazon @throws Exception
[ "Sends", "refund", "request", "to", "Amazon" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_main.php#L114-L142
train
bestit/amazon-pay-oxid
application/controllers/admin/bestitamazonpay4oxid_main.php
bestitAmazonPay4Oxid_main.getRefundsStatus
public function getRefundsStatus() { $sId = $this->getEditObjectId(); if ((int)$sId !== -1 && $sId !== null) { $oDb = $this->_getContainer()->getDatabase(); $sSql = "SELECT BESTITAMAZONREFUNDID FROM bestitamazonrefunds WHERE STATE = 'Pending' AND BESTITAMAZONREFUNDID != '' AND OXORDERID = {$oDb->quote($sId)}"; $aResult = $oDb->getAll($sSql); foreach ($aResult as $aRow) { $this->_getContainer()->getClient()->getRefundDetails($aRow['BESTITAMAZONREFUNDID']); } } }
php
public function getRefundsStatus() { $sId = $this->getEditObjectId(); if ((int)$sId !== -1 && $sId !== null) { $oDb = $this->_getContainer()->getDatabase(); $sSql = "SELECT BESTITAMAZONREFUNDID FROM bestitamazonrefunds WHERE STATE = 'Pending' AND BESTITAMAZONREFUNDID != '' AND OXORDERID = {$oDb->quote($sId)}"; $aResult = $oDb->getAll($sSql); foreach ($aResult as $aRow) { $this->_getContainer()->getClient()->getRefundDetails($aRow['BESTITAMAZONREFUNDID']); } } }
[ "public", "function", "getRefundsStatus", "(", ")", "{", "$", "sId", "=", "$", "this", "->", "getEditObjectId", "(", ")", ";", "if", "(", "(", "int", ")", "$", "sId", "!==", "-", "1", "&&", "$", "sId", "!==", "null", ")", "{", "$", "oDb", "=", ...
Gets refunds status for the order @throws Exception
[ "Gets", "refunds", "status", "for", "the", "order" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/controllers/admin/bestitamazonpay4oxid_main.php#L168-L187
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidbasketutil.php
bestitAmazonPay4OxidBasketUtil.setQuickCheckoutBasket
public function setQuickCheckoutBasket() { $oObjectFactory = $this->getObjectFactory(); $oSession = $this->getSession(); // Create new temp basket and copy the products to it $oCurrentBasket = $oSession->getBasket(); $oSession->setVariable(self::BESTITAMAZONPAY_TEMP_BASKET, serialize($oCurrentBasket)); //Reset current basket $oSession->setBasket($oObjectFactory->createOxidObject('oxBasket')); }
php
public function setQuickCheckoutBasket() { $oObjectFactory = $this->getObjectFactory(); $oSession = $this->getSession(); // Create new temp basket and copy the products to it $oCurrentBasket = $oSession->getBasket(); $oSession->setVariable(self::BESTITAMAZONPAY_TEMP_BASKET, serialize($oCurrentBasket)); //Reset current basket $oSession->setBasket($oObjectFactory->createOxidObject('oxBasket')); }
[ "public", "function", "setQuickCheckoutBasket", "(", ")", "{", "$", "oObjectFactory", "=", "$", "this", "->", "getObjectFactory", "(", ")", ";", "$", "oSession", "=", "$", "this", "->", "getSession", "(", ")", ";", "// Create new temp basket and copy the products ...
Stores the basket which is present before the quick checkout. @throws oxSystemComponentException
[ "Stores", "the", "basket", "which", "is", "present", "before", "the", "quick", "checkout", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidbasketutil.php#L17-L28
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidbasketutil.php
bestitAmazonPay4OxidBasketUtil._validateBasket
protected function _validateBasket($oBasket) { $aCurrentContent = $oBasket->getContents(); $iCurrLang = $this->getLanguage()->getBaseLanguage(); /** @var oxBasketItem $oContent */ foreach ($aCurrentContent as $oContent) { if ($oContent->getLanguageId() !== $iCurrLang) { $oContent->setLanguageId($iCurrLang); } } }
php
protected function _validateBasket($oBasket) { $aCurrentContent = $oBasket->getContents(); $iCurrLang = $this->getLanguage()->getBaseLanguage(); /** @var oxBasketItem $oContent */ foreach ($aCurrentContent as $oContent) { if ($oContent->getLanguageId() !== $iCurrLang) { $oContent->setLanguageId($iCurrLang); } } }
[ "protected", "function", "_validateBasket", "(", "$", "oBasket", ")", "{", "$", "aCurrentContent", "=", "$", "oBasket", "->", "getContents", "(", ")", ";", "$", "iCurrLang", "=", "$", "this", "->", "getLanguage", "(", ")", "->", "getBaseLanguage", "(", ")"...
Validates the basket. @param oxBasket $oBasket
[ "Validates", "the", "basket", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidbasketutil.php#L35-L46
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidbasketutil.php
bestitAmazonPay4OxidBasketUtil.restoreQuickCheckoutBasket
public function restoreQuickCheckoutBasket() { $oSession = $this->getSession(); $sBasket = $oSession->getVariable(self::BESTITAMAZONPAY_TEMP_BASKET); if ($sBasket !== null) { //init oxbasketitem class first #1746 $this->getObjectFactory()->createOxidObject('oxBasketItem'); $oBasket = unserialize($sBasket); $this->_validateBasket($oBasket); //Reset old basket $oSession->setBasket($oBasket); } }
php
public function restoreQuickCheckoutBasket() { $oSession = $this->getSession(); $sBasket = $oSession->getVariable(self::BESTITAMAZONPAY_TEMP_BASKET); if ($sBasket !== null) { //init oxbasketitem class first #1746 $this->getObjectFactory()->createOxidObject('oxBasketItem'); $oBasket = unserialize($sBasket); $this->_validateBasket($oBasket); //Reset old basket $oSession->setBasket($oBasket); } }
[ "public", "function", "restoreQuickCheckoutBasket", "(", ")", "{", "$", "oSession", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "sBasket", "=", "$", "oSession", "->", "getVariable", "(", "self", "::", "BESTITAMAZONPAY_TEMP_BASKET", ")", ";", "i...
Restores the basket which was present before the quick checkout. @throws oxSystemComponentException
[ "Restores", "the", "basket", "which", "was", "present", "before", "the", "quick", "checkout", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidbasketutil.php#L53-L68
train
bestit/amazon-pay-oxid
application/models/bestitamazonpay4oxidbasketutil.php
bestitAmazonPay4OxidBasketUtil.getBasketHash
public function getBasketHash($sAmazonOrderReferenceId, $oBasket) { $aBasket = array( 'amazonOrderReferenceId' => $sAmazonOrderReferenceId, 'totalSum' => $oBasket->getBruttoSum(), 'contents' => array() ); /** @var oxBasketItem $oBasketItem */ foreach ($oBasket->getContents() as $oBasketItem) { $sId = $oBasketItem->getArticle()->getId(); $aBasket['contents'][$sId] = $oBasketItem->getAmount(); } return md5(json_encode($aBasket)); }
php
public function getBasketHash($sAmazonOrderReferenceId, $oBasket) { $aBasket = array( 'amazonOrderReferenceId' => $sAmazonOrderReferenceId, 'totalSum' => $oBasket->getBruttoSum(), 'contents' => array() ); /** @var oxBasketItem $oBasketItem */ foreach ($oBasket->getContents() as $oBasketItem) { $sId = $oBasketItem->getArticle()->getId(); $aBasket['contents'][$sId] = $oBasketItem->getAmount(); } return md5(json_encode($aBasket)); }
[ "public", "function", "getBasketHash", "(", "$", "sAmazonOrderReferenceId", ",", "$", "oBasket", ")", "{", "$", "aBasket", "=", "array", "(", "'amazonOrderReferenceId'", "=>", "$", "sAmazonOrderReferenceId", ",", "'totalSum'", "=>", "$", "oBasket", "->", "getBrutt...
Generates the basket hash. @param string $sAmazonOrderReferenceId @param oxBasket|\OxidEsales\Eshop\Application\Model\Basket $oBasket @return string @throws oxArticleException @throws oxArticleInputException @throws oxNoArticleException
[ "Generates", "the", "basket", "hash", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/application/models/bestitamazonpay4oxidbasketutil.php#L82-L97
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_module_config.php
bestitAmazonPay4Oxid_module_config.saveConfVars
public function saveConfVars() { $sModuleId = $this->getEditObjectId(); if ($sModuleId === 'bestitamazonpay4oxid') { $sQuickConfig = $this->_getContainer()->getConfig()->getRequestParameter('bestitAmazonPay4OxidQuickConfig'); try { $aQuickConfig = json_decode($sQuickConfig, true); $aMap = array( 'merchant_id' => array('confstrs', 'sAmazonSellerId'), 'access_key' => array('confstrs', 'sAmazonAWSAccessKeyId'), 'secret_key' => array('confpassword', 'sAmazonSignature'), 'client_id' => array('confstrs', 'sAmazonLoginClientId') ); foreach ($aMap as $sAmazonKey => $aConfigKeys) { if (isset($aQuickConfig[$sAmazonKey]) === true) { list($sMainKey, $sSubKey) = $aConfigKeys; $_POST[$sMainKey][$sSubKey] = $aQuickConfig[$sAmazonKey]; } } } catch (\Exception $oException) { //Do nothing } } $this->_parentSaveConfVars(); }
php
public function saveConfVars() { $sModuleId = $this->getEditObjectId(); if ($sModuleId === 'bestitamazonpay4oxid') { $sQuickConfig = $this->_getContainer()->getConfig()->getRequestParameter('bestitAmazonPay4OxidQuickConfig'); try { $aQuickConfig = json_decode($sQuickConfig, true); $aMap = array( 'merchant_id' => array('confstrs', 'sAmazonSellerId'), 'access_key' => array('confstrs', 'sAmazonAWSAccessKeyId'), 'secret_key' => array('confpassword', 'sAmazonSignature'), 'client_id' => array('confstrs', 'sAmazonLoginClientId') ); foreach ($aMap as $sAmazonKey => $aConfigKeys) { if (isset($aQuickConfig[$sAmazonKey]) === true) { list($sMainKey, $sSubKey) = $aConfigKeys; $_POST[$sMainKey][$sSubKey] = $aQuickConfig[$sAmazonKey]; } } } catch (\Exception $oException) { //Do nothing } } $this->_parentSaveConfVars(); }
[ "public", "function", "saveConfVars", "(", ")", "{", "$", "sModuleId", "=", "$", "this", "->", "getEditObjectId", "(", ")", ";", "if", "(", "$", "sModuleId", "===", "'bestitamazonpay4oxid'", ")", "{", "$", "sQuickConfig", "=", "$", "this", "->", "_getConta...
Extends the save config variable function to store the amazon config vars from the provided config json object. @throws oxSystemComponentException
[ "Extends", "the", "save", "config", "variable", "function", "to", "store", "the", "amazon", "config", "vars", "from", "the", "provided", "config", "json", "object", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_module_config.php#L43-L72
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxdeliverysetlist.php
bestitAmazonPay4Oxid_oxDeliverySetList._getShippingAvailableForPayment
protected function _getShippingAvailableForPayment($sShipSet) { $oDatabase = $this->_getContainer()->getDatabase(); $sSql = "SELECT OXOBJECTID FROM oxobject2payment WHERE OXOBJECTID = {$oDatabase->quote($sShipSet)} AND OXPAYMENTID = {$oDatabase->quote('bestitamazon')} AND OXTYPE = 'oxdelset' AND OXTYPE = 'oxdelset' LIMIT 1"; $sShippingId = $oDatabase->getOne($sSql); return ($sShippingId) ? true : false; }
php
protected function _getShippingAvailableForPayment($sShipSet) { $oDatabase = $this->_getContainer()->getDatabase(); $sSql = "SELECT OXOBJECTID FROM oxobject2payment WHERE OXOBJECTID = {$oDatabase->quote($sShipSet)} AND OXPAYMENTID = {$oDatabase->quote('bestitamazon')} AND OXTYPE = 'oxdelset' AND OXTYPE = 'oxdelset' LIMIT 1"; $sShippingId = $oDatabase->getOne($sSql); return ($sShippingId) ? true : false; }
[ "protected", "function", "_getShippingAvailableForPayment", "(", "$", "sShipSet", ")", "{", "$", "oDatabase", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getDatabase", "(", ")", ";", "$", "sSql", "=", "\"SELECT OXOBJECTID\n FROM oxobject2pay...
Returns if Amazon pay is assigned available shipping ways @param string $sShipSet the string to quote @return boolean @throws oxConnectionException @throws oxSystemComponentException
[ "Returns", "if", "Amazon", "pay", "is", "assigned", "available", "shipping", "ways" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxdeliverysetlist.php#L39-L52
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxdeliverysetlist.php
bestitAmazonPay4Oxid_oxDeliverySetList._processResult
protected function _processResult($aResult, $oUser, $oBasket) { $oConfig = $this->_getContainer()->getConfig(); $sClass = $oConfig->getRequestParameter('cl'); $sAmazonOrderReferenceId = $this->_getContainer()->getSession()->getVariable('amazonOrderReferenceId'); //If Amazon Pay cannot be selected remove it from payments list if ($sClass === 'payment') { if ($this->_getContainer()->getModule()->isActive() !== true) { unset($aResult[2]['bestitamazon']); return $aResult; } //If Amazon pay was selected with the button before leave only bestitamazon as payment selection if ($oUser !== false && isset($aResult[2]['bestitamazon']) && $sAmazonOrderReferenceId !== null ) { //If Amazon pay was selected remove other payment options and leave only Amazon pay $aResult[2] = array('bestitamazon' => $aResult[2]['bestitamazon']); //If Amazon pay was selected remove shipping options where Amazon pay is not assigned foreach ($aResult[0] as $sKey => $sValue) { if ($this->_getShippingAvailableForPayment($sKey) !== true) { unset($aResult[0][$sKey]); } } } } //If Amazon pay was not selected within the button click in 1st, 2nd step of checkout //check if selected currency is available for selected Amazon locale, if not remove amazon pay option from payments if ($sAmazonOrderReferenceId === null && ($this->_getContainer()->getModule()->getIsSelectedCurrencyAvailable() === false || $oBasket->getPrice()->getBruttoPrice() === 0 || ((bool)$oConfig->getConfigParam('blAmazonLoginActive') === true && $this->_getContainer()->getLoginClient()->showAmazonPayButton() === false) ) ) { unset($aResult[2]['bestitamazon']); } return $aResult; }
php
protected function _processResult($aResult, $oUser, $oBasket) { $oConfig = $this->_getContainer()->getConfig(); $sClass = $oConfig->getRequestParameter('cl'); $sAmazonOrderReferenceId = $this->_getContainer()->getSession()->getVariable('amazonOrderReferenceId'); //If Amazon Pay cannot be selected remove it from payments list if ($sClass === 'payment') { if ($this->_getContainer()->getModule()->isActive() !== true) { unset($aResult[2]['bestitamazon']); return $aResult; } //If Amazon pay was selected with the button before leave only bestitamazon as payment selection if ($oUser !== false && isset($aResult[2]['bestitamazon']) && $sAmazonOrderReferenceId !== null ) { //If Amazon pay was selected remove other payment options and leave only Amazon pay $aResult[2] = array('bestitamazon' => $aResult[2]['bestitamazon']); //If Amazon pay was selected remove shipping options where Amazon pay is not assigned foreach ($aResult[0] as $sKey => $sValue) { if ($this->_getShippingAvailableForPayment($sKey) !== true) { unset($aResult[0][$sKey]); } } } } //If Amazon pay was not selected within the button click in 1st, 2nd step of checkout //check if selected currency is available for selected Amazon locale, if not remove amazon pay option from payments if ($sAmazonOrderReferenceId === null && ($this->_getContainer()->getModule()->getIsSelectedCurrencyAvailable() === false || $oBasket->getPrice()->getBruttoPrice() === 0 || ((bool)$oConfig->getConfigParam('blAmazonLoginActive') === true && $this->_getContainer()->getLoginClient()->showAmazonPayButton() === false) ) ) { unset($aResult[2]['bestitamazon']); } return $aResult; }
[ "protected", "function", "_processResult", "(", "$", "aResult", ",", "$", "oUser", ",", "$", "oBasket", ")", "{", "$", "oConfig", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", ";", "$", "sClass", "=", "$", "oConfig", ...
If Amazon pay was selected remove other payment options and leave only Amazon pay If Amazon pay was selected remove shipping options where amazon pay is not assigned Loads deliveryset data, checks if it has payments assigned. If active delivery set id is passed - checks if it can be used, if not - takes first ship set id from list which fits. For active ship set collects payment list info. Retuns array containing: 1. all ship sets that has payment (array) 2. active ship set id (string) 3. payment list for active ship set (array) @param array $aResult @param oxUser $oUser @param oxBasket $oBasket @return mixed @throws oxConnectionException @throws oxSystemComponentException
[ "If", "Amazon", "pay", "was", "selected", "remove", "other", "payment", "options", "and", "leave", "only", "Amazon", "pay", "If", "Amazon", "pay", "was", "selected", "remove", "shipping", "options", "where", "amazon", "pay", "is", "not", "assigned" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxdeliverysetlist.php#L73-L116
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxdeliverysetlist.php
bestitAmazonPay4Oxid_oxDeliverySetList.getDeliverySetData
public function getDeliverySetData($sShipSet, $oUser, $oBasket) { //Get $aActSets, $sActShipSet, $aActPaymentList in array from parent method $aResult = parent::getDeliverySetData($sShipSet, $oUser, $oBasket); return $this->_processResult($aResult, $oUser, $oBasket); }
php
public function getDeliverySetData($sShipSet, $oUser, $oBasket) { //Get $aActSets, $sActShipSet, $aActPaymentList in array from parent method $aResult = parent::getDeliverySetData($sShipSet, $oUser, $oBasket); return $this->_processResult($aResult, $oUser, $oBasket); }
[ "public", "function", "getDeliverySetData", "(", "$", "sShipSet", ",", "$", "oUser", ",", "$", "oBasket", ")", "{", "//Get $aActSets, $sActShipSet, $aActPaymentList in array from parent method", "$", "aResult", "=", "parent", "::", "getDeliverySetData", "(", "$", "sShip...
Returns the delivery set data. @param string $sShipSet current ship set id (can be null if not set yet) @param oxUser $oUser active user @param oxBasket $oBasket basket object @return array @throws oxConnectionException @throws oxSystemComponentException
[ "Returns", "the", "delivery", "set", "data", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxdeliverysetlist.php#L131-L136
train
RobDWaller/wordpress-salts-generator
src/Salts.php
Salts.wordPressSalts
public function wordPressSalts(): array { $generator = new Generator(new Factory); $salts['AUTH_KEY'] = $generator->salt(); $salts['SECURE_AUTH_KEY'] = $generator->salt(); $salts['LOGGED_IN_KEY'] = $generator->salt(); $salts['NONCE_KEY'] = $generator->salt(); $salts['AUTH_SALT'] = $generator->salt(); $salts['SECURE_AUTH_SALT'] = $generator->salt(); $salts['LOGGED_IN_SALT'] = $generator->salt(); $salts['NONCE_SALT'] = $generator->salt(); return $salts; }
php
public function wordPressSalts(): array { $generator = new Generator(new Factory); $salts['AUTH_KEY'] = $generator->salt(); $salts['SECURE_AUTH_KEY'] = $generator->salt(); $salts['LOGGED_IN_KEY'] = $generator->salt(); $salts['NONCE_KEY'] = $generator->salt(); $salts['AUTH_SALT'] = $generator->salt(); $salts['SECURE_AUTH_SALT'] = $generator->salt(); $salts['LOGGED_IN_SALT'] = $generator->salt(); $salts['NONCE_SALT'] = $generator->salt(); return $salts; }
[ "public", "function", "wordPressSalts", "(", ")", ":", "array", "{", "$", "generator", "=", "new", "Generator", "(", "new", "Factory", ")", ";", "$", "salts", "[", "'AUTH_KEY'", "]", "=", "$", "generator", "->", "salt", "(", ")", ";", "$", "salts", "...
Generate and return all the WordPress salts as an array. @return array
[ "Generate", "and", "return", "all", "the", "WordPress", "salts", "as", "an", "array", "." ]
f55f34ee3243ec81215a05e62c4e802210cecdeb
https://github.com/RobDWaller/wordpress-salts-generator/blob/f55f34ee3243ec81215a05e62c4e802210cecdeb/src/Salts.php#L22-L36
train
RobDWaller/wordpress-salts-generator
src/Salts.php
Salts.traditional
public function traditional(): string { $salts = $this->wordPressSalts(); return array_reduce(array_keys($salts), function ($saltsString, $key) use ($salts) { $saltsString .= "define('$key', '$salts[$key]');" . PHP_EOL; return $saltsString; }, ''); }
php
public function traditional(): string { $salts = $this->wordPressSalts(); return array_reduce(array_keys($salts), function ($saltsString, $key) use ($salts) { $saltsString .= "define('$key', '$salts[$key]');" . PHP_EOL; return $saltsString; }, ''); }
[ "public", "function", "traditional", "(", ")", ":", "string", "{", "$", "salts", "=", "$", "this", "->", "wordPressSalts", "(", ")", ";", "return", "array_reduce", "(", "array_keys", "(", "$", "salts", ")", ",", "function", "(", "$", "saltsString", ",", ...
Gets an array of WordPress salts and then reduces them to a string for output to the CLI. Returns them in the traditional WordPress define format used in wp-config.php files. @return string
[ "Gets", "an", "array", "of", "WordPress", "salts", "and", "then", "reduces", "them", "to", "a", "string", "for", "output", "to", "the", "CLI", ".", "Returns", "them", "in", "the", "traditional", "WordPress", "define", "format", "used", "in", "wp", "-", "...
f55f34ee3243ec81215a05e62c4e802210cecdeb
https://github.com/RobDWaller/wordpress-salts-generator/blob/f55f34ee3243ec81215a05e62c4e802210cecdeb/src/Salts.php#L45-L54
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_order_overview.php
bestitAmazonPay4Oxid_order_overview.sendorder
public function sendorder() { parent::sendorder(); /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($this->getEditObjectId()) === true && $oOrder->getFieldData('oxPaymentType') === 'bestitamazon' ) { $this->_getContainer()->getClient()->saveCapture($oOrder); } }
php
public function sendorder() { parent::sendorder(); /** @var oxOrder $oOrder */ $oOrder = $this->_getContainer()->getObjectFactory()->createOxidObject('oxOrder'); if ($oOrder->load($this->getEditObjectId()) === true && $oOrder->getFieldData('oxPaymentType') === 'bestitamazon' ) { $this->_getContainer()->getClient()->saveCapture($oOrder); } }
[ "public", "function", "sendorder", "(", ")", "{", "parent", "::", "sendorder", "(", ")", ";", "/** @var oxOrder $oOrder */", "$", "oOrder", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getObjectFactory", "(", ")", "->", "createOxidObject", "(", ...
Capture order after changing it to shipped @throws Exception
[ "Capture", "order", "after", "changing", "it", "to", "shipped" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_order_overview.php#L34-L45
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxcmp_basket.php
bestitAmazonPay4Oxid_oxcmp_basket.cleanAmazonPay
public function cleanAmazonPay($cancelOrderReference = false) { $oConfig = $this->_getContainer()->getConfig(); if ($cancelOrderReference === true || (bool) $oConfig->getRequestParameter('cancelOrderReference')) { $this->_getContainer()->getClient()->cancelOrderReference( null, array('amazon_order_reference_id' => $this->_getContainer() ->getSession() ->getVariable('amazonOrderReferenceId') ) ); } //Clean all related variables with user data and amazon reference id $this->_getContainer()->getModule()->cleanAmazonPay(); $sErrorCode = (string)$oConfig->getRequestParameter('bestitAmazonPay4OxidErrorCode'); $sErrorMessage = (string)$oConfig->getRequestParameter('error'); if ($sErrorCode === 'CurrencyUnsupported') { $sError = self::BESTITAMAZONPAY_ERROR_CURRENCY_UNSUPPORTED; } elseif ($sErrorCode == 'InvalidParameterValue' && (stripos($sErrorMessage, 'presentmentCurrency') !== false || stripos($sErrorMessage, 'currencyCode') !== false) ) { $sError = self::BESTITAMAZONPAY_ERROR_CURRENCY_UNSUPPORTED; } elseif ($sErrorMessage !== '') { // error message directly by amazon pay $sError = $sErrorMessage; } else { $sError = self::BESTITAMAZONPAY_ERROR_AMAZON_TERMINATED; } /** @var oxUserException $oEx */ $oEx = $this->_getContainer()->getObjectFactory()->createOxidObject('oxUserException'); $oEx->setMessage($sError); $this->_getContainer()->getUtilsView()->addErrorToDisplay($oEx, false, true); //Redirect to user step $this->_getContainer()->getUtils()->redirect($oConfig->getShopSecureHomeUrl().'cl=basket', false); }
php
public function cleanAmazonPay($cancelOrderReference = false) { $oConfig = $this->_getContainer()->getConfig(); if ($cancelOrderReference === true || (bool) $oConfig->getRequestParameter('cancelOrderReference')) { $this->_getContainer()->getClient()->cancelOrderReference( null, array('amazon_order_reference_id' => $this->_getContainer() ->getSession() ->getVariable('amazonOrderReferenceId') ) ); } //Clean all related variables with user data and amazon reference id $this->_getContainer()->getModule()->cleanAmazonPay(); $sErrorCode = (string)$oConfig->getRequestParameter('bestitAmazonPay4OxidErrorCode'); $sErrorMessage = (string)$oConfig->getRequestParameter('error'); if ($sErrorCode === 'CurrencyUnsupported') { $sError = self::BESTITAMAZONPAY_ERROR_CURRENCY_UNSUPPORTED; } elseif ($sErrorCode == 'InvalidParameterValue' && (stripos($sErrorMessage, 'presentmentCurrency') !== false || stripos($sErrorMessage, 'currencyCode') !== false) ) { $sError = self::BESTITAMAZONPAY_ERROR_CURRENCY_UNSUPPORTED; } elseif ($sErrorMessage !== '') { // error message directly by amazon pay $sError = $sErrorMessage; } else { $sError = self::BESTITAMAZONPAY_ERROR_AMAZON_TERMINATED; } /** @var oxUserException $oEx */ $oEx = $this->_getContainer()->getObjectFactory()->createOxidObject('oxUserException'); $oEx->setMessage($sError); $this->_getContainer()->getUtilsView()->addErrorToDisplay($oEx, false, true); //Redirect to user step $this->_getContainer()->getUtils()->redirect($oConfig->getShopSecureHomeUrl().'cl=basket', false); }
[ "public", "function", "cleanAmazonPay", "(", "$", "cancelOrderReference", "=", "false", ")", "{", "$", "oConfig", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", ";", "if", "(", "$", "cancelOrderReference", "===", "true", "|...
Cleans Amazon pay as the selected one, including all related variables and values @param bool $cancelOrderReference @throws Exception @throws oxConnectionException @throws oxSystemComponentException
[ "Cleans", "Amazon", "pay", "as", "the", "selected", "one", "including", "all", "related", "variables", "and", "values" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxcmp_basket.php#L42-L83
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxcmp_basket.php
bestitAmazonPay4Oxid_oxcmp_basket.render
public function render() { $sClass = $this->_getContainer()->getConfig()->getRequestParameter('cl'); //If user was let to change payment, don't let him do other shit, just payment selection if ($sClass !== 'order' && $sClass !== 'thankyou' && (bool)$this->_getContainer()->getSession()->getVariable('blAmazonSyncChangePayment') === true ) { $this->cleanAmazonPay(true); } return parent::render(); }
php
public function render() { $sClass = $this->_getContainer()->getConfig()->getRequestParameter('cl'); //If user was let to change payment, don't let him do other shit, just payment selection if ($sClass !== 'order' && $sClass !== 'thankyou' && (bool)$this->_getContainer()->getSession()->getVariable('blAmazonSyncChangePayment') === true ) { $this->cleanAmazonPay(true); } return parent::render(); }
[ "public", "function", "render", "(", ")", "{", "$", "sClass", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getRequestParameter", "(", "'cl'", ")", ";", "//If user was let to change payment, don't let him do other shit, just ...
Clears amazon pay variables. @return object @throws Exception @throws oxConnectionException @throws oxSystemComponentException
[ "Clears", "amazon", "pay", "variables", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxcmp_basket.php#L93-L106
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxcmp_basket.php
bestitAmazonPay4Oxid_oxcmp_basket._parentToBasket
protected function _parentToBasket( $sProductId = null, $dAmount = null, $aSelectList = null, $aPersistentParameters = null, $blOverride = false ) { return parent::tobasket($sProductId, $dAmount, $aSelectList, $aPersistentParameters, $blOverride); }
php
protected function _parentToBasket( $sProductId = null, $dAmount = null, $aSelectList = null, $aPersistentParameters = null, $blOverride = false ) { return parent::tobasket($sProductId, $dAmount, $aSelectList, $aPersistentParameters, $blOverride); }
[ "protected", "function", "_parentToBasket", "(", "$", "sProductId", "=", "null", ",", "$", "dAmount", "=", "null", ",", "$", "aSelectList", "=", "null", ",", "$", "aPersistentParameters", "=", "null", ",", "$", "blOverride", "=", "false", ")", "{", "return...
Parent function wrapper. @param null|string $sProductId @param null|float $dAmount @param null|array $aSelectList @param null|array $aPersistentParameters @param bool $blOverride @return mixed
[ "Parent", "function", "wrapper", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxcmp_basket.php#L119-L127
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxcmp_basket.php
bestitAmazonPay4Oxid_oxcmp_basket.tobasket
public function tobasket( $sProductId = null, $dAmount = null, $aSelectList = null, $aPersistentParameters = null, $blOverride = false ) { $oContainer = $this->_getContainer(); $oConfig = $oContainer->getConfig(); $isAmazonPay = (bool)$oConfig->getRequestParameter('bestitAmazonPayIsAmazonPay'); $sReturn = null; if ($isAmazonPay === true) { $oContainer->getBasketUtil()->setQuickCheckoutBasket(); $sAmazonOrderReferenceId = $oConfig->getRequestParameter('amazonOrderReferenceId'); $sAccessToken = $oConfig->getRequestParameter('access_token'); $sReturn = 'user?fnc=amazonLogin&redirectCl=user&amazonOrderReferenceId='.$sAmazonOrderReferenceId .'&access_token='.$sAccessToken; } $sDefaultReturn = $this->_parentToBasket( $sProductId, $dAmount, $aSelectList, $aPersistentParameters, $blOverride ); if ($isAmazonPay === true) { $oSession = $oContainer->getSession(); $oSession->setVariable('blAddedNewItem', false); $oSession->setVariable('isAmazonPayQuickCheckout', true); return $sReturn; } return $sDefaultReturn; }
php
public function tobasket( $sProductId = null, $dAmount = null, $aSelectList = null, $aPersistentParameters = null, $blOverride = false ) { $oContainer = $this->_getContainer(); $oConfig = $oContainer->getConfig(); $isAmazonPay = (bool)$oConfig->getRequestParameter('bestitAmazonPayIsAmazonPay'); $sReturn = null; if ($isAmazonPay === true) { $oContainer->getBasketUtil()->setQuickCheckoutBasket(); $sAmazonOrderReferenceId = $oConfig->getRequestParameter('amazonOrderReferenceId'); $sAccessToken = $oConfig->getRequestParameter('access_token'); $sReturn = 'user?fnc=amazonLogin&redirectCl=user&amazonOrderReferenceId='.$sAmazonOrderReferenceId .'&access_token='.$sAccessToken; } $sDefaultReturn = $this->_parentToBasket( $sProductId, $dAmount, $aSelectList, $aPersistentParameters, $blOverride ); if ($isAmazonPay === true) { $oSession = $oContainer->getSession(); $oSession->setVariable('blAddedNewItem', false); $oSession->setVariable('isAmazonPayQuickCheckout', true); return $sReturn; } return $sDefaultReturn; }
[ "public", "function", "tobasket", "(", "$", "sProductId", "=", "null", ",", "$", "dAmount", "=", "null", ",", "$", "aSelectList", "=", "null", ",", "$", "aPersistentParameters", "=", "null", ",", "$", "blOverride", "=", "false", ")", "{", "$", "oContaine...
Check if we are using amazon quick checkout. @param null|string $sProductId @param null|float $dAmount @param null|array $aSelectList @param null|array $aPersistentParameters @param bool $blOverride @return mixed @throws oxSystemComponentException
[ "Check", "if", "we", "are", "using", "amazon", "quick", "checkout", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxcmp_basket.php#L141-L177
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig.getSelfLink
public function getSelfLink() { try { if ((bool)$this->_getContainer()->getConfig()->getConfigParam('sSSLShopURL') === true && !$this->isAdmin() && $this->getAmazonLoginIsActive() ) { return $this->getSslSelfLink(); } } catch (Exception $oException) { //Do nothing } return parent::getSelfLink(); }
php
public function getSelfLink() { try { if ((bool)$this->_getContainer()->getConfig()->getConfigParam('sSSLShopURL') === true && !$this->isAdmin() && $this->getAmazonLoginIsActive() ) { return $this->getSslSelfLink(); } } catch (Exception $oException) { //Do nothing } return parent::getSelfLink(); }
[ "public", "function", "getSelfLink", "(", ")", "{", "try", "{", "if", "(", "(", "bool", ")", "$", "this", "->", "_getContainer", "(", ")", "->", "getConfig", "(", ")", "->", "getConfigParam", "(", "'sSSLShopURL'", ")", "===", "true", "&&", "!", "$", ...
Forces to return shop self link if Amazon Login is active and we already have ORO Method is dedicated to stay always in checkout process under SSL @return string
[ "Forces", "to", "return", "shop", "self", "link", "if", "Amazon", "Login", "is", "active", "and", "we", "already", "have", "ORO", "Method", "is", "dedicated", "to", "stay", "always", "in", "checkout", "process", "under", "SSL" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L148-L162
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig.getBasketLink
public function getBasketLink() { if ($this->getAmazonLoginIsActive() === true) { $sValue = $this->getViewConfigParam('basketlink'); if ((string)$sValue === '') { $sValue = $this->_getContainer()->getConfig()->getShopSecureHomeUrl().'cl=basket'; $this->setViewConfigParam('basketlink', $sValue); } return $sValue; } return parent::getBasketLink(); }
php
public function getBasketLink() { if ($this->getAmazonLoginIsActive() === true) { $sValue = $this->getViewConfigParam('basketlink'); if ((string)$sValue === '') { $sValue = $this->_getContainer()->getConfig()->getShopSecureHomeUrl().'cl=basket'; $this->setViewConfigParam('basketlink', $sValue); } return $sValue; } return parent::getBasketLink(); }
[ "public", "function", "getBasketLink", "(", ")", "{", "if", "(", "$", "this", "->", "getAmazonLoginIsActive", "(", ")", "===", "true", ")", "{", "$", "sValue", "=", "$", "this", "->", "getViewConfigParam", "(", "'basketlink'", ")", ";", "if", "(", "(", ...
Forces to return basket link if Amazon Login is active and we already have ORO in SSL @return string @throws oxSystemComponentException
[ "Forces", "to", "return", "basket", "link", "if", "Amazon", "Login", "is", "active", "and", "we", "already", "have", "ORO", "in", "SSL" ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L170-L184
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig._getInjectedCode
protected function _getInjectedCode() { $oUtils = $this->_getContainer()->getUtils(); $aCodeInjected = $oUtils->fromStaticCache(self::CODE_INJECTED_STATIC_CACHE_KEY); return $aCodeInjected === null ? array() : $aCodeInjected; }
php
protected function _getInjectedCode() { $oUtils = $this->_getContainer()->getUtils(); $aCodeInjected = $oUtils->fromStaticCache(self::CODE_INJECTED_STATIC_CACHE_KEY); return $aCodeInjected === null ? array() : $aCodeInjected; }
[ "protected", "function", "_getInjectedCode", "(", ")", "{", "$", "oUtils", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getUtils", "(", ")", ";", "$", "aCodeInjected", "=", "$", "oUtils", "->", "fromStaticCache", "(", "self", "::", "CODE_INJEC...
Loads the injected code map from the static cache. @return array|mixed @throws oxSystemComponentException
[ "Loads", "the", "injected", "code", "map", "from", "the", "static", "cache", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L193-L198
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig.setJSCodeInjected
public function setJSCodeInjected($sType) { $aCodeInjected = $this->_getInjectedCode(); $aCodeInjected[$sType] = true; $this->_getContainer()->getUtils()->toStaticCache(self::CODE_INJECTED_STATIC_CACHE_KEY, $aCodeInjected); }
php
public function setJSCodeInjected($sType) { $aCodeInjected = $this->_getInjectedCode(); $aCodeInjected[$sType] = true; $this->_getContainer()->getUtils()->toStaticCache(self::CODE_INJECTED_STATIC_CACHE_KEY, $aCodeInjected); }
[ "public", "function", "setJSCodeInjected", "(", "$", "sType", ")", "{", "$", "aCodeInjected", "=", "$", "this", "->", "_getInjectedCode", "(", ")", ";", "$", "aCodeInjected", "[", "$", "sType", "]", "=", "true", ";", "$", "this", "->", "_getContainer", "...
Marks the type as already injected. @param $sType @throws oxSystemComponentException
[ "Marks", "the", "type", "as", "already", "injected", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L207-L212
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig.wasJSCodeInjected
public function wasJSCodeInjected($sType) { $aCodeInjected = $this->_getInjectedCode(); return isset($aCodeInjected[$sType]) && $aCodeInjected[$sType]; }
php
public function wasJSCodeInjected($sType) { $aCodeInjected = $this->_getInjectedCode(); return isset($aCodeInjected[$sType]) && $aCodeInjected[$sType]; }
[ "public", "function", "wasJSCodeInjected", "(", "$", "sType", ")", "{", "$", "aCodeInjected", "=", "$", "this", "->", "_getInjectedCode", "(", ")", ";", "return", "isset", "(", "$", "aCodeInjected", "[", "$", "sType", "]", ")", "&&", "$", "aCodeInjected", ...
Checks if the code with given type was already injected. @param $sType @return bool @throws oxSystemComponentException
[ "Checks", "if", "the", "code", "with", "given", "type", "was", "already", "injected", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L222-L226
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_oxviewconfig.php
bestitAmazonPay4Oxid_oxViewConfig.getBasketCurrency
public function getBasketCurrency() { $oCurrency = $this->_getContainer()->getSession()->getBasket()->getBasketCurrency(); return $oCurrency !== null ? $oCurrency->name : ''; }
php
public function getBasketCurrency() { $oCurrency = $this->_getContainer()->getSession()->getBasket()->getBasketCurrency(); return $oCurrency !== null ? $oCurrency->name : ''; }
[ "public", "function", "getBasketCurrency", "(", ")", "{", "$", "oCurrency", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getSession", "(", ")", "->", "getBasket", "(", ")", "->", "getBasketCurrency", "(", ")", ";", "return", "$", "oCurrency", ...
Returns the basket currency. @return string @throws oxSystemComponentException
[ "Returns", "the", "basket", "currency", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_oxviewconfig.php#L244-L249
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_order.php
bestitAmazonPay4Oxid_order.getAmazonBillingAddress
public function getAmazonBillingAddress() { $oOrderReferenceDetails = $this->_getContainer()->getClient()->getOrderReferenceDetails(); $oDetails = $oOrderReferenceDetails->GetOrderReferenceDetailsResult->OrderReferenceDetails; if (isset($oDetails->BillingAddress) === true) { $aParsedData = $this->_getContainer() ->getAddressUtil() ->parseAmazonAddress($oDetails->BillingAddress->PhysicalAddress); return array( 'oxfname' => $aParsedData['FirstName'], 'oxlname' => $aParsedData['LastName'], 'oxcity' => $aParsedData['City'], 'oxstateid' => $aParsedData['StateOrRegion'], 'oxcountryid' => $aParsedData['CountryId'], 'oxzip' => $aParsedData['PostalCode'], 'oxstreet' => $aParsedData['Street'], 'oxstreetnr' => $aParsedData['StreetNr'], 'oxaddinfo' => $aParsedData['AddInfo'], 'oxcompany' => $aParsedData['CompanyName'] ); } return null; }
php
public function getAmazonBillingAddress() { $oOrderReferenceDetails = $this->_getContainer()->getClient()->getOrderReferenceDetails(); $oDetails = $oOrderReferenceDetails->GetOrderReferenceDetailsResult->OrderReferenceDetails; if (isset($oDetails->BillingAddress) === true) { $aParsedData = $this->_getContainer() ->getAddressUtil() ->parseAmazonAddress($oDetails->BillingAddress->PhysicalAddress); return array( 'oxfname' => $aParsedData['FirstName'], 'oxlname' => $aParsedData['LastName'], 'oxcity' => $aParsedData['City'], 'oxstateid' => $aParsedData['StateOrRegion'], 'oxcountryid' => $aParsedData['CountryId'], 'oxzip' => $aParsedData['PostalCode'], 'oxstreet' => $aParsedData['Street'], 'oxstreetnr' => $aParsedData['StreetNr'], 'oxaddinfo' => $aParsedData['AddInfo'], 'oxcompany' => $aParsedData['CompanyName'] ); } return null; }
[ "public", "function", "getAmazonBillingAddress", "(", ")", "{", "$", "oOrderReferenceDetails", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getClient", "(", ")", "->", "getOrderReferenceDetails", "(", ")", ";", "$", "oDetails", "=", "$", "oOrderRe...
Returns the amazon billing address. @return array|null @throws Exception @throws oxConnectionException @throws oxSystemComponentException
[ "Returns", "the", "amazon", "billing", "address", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_order.php#L54-L79
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_order.php
bestitAmazonPay4Oxid_order.getCountryName
public function getCountryName($sCountryId) { /** @var oxCountryList $oCountryList */ $oCountry = $this->_getContainer()->getObjectFactory()->createOxidObject('oxCountry'); return ($oCountry->load($sCountryId) === true) ? (string) $oCountry->getFieldData('oxTitle') : ''; }
php
public function getCountryName($sCountryId) { /** @var oxCountryList $oCountryList */ $oCountry = $this->_getContainer()->getObjectFactory()->createOxidObject('oxCountry'); return ($oCountry->load($sCountryId) === true) ? (string) $oCountry->getFieldData('oxTitle') : ''; }
[ "public", "function", "getCountryName", "(", "$", "sCountryId", ")", "{", "/** @var oxCountryList $oCountryList */", "$", "oCountry", "=", "$", "this", "->", "_getContainer", "(", ")", "->", "getObjectFactory", "(", ")", "->", "createOxidObject", "(", "'oxCountry'",...
Returns the county name for the current billing address country. @param string $sCountryId @return string @throws oxSystemComponentException
[ "Returns", "the", "county", "name", "for", "the", "current", "billing", "address", "country", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_order.php#L89-L95
train
bestit/amazon-pay-oxid
ext/bestitamazonpay4oxid_order.php
bestitAmazonPay4Oxid_order.updateUserWithAmazonData
public function updateUserWithAmazonData() { $billingAddress = $this->getAmazonBillingAddress(); if ($billingAddress !== null) { $oUser = $this->getUser(); $oUser->assign($billingAddress); $oUser->save(); } }
php
public function updateUserWithAmazonData() { $billingAddress = $this->getAmazonBillingAddress(); if ($billingAddress !== null) { $oUser = $this->getUser(); $oUser->assign($billingAddress); $oUser->save(); } }
[ "public", "function", "updateUserWithAmazonData", "(", ")", "{", "$", "billingAddress", "=", "$", "this", "->", "getAmazonBillingAddress", "(", ")", ";", "if", "(", "$", "billingAddress", "!==", "null", ")", "{", "$", "oUser", "=", "$", "this", "->", "getU...
Updates the user data with the amazon data. @throws Exception @throws oxConnectionException @throws oxSystemComponentException
[ "Updates", "the", "user", "data", "with", "the", "amazon", "data", "." ]
d32254664e2f148d58bfafe36f5ce67ca30560d9
https://github.com/bestit/amazon-pay-oxid/blob/d32254664e2f148d58bfafe36f5ce67ca30560d9/ext/bestitamazonpay4oxid_order.php#L103-L112
train