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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.request | public function request($url, $params = array(), $method = 'GET', $json_body = true, array $headers = array()): array
{
$headers = array_merge(array(
'Accept' => self::VERSION_STRING,
'User-Agent' => self::USER_AGENT,
), $headers);
$method = strtoupper($method);
// If a pre-defined `Authorization` header isn't present, then add a bearer token or client information.
if (!isset($headers['Authorization'])) {
if (!empty($this->_access_token)) {
$headers['Authorization'] = 'Bearer ' . $this->_access_token;
} else {
// this may be a call to get the tokens, so we add the client info.
$headers['Authorization'] = 'Basic ' . $this->_authHeader();
}
}
// Set the methods, determine the URL that we should actually request and prep the body.
$curl_opts = array();
switch ($method) {
case 'GET':
case 'HEAD':
if (!empty($params)) {
$query_component = '?' . http_build_query($params, '', '&');
} else {
$query_component = '';
}
$curl_url = self::ROOT_ENDPOINT . $url . $query_component;
break;
case 'POST':
case 'PATCH':
case 'PUT':
case 'DELETE':
if ($json_body && !empty($params)) {
$headers['Content-Type'] = 'application/json';
$body = json_encode($params);
} else {
$body = http_build_query($params, '', '&');
}
$curl_url = self::ROOT_ENDPOINT . $url;
$curl_opts = array(
CURLOPT_POST => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POSTFIELDS => $body
);
break;
default:
throw new VimeoRequestException('This library does not support ' . $method . ' requests.');
}
// Set the headers
foreach ($headers as $key => $value) {
$curl_opts[CURLOPT_HTTPHEADER][] = sprintf('%s: %s', $key, $value);
}
$response = $this->_request($curl_url, $curl_opts);
$response['body'] = json_decode($response['body'], true);
return $response;
} | php | public function request($url, $params = array(), $method = 'GET', $json_body = true, array $headers = array()): array
{
$headers = array_merge(array(
'Accept' => self::VERSION_STRING,
'User-Agent' => self::USER_AGENT,
), $headers);
$method = strtoupper($method);
// If a pre-defined `Authorization` header isn't present, then add a bearer token or client information.
if (!isset($headers['Authorization'])) {
if (!empty($this->_access_token)) {
$headers['Authorization'] = 'Bearer ' . $this->_access_token;
} else {
// this may be a call to get the tokens, so we add the client info.
$headers['Authorization'] = 'Basic ' . $this->_authHeader();
}
}
// Set the methods, determine the URL that we should actually request and prep the body.
$curl_opts = array();
switch ($method) {
case 'GET':
case 'HEAD':
if (!empty($params)) {
$query_component = '?' . http_build_query($params, '', '&');
} else {
$query_component = '';
}
$curl_url = self::ROOT_ENDPOINT . $url . $query_component;
break;
case 'POST':
case 'PATCH':
case 'PUT':
case 'DELETE':
if ($json_body && !empty($params)) {
$headers['Content-Type'] = 'application/json';
$body = json_encode($params);
} else {
$body = http_build_query($params, '', '&');
}
$curl_url = self::ROOT_ENDPOINT . $url;
$curl_opts = array(
CURLOPT_POST => true,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POSTFIELDS => $body
);
break;
default:
throw new VimeoRequestException('This library does not support ' . $method . ' requests.');
}
// Set the headers
foreach ($headers as $key => $value) {
$curl_opts[CURLOPT_HTTPHEADER][] = sprintf('%s: %s', $key, $value);
}
$response = $this->_request($curl_url, $curl_opts);
$response['body'] = json_decode($response['body'], true);
return $response;
} | [
"public",
"function",
"request",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"json_body",
"=",
"true",
",",
"array",
"$",
"headers",
"=",
"array",
"(",
")",
")",
":",
"array",
"{",
"$",... | Make an API request to Vimeo.
@param string $url A Vimeo API Endpoint. Should not include the host
@param array $params An array of parameters to send to the endpoint. If the HTTP method is GET, they will be added to the url, otherwise they will be written to the body
@param string $method The HTTP Method of the request
@param bool $json_body
@param array $headers An array of HTTP headers to pass along with the request.
@return array This array contains three keys, 'status' is the status code, 'body' is an object representation of the json response body, and headers are an associated array of response headers
@throws VimeoRequestException | [
"Make",
"an",
"API",
"request",
"to",
"Vimeo",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L88-L154 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.setProxy | public function setProxy(string $proxy_address, string $proxy_port = null, string $proxy_userpwd = null): void
{
$this->CURL_DEFAULTS[CURLOPT_PROXY] = $proxy_address;
if ($proxy_port) {
$this->CURL_DEFAULTS[CURLOPT_PROXYPORT] = $proxy_port;
}
if ($proxy_userpwd) {
$this->CURL_DEFAULTS[CURLOPT_PROXYUSERPWD] = $proxy_userpwd;
}
} | php | public function setProxy(string $proxy_address, string $proxy_port = null, string $proxy_userpwd = null): void
{
$this->CURL_DEFAULTS[CURLOPT_PROXY] = $proxy_address;
if ($proxy_port) {
$this->CURL_DEFAULTS[CURLOPT_PROXYPORT] = $proxy_port;
}
if ($proxy_userpwd) {
$this->CURL_DEFAULTS[CURLOPT_PROXYUSERPWD] = $proxy_userpwd;
}
} | [
"public",
"function",
"setProxy",
"(",
"string",
"$",
"proxy_address",
",",
"string",
"$",
"proxy_port",
"=",
"null",
",",
"string",
"$",
"proxy_userpwd",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"CURL_DEFAULTS",
"[",
"CURLOPT_PROXY",
"]",
"=... | Set a proxy to pass all API requests through.
@param string $proxy_address Mandatory address of proxy.
@param string|null $proxy_port Optional number of port.
@param string|null $proxy_userpwd Optional `user:password` authentication. | [
"Set",
"a",
"proxy",
"to",
"pass",
"all",
"API",
"requests",
"through",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L203-L213 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.parse_headers | public static function parse_headers(string $headers): array
{
$final_headers = array();
$list = explode("\n", trim($headers));
$http = array_shift($list);
foreach ($list as $header) {
$parts = explode(':', $header, 2);
$final_headers[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
}
return $final_headers;
} | php | public static function parse_headers(string $headers): array
{
$final_headers = array();
$list = explode("\n", trim($headers));
$http = array_shift($list);
foreach ($list as $header) {
$parts = explode(':', $header, 2);
$final_headers[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
}
return $final_headers;
} | [
"public",
"static",
"function",
"parse_headers",
"(",
"string",
"$",
"headers",
")",
":",
"array",
"{",
"$",
"final_headers",
"=",
"array",
"(",
")",
";",
"$",
"list",
"=",
"explode",
"(",
"\"\\n\"",
",",
"trim",
"(",
"$",
"headers",
")",
")",
";",
"... | Convert the raw headers string into an associated array
@param string $headers
@return array | [
"Convert",
"the",
"raw",
"headers",
"string",
"into",
"an",
"associated",
"array"
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L221-L234 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.accessToken | public function accessToken(string $code, string $redirect_uri): array
{
return $this->request(self::ACCESS_TOKEN_ENDPOINT, array(
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => $redirect_uri
), "POST", false);
} | php | public function accessToken(string $code, string $redirect_uri): array
{
return $this->request(self::ACCESS_TOKEN_ENDPOINT, array(
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => $redirect_uri
), "POST", false);
} | [
"public",
"function",
"accessToken",
"(",
"string",
"$",
"code",
",",
"string",
"$",
"redirect_uri",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"self",
"::",
"ACCESS_TOKEN_ENDPOINT",
",",
"array",
"(",
"'grant_type'",
"=>",
"'author... | Request an access token. This is the final step of the
OAuth 2 workflow, and should be called from your redirect url.
@param string $code The authorization code that was provided to your redirect url
@param string $redirect_uri The redirect_uri that is configured on your app page, and was used in buildAuthorizationEndpoint
@return array This array contains three keys, 'status' is the status code, 'body' is an object representation of the json response body, and headers are an associated array of response headers | [
"Request",
"an",
"access",
"token",
".",
"This",
"is",
"the",
"final",
"step",
"of",
"the",
"OAuth",
"2",
"workflow",
"and",
"should",
"be",
"called",
"from",
"your",
"redirect",
"url",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L244-L251 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.clientCredentials | public function clientCredentials($scope = 'public')
{
if (is_array($scope)) {
$scope = implode(' ', $scope);
}
$token_response = $this->request(self::CLIENT_CREDENTIALS_TOKEN_ENDPOINT, array(
'grant_type' => 'client_credentials',
'scope' => $scope
), "POST", false);
return $token_response;
} | php | public function clientCredentials($scope = 'public')
{
if (is_array($scope)) {
$scope = implode(' ', $scope);
}
$token_response = $this->request(self::CLIENT_CREDENTIALS_TOKEN_ENDPOINT, array(
'grant_type' => 'client_credentials',
'scope' => $scope
), "POST", false);
return $token_response;
} | [
"public",
"function",
"clientCredentials",
"(",
"$",
"scope",
"=",
"'public'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"implode",
"(",
"' '",
",",
"$",
"scope",
")",
";",
"}",
"$",
"token_response",
"=",
... | Get client credentials for requests.
@param mixed $scope Scopes to request for this token from the server.
@return array Response from the server with the tokens, we also set it into this object. | [
"Get",
"client",
"credentials",
"for",
"requests",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L259-L271 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.buildAuthorizationEndpoint | public function buildAuthorizationEndpoint($redirect_uri, $scope = 'public', $state = null)
{
$query = array(
"response_type" => 'code',
"client_id" => $this->_client_id,
"redirect_uri" => $redirect_uri
);
$query['scope'] = $scope;
if (empty($scope)) {
$query['scope'] = 'public';
} elseif (is_array($scope)) {
$query['scope'] = implode(' ', $scope);
}
if (!empty($state)) {
$query['state'] = $state;
}
return self::AUTH_ENDPOINT . '?' . http_build_query($query);
} | php | public function buildAuthorizationEndpoint($redirect_uri, $scope = 'public', $state = null)
{
$query = array(
"response_type" => 'code',
"client_id" => $this->_client_id,
"redirect_uri" => $redirect_uri
);
$query['scope'] = $scope;
if (empty($scope)) {
$query['scope'] = 'public';
} elseif (is_array($scope)) {
$query['scope'] = implode(' ', $scope);
}
if (!empty($state)) {
$query['state'] = $state;
}
return self::AUTH_ENDPOINT . '?' . http_build_query($query);
} | [
"public",
"function",
"buildAuthorizationEndpoint",
"(",
"$",
"redirect_uri",
",",
"$",
"scope",
"=",
"'public'",
",",
"$",
"state",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"array",
"(",
"\"response_type\"",
"=>",
"'code'",
",",
"\"client_id\"",
"=>",
"$",... | Build the url that your user.
@param string $redirect_uri The redirect url that you have configured on your app page
@param string|array|null $scope An array of scopes that your final access token needs to access
@param string|null $state A random variable that will be returned on your redirect url. You should validate that this matches
@return string | [
"Build",
"the",
"url",
"that",
"your",
"user",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L281-L301 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.replace | public function replace($video_uri, $file_path, array $params = array())
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
$file_size = filesize($file_path);
// Use JSON filtering so we only receive the data that we need to make an upload happen.
$uri = $video_uri . self::VERSIONS_ENDPOINT . '?fields=upload';
// Ignore any specified upload approach and size.
$params['file_name'] = basename($file_path);
$params['upload']['approach'] = 'tus';
$params['upload']['size'] = $file_size;
$attempt = $this->request($uri, $params, 'POST');
if ($attempt['status'] !== 201) {
$attempt_error = !empty($attempt['body']['error']) ? ' [' . $attempt['body']['error'] . ']' : '';
throw new VimeoUploadException('Unable to initiate an upload.' . $attempt_error);
}
// `uri` doesn't come back from `/videos/:id/versions` so we need to manually set it here for uploading.
$attempt['body']['uri'] = $video_uri;
return $this->perform_upload_tus($file_path, $file_size, $attempt);
} | php | public function replace($video_uri, $file_path, array $params = array())
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
$file_size = filesize($file_path);
// Use JSON filtering so we only receive the data that we need to make an upload happen.
$uri = $video_uri . self::VERSIONS_ENDPOINT . '?fields=upload';
// Ignore any specified upload approach and size.
$params['file_name'] = basename($file_path);
$params['upload']['approach'] = 'tus';
$params['upload']['size'] = $file_size;
$attempt = $this->request($uri, $params, 'POST');
if ($attempt['status'] !== 201) {
$attempt_error = !empty($attempt['body']['error']) ? ' [' . $attempt['body']['error'] . ']' : '';
throw new VimeoUploadException('Unable to initiate an upload.' . $attempt_error);
}
// `uri` doesn't come back from `/videos/:id/versions` so we need to manually set it here for uploading.
$attempt['body']['uri'] = $video_uri;
return $this->perform_upload_tus($file_path, $file_size, $attempt);
} | [
"public",
"function",
"replace",
"(",
"$",
"video_uri",
",",
"$",
"file_path",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"// Validate that our file is real.",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file_path",
")",
")",
"{",
"throw",
... | Replace the source of a single Vimeo video.
@link https://developer.vimeo.com/api/endpoints/videos#POST/videos/{video_id}/versions
@param string $video_uri Video uri of the video file to replace.
@param string $file_path Path to the video file to upload.
@return string Video URI
@throws VimeoRequestException
@throws VimeoUploadException | [
"Replace",
"the",
"source",
"of",
"a",
"single",
"Vimeo",
"video",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L351-L378 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.uploadImage | public function uploadImage($pictures_uri, $file_path, $activate = false)
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
$pictures_response = $this->request($pictures_uri, array(), 'POST');
if ($pictures_response['status'] !== 201) {
throw new VimeoUploadException('Unable to request an upload url from vimeo');
}
$upload_url = $pictures_response['body']['link'];
$image_resource = fopen($file_path, 'r');
$curl_opts = array(
CURLOPT_TIMEOUT => 240,
CURLOPT_UPLOAD => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_READDATA => $image_resource
);
$curl = curl_init($upload_url);
// Merge the options
curl_setopt_array($curl, $curl_opts + $this->CURL_DEFAULTS);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (!$response || !is_string($response)) {
$error = curl_error($curl);
throw new VimeoUploadException($error);
}
curl_close($curl);
if ($curl_info['http_code'] !== 200) {
throw new VimeoUploadException($response);
}
// Activate the uploaded image
if ($activate) {
$completion = $this->request($pictures_response['body']['uri'], array('active' => true), 'PATCH');
}
return $pictures_response['body']['uri'];
} | php | public function uploadImage($pictures_uri, $file_path, $activate = false)
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
$pictures_response = $this->request($pictures_uri, array(), 'POST');
if ($pictures_response['status'] !== 201) {
throw new VimeoUploadException('Unable to request an upload url from vimeo');
}
$upload_url = $pictures_response['body']['link'];
$image_resource = fopen($file_path, 'r');
$curl_opts = array(
CURLOPT_TIMEOUT => 240,
CURLOPT_UPLOAD => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_READDATA => $image_resource
);
$curl = curl_init($upload_url);
// Merge the options
curl_setopt_array($curl, $curl_opts + $this->CURL_DEFAULTS);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (!$response || !is_string($response)) {
$error = curl_error($curl);
throw new VimeoUploadException($error);
}
curl_close($curl);
if ($curl_info['http_code'] !== 200) {
throw new VimeoUploadException($response);
}
// Activate the uploaded image
if ($activate) {
$completion = $this->request($pictures_response['body']['uri'], array('active' => true), 'PATCH');
}
return $pictures_response['body']['uri'];
} | [
"public",
"function",
"uploadImage",
"(",
"$",
"pictures_uri",
",",
"$",
"file_path",
",",
"$",
"activate",
"=",
"false",
")",
"{",
"// Validate that our file is real.",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file_path",
")",
")",
"{",
"throw",
"new",
"VimeoU... | Uploads an image to an individual picture response.
@link https://developer.vimeo.com/api/upload/pictures
@param string $pictures_uri The pictures endpoint for a resource that allows picture uploads (eg videos and users)
@param string $file_path The path to your image file
@param boolean $activate Activate image after upload
@return string The URI of the uploaded image.
@throws VimeoRequestException
@throws VimeoUploadException | [
"Uploads",
"an",
"image",
"to",
"an",
"individual",
"picture",
"response",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L391-L438 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.uploadTexttrack | public function uploadTexttrack($texttracks_uri, $file_path, $track_type, $language)
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
// To simplify the script we provide the filename as the text track name, but you can provide any value you want.
$name = array_slice(explode("/", $file_path), -1);
$name = $name[0];
$texttrack_response = $this->request($texttracks_uri, array(
'type' => $track_type,
'language' => $language,
'name' => $name
), 'POST');
if ($texttrack_response['status'] !== 201) {
throw new VimeoUploadException('Unable to request an upload url from vimeo');
}
$upload_url = $texttrack_response['body']['link'];
$texttrack_resource = fopen($file_path, 'r');
$curl_opts = array(
CURLOPT_TIMEOUT => 240,
CURLOPT_UPLOAD => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_READDATA => $texttrack_resource
);
$curl = curl_init($upload_url);
// Merge the options
curl_setopt_array($curl, $curl_opts + $this->CURL_DEFAULTS);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (!$response || !is_string($response)) {
$error = curl_error($curl);
throw new VimeoUploadException($error);
}
curl_close($curl);
if ($curl_info['http_code'] !== 200) {
throw new VimeoUploadException($response);
}
return $texttrack_response['body']['uri'];
} | php | public function uploadTexttrack($texttracks_uri, $file_path, $track_type, $language)
{
// Validate that our file is real.
if (!is_file($file_path)) {
throw new VimeoUploadException('Unable to locate file to upload.');
}
// To simplify the script we provide the filename as the text track name, but you can provide any value you want.
$name = array_slice(explode("/", $file_path), -1);
$name = $name[0];
$texttrack_response = $this->request($texttracks_uri, array(
'type' => $track_type,
'language' => $language,
'name' => $name
), 'POST');
if ($texttrack_response['status'] !== 201) {
throw new VimeoUploadException('Unable to request an upload url from vimeo');
}
$upload_url = $texttrack_response['body']['link'];
$texttrack_resource = fopen($file_path, 'r');
$curl_opts = array(
CURLOPT_TIMEOUT => 240,
CURLOPT_UPLOAD => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_READDATA => $texttrack_resource
);
$curl = curl_init($upload_url);
// Merge the options
curl_setopt_array($curl, $curl_opts + $this->CURL_DEFAULTS);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (!$response || !is_string($response)) {
$error = curl_error($curl);
throw new VimeoUploadException($error);
}
curl_close($curl);
if ($curl_info['http_code'] !== 200) {
throw new VimeoUploadException($response);
}
return $texttrack_response['body']['uri'];
} | [
"public",
"function",
"uploadTexttrack",
"(",
"$",
"texttracks_uri",
",",
"$",
"file_path",
",",
"$",
"track_type",
",",
"$",
"language",
")",
"{",
"// Validate that our file is real.",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file_path",
")",
")",
"{",
"throw",
... | Uploads a text track.
@link https://developer.vimeo.com/api/upload/texttracks
@param string $texttracks_uri The text tracks uri that we are adding our text track to
@param string $file_path The path to your text track file
@param string $track_type The type of your text track
@param string $language The language of your text track
@return string The URI of the uploaded text track.
@throws VimeoRequestException
@throws VimeoUploadException | [
"Uploads",
"a",
"text",
"track",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L452-L503 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo._request | private function _request(string $url, $curl_opts = array()): array
{
// Merge the options (custom options take precedence).
$curl_opts = $this->_curl_opts + $curl_opts + $this->CURL_DEFAULTS;
// Call the API.
$curl = curl_init($url);
curl_setopt_array($curl, $curl_opts);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (isset($curl_info['http_code']) && $curl_info['http_code'] === 0) {
$curl_error = curl_error($curl);
$curl_error = !empty($curl_error) ? ' [' . $curl_error .']' : '';
throw new VimeoRequestException('Unable to complete request.' . $curl_error);
} elseif (!$response || !is_string($response)) {
$curl_error = curl_error($curl);
$curl_error = !empty($curl_error) ? ' [' . $curl_error .']' : '';
throw new VimeoRequestException('Unable to complete request.' . $curl_error);
}
curl_close($curl);
// Retrieve the info
$header_size = $curl_info['header_size'];
$headers = substr($response, 0, $header_size);
$body = substr($response, $header_size);
// Return it raw.
return array(
'body' => $body,
'status' => $curl_info['http_code'],
'headers' => self::parse_headers($headers)
);
} | php | private function _request(string $url, $curl_opts = array()): array
{
// Merge the options (custom options take precedence).
$curl_opts = $this->_curl_opts + $curl_opts + $this->CURL_DEFAULTS;
// Call the API.
$curl = curl_init($url);
curl_setopt_array($curl, $curl_opts);
$response = curl_exec($curl);
$curl_info = curl_getinfo($curl);
if (isset($curl_info['http_code']) && $curl_info['http_code'] === 0) {
$curl_error = curl_error($curl);
$curl_error = !empty($curl_error) ? ' [' . $curl_error .']' : '';
throw new VimeoRequestException('Unable to complete request.' . $curl_error);
} elseif (!$response || !is_string($response)) {
$curl_error = curl_error($curl);
$curl_error = !empty($curl_error) ? ' [' . $curl_error .']' : '';
throw new VimeoRequestException('Unable to complete request.' . $curl_error);
}
curl_close($curl);
// Retrieve the info
$header_size = $curl_info['header_size'];
$headers = substr($response, 0, $header_size);
$body = substr($response, $header_size);
// Return it raw.
return array(
'body' => $body,
'status' => $curl_info['http_code'],
'headers' => self::parse_headers($headers)
);
} | [
"private",
"function",
"_request",
"(",
"string",
"$",
"url",
",",
"$",
"curl_opts",
"=",
"array",
"(",
")",
")",
":",
"array",
"{",
"// Merge the options (custom options take precedence).",
"$",
"curl_opts",
"=",
"$",
"this",
"->",
"_curl_opts",
"+",
"$",
"cu... | Internal function to handle requests, both authenticated and by the upload function.
@param string $url
@param array $curl_opts
@return array
@throws VimeoRequestException | [
"Internal",
"function",
"to",
"handle",
"requests",
"both",
"authenticated",
"and",
"by",
"the",
"upload",
"function",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L513-L547 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.perform_upload_tus | private function perform_upload_tus(string $file_path, $file_size, array $attempt): string
{
$default_chunk_size = (100 * 1024 * 1024); // 100 MB
$url = $attempt['body']['upload']['upload_link'];
$url_path = parse_url($url)['path'];
$base_url = str_replace($url_path, '', $url);
$api_path = $url_path;
$api_pathp = explode('/', $api_path);
$key = $api_pathp[count($api_pathp) - 1];
$api_path = str_replace('/' . $key, '', $api_path);
$bytes_uploaded = 0;
$failures = 0;
$chunk_size = $this->getTusUploadChunkSize($default_chunk_size, (int)$file_size);
$client = new \TusPhp\Tus\Client($base_url);
$client->setApiPath($api_path);
$client->setKey($key)->file($file_path);
do {
try {
$bytes_uploaded = $client->upload($chunk_size);
} catch (\Exception $e) {
// We likely experienced a timeout, but if we experience three in a row, then we should back off and
// fail so as to not overwhelm servers that are, probably, down.
if ($failures >= 3) {
throw new VimeoUploadException($e->getMessage());
}
$failures++;
sleep((int)pow(4, $failures)); // sleep 4, 16, 64 seconds (based on failure count)
}
} while ($bytes_uploaded < $file_size);
return $attempt['body']['uri'];
} | php | private function perform_upload_tus(string $file_path, $file_size, array $attempt): string
{
$default_chunk_size = (100 * 1024 * 1024); // 100 MB
$url = $attempt['body']['upload']['upload_link'];
$url_path = parse_url($url)['path'];
$base_url = str_replace($url_path, '', $url);
$api_path = $url_path;
$api_pathp = explode('/', $api_path);
$key = $api_pathp[count($api_pathp) - 1];
$api_path = str_replace('/' . $key, '', $api_path);
$bytes_uploaded = 0;
$failures = 0;
$chunk_size = $this->getTusUploadChunkSize($default_chunk_size, (int)$file_size);
$client = new \TusPhp\Tus\Client($base_url);
$client->setApiPath($api_path);
$client->setKey($key)->file($file_path);
do {
try {
$bytes_uploaded = $client->upload($chunk_size);
} catch (\Exception $e) {
// We likely experienced a timeout, but if we experience three in a row, then we should back off and
// fail so as to not overwhelm servers that are, probably, down.
if ($failures >= 3) {
throw new VimeoUploadException($e->getMessage());
}
$failures++;
sleep((int)pow(4, $failures)); // sleep 4, 16, 64 seconds (based on failure count)
}
} while ($bytes_uploaded < $file_size);
return $attempt['body']['uri'];
} | [
"private",
"function",
"perform_upload_tus",
"(",
"string",
"$",
"file_path",
",",
"$",
"file_size",
",",
"array",
"$",
"attempt",
")",
":",
"string",
"{",
"$",
"default_chunk_size",
"=",
"(",
"100",
"*",
"1024",
"*",
"1024",
")",
";",
"// 100 MB",
"$",
... | Take an upload attempt and perform the actual upload via tus.
@link https://tus.io/
@param string $file_path Path to the video file to upload.
@param int|float $file_size Size of the video file.
@param array $attempt Upload attempt data.
@return string
@throws VimeoUploadException | [
"Take",
"an",
"upload",
"attempt",
"and",
"perform",
"the",
"actual",
"upload",
"via",
"tus",
"."
] | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L575-L612 | train |
vimeo/vimeo.php | src/Vimeo/Vimeo.php | Vimeo.getTusUploadChunkSize | private function getTusUploadChunkSize(int $proposed_chunk_size, int $file_size): int
{
$proposed_chunk_size = ($proposed_chunk_size <= 0) ? 1 : $proposed_chunk_size;
$chunks = floor($file_size / $proposed_chunk_size);
$divides_evenly = $file_size % $proposed_chunk_size === 0;
$number_of_chunks_proposed = ($divides_evenly) ? $chunks : $chunks + 1;
if ($number_of_chunks_proposed > 1024) {
return (int)floor($file_size / 1024) + 1;
}
return $proposed_chunk_size;
} | php | private function getTusUploadChunkSize(int $proposed_chunk_size, int $file_size): int
{
$proposed_chunk_size = ($proposed_chunk_size <= 0) ? 1 : $proposed_chunk_size;
$chunks = floor($file_size / $proposed_chunk_size);
$divides_evenly = $file_size % $proposed_chunk_size === 0;
$number_of_chunks_proposed = ($divides_evenly) ? $chunks : $chunks + 1;
if ($number_of_chunks_proposed > 1024) {
return (int)floor($file_size / 1024) + 1;
}
return $proposed_chunk_size;
} | [
"private",
"function",
"getTusUploadChunkSize",
"(",
"int",
"$",
"proposed_chunk_size",
",",
"int",
"$",
"file_size",
")",
":",
"int",
"{",
"$",
"proposed_chunk_size",
"=",
"(",
"$",
"proposed_chunk_size",
"<=",
"0",
")",
"?",
"1",
":",
"$",
"proposed_chunk_si... | Enforces the notion that a user may supply any `proposed_chunk_size`, as long as it results in 1024 or less
proposed chunks. In the event it does not, then the chunk size becomes the file size divided by 1024.
@param int $proposed_chunk_size
@param int $file_size
@return int | [
"Enforces",
"the",
"notion",
"that",
"a",
"user",
"may",
"supply",
"any",
"proposed_chunk_size",
"as",
"long",
"as",
"it",
"results",
"in",
"1024",
"or",
"less",
"proposed",
"chunks",
".",
"In",
"the",
"event",
"it",
"does",
"not",
"then",
"the",
"chunk",
... | 7013418ff6f2b70003d7025a29ead2c8a7704a80 | https://github.com/vimeo/vimeo.php/blob/7013418ff6f2b70003d7025a29ead2c8a7704a80/src/Vimeo/Vimeo.php#L622-L634 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Resource/Billing/Agreement.php | Adyen_Payment_Model_Resource_Billing_Agreement.addOrderRelation | public function addOrderRelation($agreementId, $orderId)
{
/*
* needed for subscription module, only available in version >= 1.8
*/
if (method_exists($this->_getWriteAdapter(), 'insertIgnore')) {
$this->_getWriteAdapter()->insertIgnore(
$this->getTable('sales/billing_agreement_order'), array(
'agreement_id' => $agreementId,
'order_id' => $orderId
)
);
} else {
// use the default insert for <= 1.7 version
// @codingStandardsIgnoreStart
try {
parent::addOrderRelation($agreementId, $orderId);
} catch (Exception $e) {
// do not log this because this is a Integrity constraint violation solved in 1.8 by insertIgnore
}
// @codingStandardsIgnoreEnd
}
return $this;
} | php | public function addOrderRelation($agreementId, $orderId)
{
/*
* needed for subscription module, only available in version >= 1.8
*/
if (method_exists($this->_getWriteAdapter(), 'insertIgnore')) {
$this->_getWriteAdapter()->insertIgnore(
$this->getTable('sales/billing_agreement_order'), array(
'agreement_id' => $agreementId,
'order_id' => $orderId
)
);
} else {
// use the default insert for <= 1.7 version
// @codingStandardsIgnoreStart
try {
parent::addOrderRelation($agreementId, $orderId);
} catch (Exception $e) {
// do not log this because this is a Integrity constraint violation solved in 1.8 by insertIgnore
}
// @codingStandardsIgnoreEnd
}
return $this;
} | [
"public",
"function",
"addOrderRelation",
"(",
"$",
"agreementId",
",",
"$",
"orderId",
")",
"{",
"/*\n * needed for subscription module, only available in version >= 1.8\n */",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"_getWriteAdapter",
"(",
")"... | Add order relation to billing agreement
@param int $agreementId
@param int $orderId
@return Mage_Sales_Model_Resource_Billing_Agreement | [
"Add",
"order",
"relation",
"to",
"billing",
"agreement"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Resource/Billing/Agreement.php#L39-L63 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/controllers/ProcessController.php | Adyen_Payment_ProcessController.successAction | public function successAction()
{
// get the response data
$response = $this->getRequest()->getParams();
// process
try {
$result = $this->validateResultUrl($response);
if ($result) {
$session = $this->_getCheckout();
$session->unsAdyenRealOrderId();
$session->setQuoteId($session->getAdyenQuoteId(true));
$session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success', array('utm_nooverride' => '1'));
} else {
$this->cancel();
}
} catch (Exception $e) {
Mage::logException($e);
throw $e;
}
} | php | public function successAction()
{
// get the response data
$response = $this->getRequest()->getParams();
// process
try {
$result = $this->validateResultUrl($response);
if ($result) {
$session = $this->_getCheckout();
$session->unsAdyenRealOrderId();
$session->setQuoteId($session->getAdyenQuoteId(true));
$session->getQuote()->setIsActive(false)->save();
$this->_redirect('checkout/onepage/success', array('utm_nooverride' => '1'));
} else {
$this->cancel();
}
} catch (Exception $e) {
Mage::logException($e);
throw $e;
}
} | [
"public",
"function",
"successAction",
"(",
")",
"{",
"// get the response data",
"$",
"response",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParams",
"(",
")",
";",
"// process",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"validateR... | Adyen returns POST variables to this action | [
"Adyen",
"returns",
"POST",
"variables",
"to",
"this",
"action"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/controllers/ProcessController.php#L278-L300 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.getMagentoCreditCartType | public function getMagentoCreditCartType($ccType)
{
$ccTypesMapper = Mage::helper('adyen')->getCcTypesAltData();
if (isset($ccTypesMapper[$ccType])) {
$ccType = $ccTypesMapper[$ccType]['code'];
}
return $ccType;
} | php | public function getMagentoCreditCartType($ccType)
{
$ccTypesMapper = Mage::helper('adyen')->getCcTypesAltData();
if (isset($ccTypesMapper[$ccType])) {
$ccType = $ccTypesMapper[$ccType]['code'];
}
return $ccType;
} | [
"public",
"function",
"getMagentoCreditCartType",
"(",
"$",
"ccType",
")",
"{",
"$",
"ccTypesMapper",
"=",
"Mage",
"::",
"helper",
"(",
"'adyen'",
")",
"->",
"getCcTypesAltData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ccTypesMapper",
"[",
"$",
"ccTy... | Creditcard type that is selected is different from creditcard type that we get back from the request this
function get the magento creditcard type this is needed for getting settings like installments
@param $ccType
@return mixed | [
"Creditcard",
"type",
"that",
"is",
"selected",
"is",
"different",
"from",
"creditcard",
"type",
"that",
"we",
"get",
"back",
"from",
"the",
"request",
"this",
"function",
"get",
"the",
"magento",
"creditcard",
"type",
"this",
"is",
"needed",
"for",
"getting",... | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L232-L242 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.getClientIp | public function getClientIp()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
} elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ipaddress = $_SERVER['REMOTE_ADDR'];
} else {
$ipaddress = '';
}
return $ipaddress;
} | php | public function getClientIp()
{
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
} elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
} elseif (isset($_SERVER['HTTP_FORWARDED'])) {
$ipaddress = $_SERVER['HTTP_FORWARDED'];
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ipaddress = $_SERVER['REMOTE_ADDR'];
} else {
$ipaddress = '';
}
return $ipaddress;
} | [
"public",
"function",
"getClientIp",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
")",
")",
"{",
"$",
"ipaddress",
"=",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
... | Get the client ip address
@return string | [
"Get",
"the",
"client",
"ip",
"address"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L342-L361 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.formatStreet | protected function formatStreet($street, $klarna)
{
$formatStreetOnMultiStreetLines = false;
/*
* If ignore second line steet is enabled for klarna only look at the first addressfield
* and try to substract housenumber
*/
if ($klarna) {
if ($this->getConfigData('ignore_second_address_field', 'adyen_openinvoice')) {
$formatStreetOnMultiStreetLines = true;
}
}
if (!$formatStreetOnMultiStreetLines && count($street) != 1) {
return $street;
}
preg_match('/\s(\d+.*)$/i', $street['0'], $houseNumber, PREG_OFFSET_CAPTURE);
if (!empty($houseNumber['0'])) {
$_houseNumber = trim($houseNumber['0']['0']);
$position = $houseNumber['0']['1'];
$streeName = trim(substr($street['0'], 0, $position));
$street = array($streeName, $_houseNumber);
}
return $street;
} | php | protected function formatStreet($street, $klarna)
{
$formatStreetOnMultiStreetLines = false;
/*
* If ignore second line steet is enabled for klarna only look at the first addressfield
* and try to substract housenumber
*/
if ($klarna) {
if ($this->getConfigData('ignore_second_address_field', 'adyen_openinvoice')) {
$formatStreetOnMultiStreetLines = true;
}
}
if (!$formatStreetOnMultiStreetLines && count($street) != 1) {
return $street;
}
preg_match('/\s(\d+.*)$/i', $street['0'], $houseNumber, PREG_OFFSET_CAPTURE);
if (!empty($houseNumber['0'])) {
$_houseNumber = trim($houseNumber['0']['0']);
$position = $houseNumber['0']['1'];
$streeName = trim(substr($street['0'], 0, $position));
$street = array($streeName, $_houseNumber);
}
return $street;
} | [
"protected",
"function",
"formatStreet",
"(",
"$",
"street",
",",
"$",
"klarna",
")",
"{",
"$",
"formatStreetOnMultiStreetLines",
"=",
"false",
";",
"/*\n * If ignore second line steet is enabled for klarna only look at the first addressfield\n * and try to substract ... | Fix this one string street + number
@example street + number
@param type $street
@return type $street | [
"Fix",
"this",
"one",
"string",
"street",
"+",
"number"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L431-L458 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.isOpenInvoice | public function isOpenInvoice($paymentMethod)
{
if ($this->isKlarna($paymentMethod) ||
strcmp($paymentMethod, self::RATEPAY) === 0 ||
$this->isAfterPay($paymentMethod)) {
return true;
}
return false;
} | php | public function isOpenInvoice($paymentMethod)
{
if ($this->isKlarna($paymentMethod) ||
strcmp($paymentMethod, self::RATEPAY) === 0 ||
$this->isAfterPay($paymentMethod)) {
return true;
}
return false;
} | [
"public",
"function",
"isOpenInvoice",
"(",
"$",
"paymentMethod",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isKlarna",
"(",
"$",
"paymentMethod",
")",
"||",
"strcmp",
"(",
"$",
"paymentMethod",
",",
"self",
"::",
"RATEPAY",
")",
"===",
"0",
"||",
"$",
"... | Identifiy if payment method is an openinvoice payment method
@param $paymentMethod
@return bool | [
"Identifiy",
"if",
"payment",
"method",
"is",
"an",
"openinvoice",
"payment",
"method"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L525-L534 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.getSession | public function getSession()
{
if (Mage::app()->getStore()->isAdmin()) {
$session = Mage::getSingleton('adminhtml/session_quote');
} else {
$session = Mage::getSingleton('checkout/session');
}
return $session;
} | php | public function getSession()
{
if (Mage::app()->getStore()->isAdmin()) {
$session = Mage::getSingleton('adminhtml/session_quote');
} else {
$session = Mage::getSingleton('checkout/session');
}
return $session;
} | [
"public",
"function",
"getSession",
"(",
")",
"{",
"if",
"(",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"isAdmin",
"(",
")",
")",
"{",
"$",
"session",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'adminhtml/session_quote'",
")",
";",... | Defines if it need to use the admin session or checkout session
@return mixed | [
"Defines",
"if",
"it",
"need",
"to",
"use",
"the",
"admin",
"session",
"or",
"checkout",
"session"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L569-L578 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.getAdyenMerchantAccount | public function getAdyenMerchantAccount($paymentMethod, $storeId = null)
{
$merchantAccount = trim($this->getConfigData('merchantAccount', 'adyen_abstract', $storeId));
$merchantAccountPos = trim($this->getConfigData('pos_merchant_account', 'adyen_pos_cloud', $storeId));
if ($paymentMethod == 'pos_cloud' && !empty($merchantAccountPos)) {
return $merchantAccountPos;
}
return $merchantAccount;
} | php | public function getAdyenMerchantAccount($paymentMethod, $storeId = null)
{
$merchantAccount = trim($this->getConfigData('merchantAccount', 'adyen_abstract', $storeId));
$merchantAccountPos = trim($this->getConfigData('pos_merchant_account', 'adyen_pos_cloud', $storeId));
if ($paymentMethod == 'pos_cloud' && !empty($merchantAccountPos)) {
return $merchantAccountPos;
}
return $merchantAccount;
} | [
"public",
"function",
"getAdyenMerchantAccount",
"(",
"$",
"paymentMethod",
",",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"merchantAccount",
"=",
"trim",
"(",
"$",
"this",
"->",
"getConfigData",
"(",
"'merchantAccount'",
",",
"'adyen_abstract'",
",",
"$",
"... | Return the merchant account name configured for the proper payment method.
If it is not configured for the specific payment method,
return the merchant account name defined in required settings.
@param $paymentMethod
@param int|null $storeId
@return string | [
"Return",
"the",
"merchant",
"account",
"name",
"configured",
"for",
"the",
"proper",
"payment",
"method",
".",
"If",
"it",
"is",
"not",
"configured",
"for",
"the",
"specific",
"payment",
"method",
"return",
"the",
"merchant",
"account",
"name",
"defined",
"in... | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L619-L628 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Data.php | Adyen_Payment_Helper_Data.formatTerminalAPIReceipt | public function formatTerminalAPIReceipt($paymentReceipt)
{
$formattedHtml = "<table class='terminal-api-receipt'>";
foreach ($paymentReceipt as $receipt) {
if ($receipt['DocumentQualifier'] == "CustomerReceipt") {
foreach ($receipt['OutputContent']['OutputText'] as $item) {
parse_str($item['Text'], $textParts);
$formattedHtml .= "<tr class='terminal-api-receipt'>";
if (!empty($textParts['name'])) {
$formattedHtml .= "<td class='terminal-api-receipt-name'>" . $textParts['name'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-name'> </td>";
}
if (!empty($textParts['value'])) {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>" . $textParts['value'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'> </td>";
}
$formattedHtml .= "</tr>";
}
}
}
$formattedHtml .= "</table>";
return $formattedHtml;
} | php | public function formatTerminalAPIReceipt($paymentReceipt)
{
$formattedHtml = "<table class='terminal-api-receipt'>";
foreach ($paymentReceipt as $receipt) {
if ($receipt['DocumentQualifier'] == "CustomerReceipt") {
foreach ($receipt['OutputContent']['OutputText'] as $item) {
parse_str($item['Text'], $textParts);
$formattedHtml .= "<tr class='terminal-api-receipt'>";
if (!empty($textParts['name'])) {
$formattedHtml .= "<td class='terminal-api-receipt-name'>" . $textParts['name'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-name'> </td>";
}
if (!empty($textParts['value'])) {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'>" . $textParts['value'] . "</td>";
} else {
$formattedHtml .= "<td class='terminal-api-receipt-value' align='right'> </td>";
}
$formattedHtml .= "</tr>";
}
}
}
$formattedHtml .= "</table>";
return $formattedHtml;
} | [
"public",
"function",
"formatTerminalAPIReceipt",
"(",
"$",
"paymentReceipt",
")",
"{",
"$",
"formattedHtml",
"=",
"\"<table class='terminal-api-receipt'>\"",
";",
"foreach",
"(",
"$",
"paymentReceipt",
"as",
"$",
"receipt",
")",
"{",
"if",
"(",
"$",
"receipt",
"[... | Format the Receipt sent in the Terminal API response in HTML
so that it can be easily shown to the shopper
@param $paymentReceipt
@return string | [
"Format",
"the",
"Receipt",
"sent",
"in",
"the",
"Terminal",
"API",
"response",
"in",
"HTML",
"so",
"that",
"it",
"can",
"be",
"easily",
"shown",
"to",
"the",
"shopper"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Data.php#L637-L664 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.authorize | public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
/** @var Mage_Sales_Model_Order $order */
$order = $payment->getOrder();
$amount = $order->getGrandTotal();
// check if a zero auth should be done for this order
$useZeroAuth = (bool)Mage::helper('adyen')->getConfigData('use_zero_auth', null, $order->getStoreId());
$zeroAuthDateField = Mage::helper('adyen')->getConfigData(
'base_zero_auth_on_date', null,
$order->getStoreId()
);
if ($useZeroAuth) { // zero auth should be used
// only orders that are scheduled to be captured later than
// the auth valid period use zero auth
// the period is 7 days since this works for most payment methods
$scheduledDate = strtotime($order->getData($zeroAuthDateField));
if ($scheduledDate > strtotime("+7 days")) { // scheduled date is higher than now + 7 days
$amount = 0; // set amount to 0 for zero auth
}
}
/*
* ReserveOrderId for this quote so payment failed notification
* does not interfere with new successful orders
*/
$incrementId = $order->getIncrementId();
$quoteId = $order->getQuoteId();
$quote = Mage::getModel('sales/quote')
->load($quoteId)
->setReservedOrderId($incrementId)
->save();
// by zero authentication payment is authorised when api responds is succesfull
if ($order->getGrandTotal() == 0) {
$payment->setIsTransactionPending(false);
}
/*
* Do not send a email notification when order is created.
* Only do this on the AUHTORISATION notification.
* For Boleto and Multibanco send it on order creation
*/
if (!in_array($this->getCode(), array('adyen_boleto', 'adyen_multibanco'))) {
$order->setCanSendNewEmailFlag(false);
}
if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || substr(
$this->getCode(), 0,
14
) == 'adyen_oneclick' || $this->getCode() == 'adyen_sepa' || $this->getCode() == 'adyen_apple_pay' || $this->getCode() == 'adyen_multibanco') {
if (substr($this->getCode(), 0, 14) == 'adyen_oneclick') {
// set payment method to adyen_oneclick otherwise backend can not view the order
$payment->setMethod("adyen_oneclick");
$recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
// load agreement based on reference_id (option to add an index on reference_id in database)
$agreement = Mage::getModel('sales/billing_agreement')->load($recurringDetailReference, 'reference_id');
// agreement could be a empty object
if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
$agreement->addOrderRelation($order);
$agreement->setIsObjectChanged(true);
$order->addRelatedObject($agreement);
$message = Mage::helper('adyen')->__(
'Used existing billing agreement #%s.',
$agreement->getReferenceId()
);
$comment = $order->addStatusHistoryComment($message);
$order->addRelatedObject($comment);
}
}
$_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
}
return $this;
} | php | public function authorize(Varien_Object $payment, $amount)
{
parent::authorize($payment, $amount);
$payment->setLastTransId($this->getTransactionId())->setIsTransactionPending(true);
/** @var Mage_Sales_Model_Order $order */
$order = $payment->getOrder();
$amount = $order->getGrandTotal();
// check if a zero auth should be done for this order
$useZeroAuth = (bool)Mage::helper('adyen')->getConfigData('use_zero_auth', null, $order->getStoreId());
$zeroAuthDateField = Mage::helper('adyen')->getConfigData(
'base_zero_auth_on_date', null,
$order->getStoreId()
);
if ($useZeroAuth) { // zero auth should be used
// only orders that are scheduled to be captured later than
// the auth valid period use zero auth
// the period is 7 days since this works for most payment methods
$scheduledDate = strtotime($order->getData($zeroAuthDateField));
if ($scheduledDate > strtotime("+7 days")) { // scheduled date is higher than now + 7 days
$amount = 0; // set amount to 0 for zero auth
}
}
/*
* ReserveOrderId for this quote so payment failed notification
* does not interfere with new successful orders
*/
$incrementId = $order->getIncrementId();
$quoteId = $order->getQuoteId();
$quote = Mage::getModel('sales/quote')
->load($quoteId)
->setReservedOrderId($incrementId)
->save();
// by zero authentication payment is authorised when api responds is succesfull
if ($order->getGrandTotal() == 0) {
$payment->setIsTransactionPending(false);
}
/*
* Do not send a email notification when order is created.
* Only do this on the AUHTORISATION notification.
* For Boleto and Multibanco send it on order creation
*/
if (!in_array($this->getCode(), array('adyen_boleto', 'adyen_multibanco'))) {
$order->setCanSendNewEmailFlag(false);
}
if ($this->getCode() == 'adyen_boleto' || $this->getCode() == 'adyen_cc' || substr(
$this->getCode(), 0,
14
) == 'adyen_oneclick' || $this->getCode() == 'adyen_sepa' || $this->getCode() == 'adyen_apple_pay' || $this->getCode() == 'adyen_multibanco') {
if (substr($this->getCode(), 0, 14) == 'adyen_oneclick') {
// set payment method to adyen_oneclick otherwise backend can not view the order
$payment->setMethod("adyen_oneclick");
$recurringDetailReference = $payment->getAdditionalInformation("recurring_detail_reference");
// load agreement based on reference_id (option to add an index on reference_id in database)
$agreement = Mage::getModel('sales/billing_agreement')->load($recurringDetailReference, 'reference_id');
// agreement could be a empty object
if ($agreement && $agreement->getAgreementId() > 0 && $agreement->isValid()) {
$agreement->addOrderRelation($order);
$agreement->setIsObjectChanged(true);
$order->addRelatedObject($agreement);
$message = Mage::helper('adyen')->__(
'Used existing billing agreement #%s.',
$agreement->getReferenceId()
);
$comment = $order->addStatusHistoryComment($message);
$order->addRelatedObject($comment);
}
}
$_authorizeResponse = $this->_processRequest($payment, $amount, "authorise");
}
return $this;
} | [
"public",
"function",
"authorize",
"(",
"Varien_Object",
"$",
"payment",
",",
"$",
"amount",
")",
"{",
"parent",
"::",
"authorize",
"(",
"$",
"payment",
",",
"$",
"amount",
")",
";",
"$",
"payment",
"->",
"setLastTransId",
"(",
"$",
"this",
"->",
"getTra... | In the backend it means Authorize only
@param Varien_Object $payment
@param $amount
@return $this | [
"In",
"the",
"backend",
"it",
"means",
"Authorize",
"only"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L229-L312 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.capture | public function capture(Varien_Object $payment, $amount)
{
parent::capture($payment, $amount);
$payment->setStatus(self::STATUS_APPROVED)
->setTransactionId($this->getTransactionId())
->setIsTransactionClosed(0);
$order = $payment->getOrder();
$currency = $order->getOrderCurrencyCode();
if ($payment->hasCurrentInvoice() && $currency != $order->getBaseCurrencyCode()) {
$invoice = $payment->getCurrentInvoice();
$amount = $invoice->getGrandTotal();
}
// do capture request to adyen
$order = $payment->getOrder();
$pspReference = Mage::getModel('adyen/event')->getOriginalPspReference($order->getIncrementId());
$order->getPayment()->getMethodInstance()->sendCaptureRequest($payment, $amount, $pspReference);
return $this;
} | php | public function capture(Varien_Object $payment, $amount)
{
parent::capture($payment, $amount);
$payment->setStatus(self::STATUS_APPROVED)
->setTransactionId($this->getTransactionId())
->setIsTransactionClosed(0);
$order = $payment->getOrder();
$currency = $order->getOrderCurrencyCode();
if ($payment->hasCurrentInvoice() && $currency != $order->getBaseCurrencyCode()) {
$invoice = $payment->getCurrentInvoice();
$amount = $invoice->getGrandTotal();
}
// do capture request to adyen
$order = $payment->getOrder();
$pspReference = Mage::getModel('adyen/event')->getOriginalPspReference($order->getIncrementId());
$order->getPayment()->getMethodInstance()->sendCaptureRequest($payment, $amount, $pspReference);
return $this;
} | [
"public",
"function",
"capture",
"(",
"Varien_Object",
"$",
"payment",
",",
"$",
"amount",
")",
"{",
"parent",
"::",
"capture",
"(",
"$",
"payment",
",",
"$",
"amount",
")",
";",
"$",
"payment",
"->",
"setStatus",
"(",
"self",
"::",
"STATUS_APPROVED",
")... | In backend it means Authorize && Capture
@param $payment
@param $amount | [
"In",
"backend",
"it",
"means",
"Authorize",
"&&",
"Capture"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L319-L339 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.getAccountData | public function getAccountData($storeId = null)
{
$url = $this->_getAdyenUrls($storeId);
$wsUsername = $this->getConfigDataWsUserName($storeId);
$wsPassword = $this->getConfigDataWsPassword($storeId);
$account = array(
'url' => $url,
'login' => $wsUsername,
'password' => $wsPassword
);
return $account;
} | php | public function getAccountData($storeId = null)
{
$url = $this->_getAdyenUrls($storeId);
$wsUsername = $this->getConfigDataWsUserName($storeId);
$wsPassword = $this->getConfigDataWsPassword($storeId);
$account = array(
'url' => $url,
'login' => $wsUsername,
'password' => $wsPassword
);
return $account;
} | [
"public",
"function",
"getAccountData",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_getAdyenUrls",
"(",
"$",
"storeId",
")",
";",
"$",
"wsUsername",
"=",
"$",
"this",
"->",
"getConfigDataWsUserName",
"(",
"$",
"store... | Adyen User Account Data | [
"Adyen",
"User",
"Account",
"Data"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L830-L841 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.isAvailable | public function isAvailable($quote = null)
{
if (!parent::isAvailable($quote)) {
return false;
}
if (!is_null($quote)) {
if ($this->_getConfigData('allowspecific', $this->_code)) {
$country = $quote->getShippingAddress()->getCountry();
$availableCountries = explode(',', $this->_getConfigData('specificcountry', $this->_code));
if (!in_array($country, $availableCountries)) {
return false;
}
}
}
return true;
} | php | public function isAvailable($quote = null)
{
if (!parent::isAvailable($quote)) {
return false;
}
if (!is_null($quote)) {
if ($this->_getConfigData('allowspecific', $this->_code)) {
$country = $quote->getShippingAddress()->getCountry();
$availableCountries = explode(',', $this->_getConfigData('specificcountry', $this->_code));
if (!in_array($country, $availableCountries)) {
return false;
}
}
}
return true;
} | [
"public",
"function",
"isAvailable",
"(",
"$",
"quote",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"parent",
"::",
"isAvailable",
"(",
"$",
"quote",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"quote",
")",
")",
"... | Return true if the method can be used at this time
@since 0.1.0.3r1
@return bool | [
"Return",
"true",
"if",
"the",
"method",
"can",
"be",
"used",
"at",
"this",
"time"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L920-L937 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.getConfigDataDemoMode | public function getConfigDataDemoMode($storeId = null)
{
if ($storeId == null && Mage::app()->getStore()->isAdmin()) {
$storeId = $this->getInfoInstance()->getOrder()->getStoreId();
}
return Mage::helper('adyen')->getConfigDataDemoMode($storeId);
} | php | public function getConfigDataDemoMode($storeId = null)
{
if ($storeId == null && Mage::app()->getStore()->isAdmin()) {
$storeId = $this->getInfoInstance()->getOrder()->getStoreId();
}
return Mage::helper('adyen')->getConfigDataDemoMode($storeId);
} | [
"public",
"function",
"getConfigDataDemoMode",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"storeId",
"==",
"null",
"&&",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"isAdmin",
"(",
")",
")",
"{",
"$",
"storeId",
... | Used via Payment method.Notice via configuration ofcourse Y or N
@return boolean true on demo, else false | [
"Used",
"via",
"Payment",
"method",
".",
"Notice",
"via",
"configuration",
"ofcourse",
"Y",
"or",
"N"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L954-L961 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.updateBillingAgreementStatus | public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
{
Mage::dispatchEvent('adyen_payment_update_billing_agreement_status', array('agreement' => $agreement));
$targetStatus = $agreement->getStatus();
$adyenHelper = Mage::helper('adyen');
if ($targetStatus == Mage_Sales_Model_Billing_Agreement::STATUS_CANCELED) {
try {
$this->_api()->disableRecurringContract(
$agreement->getReferenceId(),
$agreement->getCustomerReference(),
$agreement->getStoreId()
);
} catch (Adyen_Payment_Exception $e) {
Mage::throwException(
$adyenHelper->__(
"Error while disabling Billing Agreement #%s: %s", $agreement->getReferenceId(),
$e->getMessage()
)
);
}
} else {
throw new Exception(
Mage::helper('adyen')->__(
'Changing billing agreement status to "%s" not yet implemented.', $targetStatus
)
);
}
return $this;
} | php | public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
{
Mage::dispatchEvent('adyen_payment_update_billing_agreement_status', array('agreement' => $agreement));
$targetStatus = $agreement->getStatus();
$adyenHelper = Mage::helper('adyen');
if ($targetStatus == Mage_Sales_Model_Billing_Agreement::STATUS_CANCELED) {
try {
$this->_api()->disableRecurringContract(
$agreement->getReferenceId(),
$agreement->getCustomerReference(),
$agreement->getStoreId()
);
} catch (Adyen_Payment_Exception $e) {
Mage::throwException(
$adyenHelper->__(
"Error while disabling Billing Agreement #%s: %s", $agreement->getReferenceId(),
$e->getMessage()
)
);
}
} else {
throw new Exception(
Mage::helper('adyen')->__(
'Changing billing agreement status to "%s" not yet implemented.', $targetStatus
)
);
}
return $this;
} | [
"public",
"function",
"updateBillingAgreementStatus",
"(",
"Mage_Payment_Model_Billing_AgreementAbstract",
"$",
"agreement",
")",
"{",
"Mage",
"::",
"dispatchEvent",
"(",
"'adyen_payment_update_billing_agreement_status'",
",",
"array",
"(",
"'agreement'",
"=>",
"$",
"agreemen... | Update billing agreement status
@param Adyen_Payment_Model_Billing_Agreement|Mage_Payment_Model_Billing_AgreementAbstract $agreement
@return $this
@throws Exception
@throws Mage_Core_Exception | [
"Update",
"billing",
"agreement",
"status"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L1070-L1101 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Abstract.php | Adyen_Payment_Model_Adyen_Abstract.getBillingAgreementTokenInfo | public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
{
$recurringContractDetail = $this->_api()->getRecurringContractDetail(
$agreement->getCustomerReference(),
$agreement->getReferenceId()
);
if (!$recurringContractDetail) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'The recurring contract (%s) could not be retrieved', $agreement->getReferenceId()
)
);
}
$agreement->parseRecurringContractData($recurringContractDetail);
return $recurringContractDetail;
} | php | public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
{
$recurringContractDetail = $this->_api()->getRecurringContractDetail(
$agreement->getCustomerReference(),
$agreement->getReferenceId()
);
if (!$recurringContractDetail) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'The recurring contract (%s) could not be retrieved', $agreement->getReferenceId()
)
);
}
$agreement->parseRecurringContractData($recurringContractDetail);
return $recurringContractDetail;
} | [
"public",
"function",
"getBillingAgreementTokenInfo",
"(",
"Mage_Payment_Model_Billing_AgreementAbstract",
"$",
"agreement",
")",
"{",
"$",
"recurringContractDetail",
"=",
"$",
"this",
"->",
"_api",
"(",
")",
"->",
"getRecurringContractDetail",
"(",
"$",
"agreement",
"-... | Retrieve billing agreement customer details by token
@param Adyen_Payment_Model_Billing_Agreement|Mage_Payment_Model_Billing_AgreementAbstract $agreement
@return array | [
"Retrieve",
"billing",
"agreement",
"customer",
"details",
"by",
"token"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Abstract.php#L1110-L1128 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php | Adyen_Fee_Block_Adminhtml_Sales_Order_Creditmemo_Create_Adjustments.initTotals | public function initTotals()
{
$parent = $this->getParentBlock();
$this->_source = $parent->getSource();
$total = new Varien_Object(
array(
'code' => 'adjust_adyen_fee_payment_fee',
'block_name' => $this->getNameInLayout()
)
);
// remove totals because you only want to show editable field
$parent->removeTotal('payment_fee_excl');
$parent->removeTotal('payment_fee_incl');
$parent->addTotalBefore($total, 'agjustments'); // Yes, misspelled in Magento Core
return $this;
} | php | public function initTotals()
{
$parent = $this->getParentBlock();
$this->_source = $parent->getSource();
$total = new Varien_Object(
array(
'code' => 'adjust_adyen_fee_payment_fee',
'block_name' => $this->getNameInLayout()
)
);
// remove totals because you only want to show editable field
$parent->removeTotal('payment_fee_excl');
$parent->removeTotal('payment_fee_incl');
$parent->addTotalBefore($total, 'agjustments'); // Yes, misspelled in Magento Core
return $this;
} | [
"public",
"function",
"initTotals",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParentBlock",
"(",
")",
";",
"$",
"this",
"->",
"_source",
"=",
"$",
"parent",
"->",
"getSource",
"(",
")",
";",
"$",
"total",
"=",
"new",
"Varien_Object",
... | Initialize creditmemo agjustment totals
@return Mage_Tax_Block_Sales_Order_Tax | [
"Initialize",
"creditmemo",
"agjustment",
"totals"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php#L38-L55 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php | Adyen_Fee_Block_Adminhtml_Sales_Order_Creditmemo_Create_Adjustments.geAdyenPaymentInvoiceFeeAmount | public function geAdyenPaymentInvoiceFeeAmount()
{
$fee = null;
$creditmemo = $this->getSource();
if ($creditmemo) {
if ($creditmemo->getPaymentFeeAmount() !== null) {
$source = $this->getSource();
$taxConfig = Mage::getSingleton('adyen_fee/tax_config');
if ($taxConfig->displaySalesPaymentFeeInclTax($source->getOrder()->getStoreId())) {
$fee = $creditmemo->getPaymentFeeAmount() + $creditmemo->getPaymentFeeTax();
} else {
$fee = $creditmemo->getPaymentFeeAmount();
}
$fee = Mage::app()->getStore()->roundPrice($fee);
}
}
return $fee;
} | php | public function geAdyenPaymentInvoiceFeeAmount()
{
$fee = null;
$creditmemo = $this->getSource();
if ($creditmemo) {
if ($creditmemo->getPaymentFeeAmount() !== null) {
$source = $this->getSource();
$taxConfig = Mage::getSingleton('adyen_fee/tax_config');
if ($taxConfig->displaySalesPaymentFeeInclTax($source->getOrder()->getStoreId())) {
$fee = $creditmemo->getPaymentFeeAmount() + $creditmemo->getPaymentFeeTax();
} else {
$fee = $creditmemo->getPaymentFeeAmount();
}
$fee = Mage::app()->getStore()->roundPrice($fee);
}
}
return $fee;
} | [
"public",
"function",
"geAdyenPaymentInvoiceFeeAmount",
"(",
")",
"{",
"$",
"fee",
"=",
"null",
";",
"$",
"creditmemo",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
";",
"if",
"(",
"$",
"creditmemo",
")",
"{",
"if",
"(",
"$",
"creditmemo",
"->",
"get... | Get credit memo shipping amount depend on configuration settings
@return float | [
"Get",
"credit",
"memo",
"shipping",
"amount",
"depend",
"on",
"configuration",
"settings"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php#L66-L86 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php | Adyen_Fee_Block_Adminhtml_Sales_Order_Creditmemo_Create_Adjustments.getAdyenPaymentFeeInvoiceFeeLabel | public function getAdyenPaymentFeeInvoiceFeeLabel()
{
$taxConfig = Mage::getSingleton('adyen_fee/tax_config');
$source = $this->getSource();
if ($taxConfig->displaySalesPaymentFeeInclTax($source->getOrder()->getStoreId())) {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee (Incl.Tax)');
} elseif ($taxConfig->displaySalesPaymentFeeBoth($source->getOrder()->getStoreId())) {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee (Excl.Tax)');
} else {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee ');
}
return $label;
} | php | public function getAdyenPaymentFeeInvoiceFeeLabel()
{
$taxConfig = Mage::getSingleton('adyen_fee/tax_config');
$source = $this->getSource();
if ($taxConfig->displaySalesPaymentFeeInclTax($source->getOrder()->getStoreId())) {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee (Incl.Tax)');
} elseif ($taxConfig->displaySalesPaymentFeeBoth($source->getOrder()->getStoreId())) {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee (Excl.Tax)');
} else {
$label = $this->helper('adyen')->__('Refund') . " " . $this->helper('adyen')->__('Payment Fee ');
}
return $label;
} | [
"public",
"function",
"getAdyenPaymentFeeInvoiceFeeLabel",
"(",
")",
"{",
"$",
"taxConfig",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'adyen_fee/tax_config'",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"getSource",
"(",
")",
";",
"if",
"(",
"$",
"taxCon... | Get label for shipping total based on configuration settings
@return string | [
"Get",
"label",
"for",
"shipping",
"total",
"based",
"on",
"configuration",
"settings"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Creditmemo/Create/Adjustments.php#L92-L106 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/Form/Field/Installments.php | Adyen_Payment_Block_Adminhtml_Form_Field_Installments._prepareToRender | protected function _prepareToRender()
{
$this->addColumn(
'installment_currency', array(
'label' => Mage::helper('adyen')->__('Currency'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_boundary', array(
'label' => Mage::helper('adyen')->__('Amount (incl.)'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_frequency', array(
'label' => Mage::helper('adyen')->__('Maximum Number of Installments'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_interest', array(
'label' => Mage::helper('adyen')->__('Interest Rate (%)'),
'style' => 'width:100px',
)
);
$this->_addAfter = false;
$this->_addButtonLabel = Mage::helper('adyen')->__('Add Installment Boundary');
} | php | protected function _prepareToRender()
{
$this->addColumn(
'installment_currency', array(
'label' => Mage::helper('adyen')->__('Currency'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_boundary', array(
'label' => Mage::helper('adyen')->__('Amount (incl.)'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_frequency', array(
'label' => Mage::helper('adyen')->__('Maximum Number of Installments'),
'style' => 'width:100px',
)
);
$this->addColumn(
'installment_interest', array(
'label' => Mage::helper('adyen')->__('Interest Rate (%)'),
'style' => 'width:100px',
)
);
$this->_addAfter = false;
$this->_addButtonLabel = Mage::helper('adyen')->__('Add Installment Boundary');
} | [
"protected",
"function",
"_prepareToRender",
"(",
")",
"{",
"$",
"this",
"->",
"addColumn",
"(",
"'installment_currency'",
",",
"array",
"(",
"'label'",
"=>",
"Mage",
"::",
"helper",
"(",
"'adyen'",
")",
"->",
"__",
"(",
"'Currency'",
")",
",",
"'style'",
... | Prepare to render | [
"Prepare",
"to",
"render"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/Form/Field/Installments.php#L43-L71 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Authenticate.php | Adyen_Payment_Model_Authenticate.fixCgiHttpAuthentication | public function fixCgiHttpAuthentication()
{
// unsupported is $_SERVER['REMOfixCgiHttpAuthenticationTE_AUTHORIZATION']: as stated in manual :p
// do nothing if values are already there
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
return;
} else {
if (isset($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']) && $_SERVER['REDIRECT_REMOTE_AUTHORIZATION'] != '') { //pcd note: no idea who sets this
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']), 2
);
} elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) { //pcd note: standard in magento?
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)), 2
);
} elseif (!empty($_SERVER['REMOTE_USER'])) { //pcd note: when cgi and .htaccess modrewrite patch is executed
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['REMOTE_USER'], 6)), 2
);
} elseif (!empty($_SERVER['REDIRECT_REMOTE_USER'])) { //pcd note: no idea who sets this
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)), 2
);
}
}
} | php | public function fixCgiHttpAuthentication()
{
// unsupported is $_SERVER['REMOfixCgiHttpAuthenticationTE_AUTHORIZATION']: as stated in manual :p
// do nothing if values are already there
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
return;
} else {
if (isset($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']) && $_SERVER['REDIRECT_REMOTE_AUTHORIZATION'] != '') { //pcd note: no idea who sets this
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode($_SERVER['REDIRECT_REMOTE_AUTHORIZATION']), 2
);
} elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) { //pcd note: standard in magento?
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)), 2
);
} elseif (!empty($_SERVER['REMOTE_USER'])) { //pcd note: when cgi and .htaccess modrewrite patch is executed
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['REMOTE_USER'], 6)), 2
);
} elseif (!empty($_SERVER['REDIRECT_REMOTE_USER'])) { //pcd note: no idea who sets this
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(
':',
base64_decode(substr($_SERVER['REDIRECT_REMOTE_USER'], 6)), 2
);
}
}
} | [
"public",
"function",
"fixCgiHttpAuthentication",
"(",
")",
"{",
"// unsupported is $_SERVER['REMOfixCgiHttpAuthenticationTE_AUTHORIZATION']: as stated in manual :p",
"// do nothing if values are already there",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_USER'",
... | Fix these global variables for the CGI if needed | [
"Fix",
"these",
"global",
"variables",
"for",
"the",
"CGI",
"if",
"needed"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Authenticate.php#L208-L238 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Method.php | Adyen_Payment_Block_Adminhtml_System_Config_Fieldset_Method._isPaymentEnabled | protected function _isPaymentEnabled($element)
{
$groupConfig = $this->getGroup($element)->asArray();
$activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : '';
if (empty($activityPath)) {
return false;
}
// for ideal look at adyen HPP configuration
if ($activityPath == "payment/adyen_ideal/active") {
$activityPath = "payment/adyen_hpp/active";
}
$isPaymentEnabled = (bool)(string)$this->_getConfigDataModel()->getConfigDataValue($activityPath);
return (bool)$isPaymentEnabled;
} | php | protected function _isPaymentEnabled($element)
{
$groupConfig = $this->getGroup($element)->asArray();
$activityPath = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : '';
if (empty($activityPath)) {
return false;
}
// for ideal look at adyen HPP configuration
if ($activityPath == "payment/adyen_ideal/active") {
$activityPath = "payment/adyen_hpp/active";
}
$isPaymentEnabled = (bool)(string)$this->_getConfigDataModel()->getConfigDataValue($activityPath);
return (bool)$isPaymentEnabled;
} | [
"protected",
"function",
"_isPaymentEnabled",
"(",
"$",
"element",
")",
"{",
"$",
"groupConfig",
"=",
"$",
"this",
"->",
"getGroup",
"(",
"$",
"element",
")",
"->",
"asArray",
"(",
")",
";",
"$",
"activityPath",
"=",
"isset",
"(",
"$",
"groupConfig",
"["... | Check whether current payment method is enabled
@param Varien_Data_Form_Element_Abstract $element
@param callback|null $configCallback
@return bool | [
"Check",
"whether",
"current",
"payment",
"method",
"is",
"enabled"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Method.php#L38-L55 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Method.php | Adyen_Payment_Block_Adminhtml_System_Config_Fieldset_Method._getHeaderTitleHtml | protected function _getHeaderTitleHtml($element)
{
$html = '<div class="entry-edit-head collapseable" ><a id="' . $element->getHtmlId()
. '-head" href="#" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \''
. $this->getUrl('*/*/state') . '\'); return false;">';
$html .= ' <img src="' . $this->getSkinUrl('images/adyen/logo.png') . '" height="20" style="vertical-align: text-bottom; margin-right: 5px;"/> ';
$html .= $element->getLegend();
if ($this->_isPaymentEnabled($element)) {
$html .= ' <img src="' . $this->getSkinUrl('images/icon-enabled.png') . '" style="vertical-align: middle"/> ';
}
$html .= '</a></div>';
return $html;
} | php | protected function _getHeaderTitleHtml($element)
{
$html = '<div class="entry-edit-head collapseable" ><a id="' . $element->getHtmlId()
. '-head" href="#" onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \''
. $this->getUrl('*/*/state') . '\'); return false;">';
$html .= ' <img src="' . $this->getSkinUrl('images/adyen/logo.png') . '" height="20" style="vertical-align: text-bottom; margin-right: 5px;"/> ';
$html .= $element->getLegend();
if ($this->_isPaymentEnabled($element)) {
$html .= ' <img src="' . $this->getSkinUrl('images/icon-enabled.png') . '" style="vertical-align: middle"/> ';
}
$html .= '</a></div>';
return $html;
} | [
"protected",
"function",
"_getHeaderTitleHtml",
"(",
"$",
"element",
")",
"{",
"$",
"html",
"=",
"'<div class=\"entry-edit-head collapseable\" ><a id=\"'",
".",
"$",
"element",
"->",
"getHtmlId",
"(",
")",
".",
"'-head\" href=\"#\" onclick=\"Fieldset.toggleCollapse(\\''",
"... | Return header title part of html for payment solution
@param Varien_Data_Form_Element_Abstract $element
@return string | [
"Return",
"header",
"title",
"part",
"of",
"html",
"for",
"payment",
"solution"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Method.php#L63-L77 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api.listRecurringContracts | public function listRecurringContracts($shopperReference, $store = null)
{
$recurringContracts = array();
foreach ($this->_recurringTypes as $recurringType) {
try {
// merge ONECLICK and RECURRING into one record with recurringType ONECLICK,RECURRING
$listRecurringContractByType = $this->listRecurringContractByType(
$shopperReference, $store,
$recurringType
);
foreach ($listRecurringContractByType as $recurringContract) {
if (isset($recurringContract['recurringDetailReference'])) {
$recurringDetailReference = $recurringContract['recurringDetailReference'];
// check if recurring reference is already in array
if (isset($recurringContracts[$recurringDetailReference])) {
// recurring reference already exists so recurringType is possible for ONECLICK and RECURRING
$recurringContracts[$recurringDetailReference]['recurring_type'] = self::RECURRING_TYPE_ONECLICK_RECURRING;
} else {
$recurringContracts[$recurringDetailReference] = $recurringContract;
}
}
}
} catch (Adyen_Payment_Exception $e) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
"Error retrieving the Billing Agreement for shopperReference %s with recurringType #%s Error: %s",
$shopperReference, $recurringType, $e->getMessage()
)
);
}
}
return $recurringContracts;
} | php | public function listRecurringContracts($shopperReference, $store = null)
{
$recurringContracts = array();
foreach ($this->_recurringTypes as $recurringType) {
try {
// merge ONECLICK and RECURRING into one record with recurringType ONECLICK,RECURRING
$listRecurringContractByType = $this->listRecurringContractByType(
$shopperReference, $store,
$recurringType
);
foreach ($listRecurringContractByType as $recurringContract) {
if (isset($recurringContract['recurringDetailReference'])) {
$recurringDetailReference = $recurringContract['recurringDetailReference'];
// check if recurring reference is already in array
if (isset($recurringContracts[$recurringDetailReference])) {
// recurring reference already exists so recurringType is possible for ONECLICK and RECURRING
$recurringContracts[$recurringDetailReference]['recurring_type'] = self::RECURRING_TYPE_ONECLICK_RECURRING;
} else {
$recurringContracts[$recurringDetailReference] = $recurringContract;
}
}
}
} catch (Adyen_Payment_Exception $e) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
"Error retrieving the Billing Agreement for shopperReference %s with recurringType #%s Error: %s",
$shopperReference, $recurringType, $e->getMessage()
)
);
}
}
return $recurringContracts;
} | [
"public",
"function",
"listRecurringContracts",
"(",
"$",
"shopperReference",
",",
"$",
"store",
"=",
"null",
")",
"{",
"$",
"recurringContracts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_recurringTypes",
"as",
"$",
"recurringType",
... | Get all the stored Credit Cards and other billing agreements stored with Adyen.
@param string $shopperReference
@param int|Mage_Core_model_Store|null $store
@return array | [
"Get",
"all",
"the",
"stored",
"Credit",
"Cards",
"and",
"other",
"billing",
"agreements",
"stored",
"with",
"Adyen",
"."
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L76-L111 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api._mapToPaymentMethod | protected function _mapToPaymentMethod($variant)
{
if (is_null($this->_paymentMethodMap)) {
//@todo abstract this away to some config?
$this->_paymentMethodMap = array(
'sepadirectdebit' => 'adyen_sepa'
);
$ccTypes = Mage::helper('adyen')->getCcTypes();
$ccTypes = array_keys(array_change_key_case($ccTypes, CASE_LOWER));
foreach ($ccTypes as $ccType) {
$this->_paymentMethodMap[$ccType] = 'adyen_cc';
}
}
return isset($this->_paymentMethodMap[$variant]) ? $this->_paymentMethodMap[$variant] : $variant;
} | php | protected function _mapToPaymentMethod($variant)
{
if (is_null($this->_paymentMethodMap)) {
//@todo abstract this away to some config?
$this->_paymentMethodMap = array(
'sepadirectdebit' => 'adyen_sepa'
);
$ccTypes = Mage::helper('adyen')->getCcTypes();
$ccTypes = array_keys(array_change_key_case($ccTypes, CASE_LOWER));
foreach ($ccTypes as $ccType) {
$this->_paymentMethodMap[$ccType] = 'adyen_cc';
}
}
return isset($this->_paymentMethodMap[$variant]) ? $this->_paymentMethodMap[$variant] : $variant;
} | [
"protected",
"function",
"_mapToPaymentMethod",
"(",
"$",
"variant",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_paymentMethodMap",
")",
")",
"{",
"//@todo abstract this away to some config?",
"$",
"this",
"->",
"_paymentMethodMap",
"=",
"array",
"("... | Map the recurring variant to a Magento payment method.
@param $variant
@return mixed | [
"Map",
"the",
"recurring",
"variant",
"to",
"a",
"Magento",
"payment",
"method",
"."
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L183-L200 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api.disableRecurringContract | public function disableRecurringContract($recurringDetailReference, $shopperReference, $store = null)
{
$merchantAccount = $this->_helper()->getConfigData('merchantAccount', null, $store);
$request = array(
"action" => "Recurring.disable",
"disableRequest.merchantAccount" => $merchantAccount,
"disableRequest.shopperReference" => $shopperReference,
"disableRequest.recurringDetailReference" => $recurringDetailReference
);
$result = $this->_doRequest($request, $store);
// convert result to utf8 characters
$result = utf8_encode(urldecode($result));
if ($result != "disableResult.response=[detail-successfully-disabled]") {
Adyen_Payment_Exception::throwException(Mage::helper('adyen')->__($result));
}
return true;
} | php | public function disableRecurringContract($recurringDetailReference, $shopperReference, $store = null)
{
$merchantAccount = $this->_helper()->getConfigData('merchantAccount', null, $store);
$request = array(
"action" => "Recurring.disable",
"disableRequest.merchantAccount" => $merchantAccount,
"disableRequest.shopperReference" => $shopperReference,
"disableRequest.recurringDetailReference" => $recurringDetailReference
);
$result = $this->_doRequest($request, $store);
// convert result to utf8 characters
$result = utf8_encode(urldecode($result));
if ($result != "disableResult.response=[detail-successfully-disabled]") {
Adyen_Payment_Exception::throwException(Mage::helper('adyen')->__($result));
}
return true;
} | [
"public",
"function",
"disableRecurringContract",
"(",
"$",
"recurringDetailReference",
",",
"$",
"shopperReference",
",",
"$",
"store",
"=",
"null",
")",
"{",
"$",
"merchantAccount",
"=",
"$",
"this",
"->",
"_helper",
"(",
")",
"->",
"getConfigData",
"(",
"'m... | Disable a recurring contract
@param string $recurringDetailReference
@param string $shopperReference
@param int|Mage_Core_model_Store|null $store
@throws Adyen_Payment_Exception
@return bool | [
"Disable",
"a",
"recurring",
"contract"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L213-L234 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api._doRequest | protected function _doRequest(array $request, $storeId)
{
if ($storeId instanceof Mage_Core_model_Store) {
$storeId = $storeId->getId();
}
$requestUrl = self::ENDPOINT_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_TEST;
}
$username = $this->_helper()->getConfigDataWsUserName($storeId);
$password = $this->_helper()->getConfigDataWsPassword($storeId);
Mage::log($request, null, 'adyen_api.log');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, count($request));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$error = curl_error($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($result === false) {
Adyen_Payment_Exception::throwException($error);
}
if ($httpStatus != 200) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'HTTP Status code %s received, data %s',
$httpStatus, $result
)
);
}
return $result;
} | php | protected function _doRequest(array $request, $storeId)
{
if ($storeId instanceof Mage_Core_model_Store) {
$storeId = $storeId->getId();
}
$requestUrl = self::ENDPOINT_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_TEST;
}
$username = $this->_helper()->getConfigDataWsUserName($storeId);
$password = $this->_helper()->getConfigDataWsPassword($storeId);
Mage::log($request, null, 'adyen_api.log');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, count($request));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$error = curl_error($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($result === false) {
Adyen_Payment_Exception::throwException($error);
}
if ($httpStatus != 200) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'HTTP Status code %s received, data %s',
$httpStatus, $result
)
);
}
return $result;
} | [
"protected",
"function",
"_doRequest",
"(",
"array",
"$",
"request",
",",
"$",
"storeId",
")",
"{",
"if",
"(",
"$",
"storeId",
"instanceof",
"Mage_Core_model_Store",
")",
"{",
"$",
"storeId",
"=",
"$",
"storeId",
"->",
"getId",
"(",
")",
";",
"}",
"$",
... | Do the actual API request
@param array $request
@param int|Mage_Core_model_Store $storeId
@throws Adyen_Payment_Exception
@return mixed | [
"Do",
"the",
"actual",
"API",
"request"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L278-L324 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api.doRequestJson | protected function doRequestJson(array $request, $requestUrl, $apiKey, $storeId, $timeout = null)
{
$ch = curl_init();
$headers = array(
'Content-Type: application/json'
);
if (empty($apiKey)) {
$username = $this->_helper()->getConfigDataWsUserName($storeId);
$password = $this->_helper()->getConfigDataWsPassword($storeId);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
} else {
$headers[] = 'x-api-key: ' . $apiKey;
}
if (!empty($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}
Mage::log($request, null, 'adyen_api.log');
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$error = curl_error($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$errorCode = curl_errno($ch);
curl_close($ch);
if ($result === false) {
Adyen_Payment_Exception::throwCurlException($error, $errorCode);
}
if ($httpStatus == 401 || $httpStatus == 403) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'Received Status code %s, please make sure your Checkout API key is correct.',
$httpStatus
)
);
} elseif ($httpStatus != 200) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'HTTP Status code %s received, data %s',
$httpStatus, $result
)
);
}
return $result;
} | php | protected function doRequestJson(array $request, $requestUrl, $apiKey, $storeId, $timeout = null)
{
$ch = curl_init();
$headers = array(
'Content-Type: application/json'
);
if (empty($apiKey)) {
$username = $this->_helper()->getConfigDataWsUserName($storeId);
$password = $this->_helper()->getConfigDataWsPassword($storeId);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
} else {
$headers[] = 'x-api-key: ' . $apiKey;
}
if (!empty($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}
Mage::log($request, null, 'adyen_api.log');
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$error = curl_error($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$errorCode = curl_errno($ch);
curl_close($ch);
if ($result === false) {
Adyen_Payment_Exception::throwCurlException($error, $errorCode);
}
if ($httpStatus == 401 || $httpStatus == 403) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'Received Status code %s, please make sure your Checkout API key is correct.',
$httpStatus
)
);
} elseif ($httpStatus != 200) {
Adyen_Payment_Exception::throwException(
Mage::helper('adyen')->__(
'HTTP Status code %s received, data %s',
$httpStatus, $result
)
);
}
return $result;
} | [
"protected",
"function",
"doRequestJson",
"(",
"array",
"$",
"request",
",",
"$",
"requestUrl",
",",
"$",
"apiKey",
",",
"$",
"storeId",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"$",
"headers",
"=",
"arr... | Do the API request in json format
@param array $request
@param $requestUrl
@param $apiKey
@param $storeId
@param null $timeout
@return mixed | [
"Do",
"the",
"API",
"request",
"in",
"json",
"format"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L361-L414 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api.doRequestSync | public function doRequestSync(array $request, $storeId)
{
$requestUrl = self::ENDPOINT_TERMINAL_CLOUD_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_TERMINAL_CLOUD_TEST;
}
$apiKey = $this->_helper()->getPosApiKey($storeId);
$timeout = $this->_helper()->getConfigData('timeout', 'adyen_pos_cloud', $storeId);
$response = $this->doRequestJson($request, $requestUrl, $apiKey, $storeId, $timeout);
return json_decode($response, true);
} | php | public function doRequestSync(array $request, $storeId)
{
$requestUrl = self::ENDPOINT_TERMINAL_CLOUD_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_TERMINAL_CLOUD_TEST;
}
$apiKey = $this->_helper()->getPosApiKey($storeId);
$timeout = $this->_helper()->getConfigData('timeout', 'adyen_pos_cloud', $storeId);
$response = $this->doRequestJson($request, $requestUrl, $apiKey, $storeId, $timeout);
return json_decode($response, true);
} | [
"public",
"function",
"doRequestSync",
"(",
"array",
"$",
"request",
",",
"$",
"storeId",
")",
"{",
"$",
"requestUrl",
"=",
"self",
"::",
"ENDPOINT_TERMINAL_CLOUD_LIVE",
";",
"if",
"(",
"$",
"this",
"->",
"_helper",
"(",
")",
"->",
"getConfigDataDemoMode",
"... | Set the timeout and do a sync request to the Terminal API endpoint
@param array $request
@param int $storeId
@return mixed | [
"Set",
"the",
"timeout",
"and",
"do",
"a",
"sync",
"request",
"to",
"the",
"Terminal",
"API",
"endpoint"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L423-L434 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Api.php | Adyen_Payment_Model_Api.retrieveConnectedTerminals | public function retrieveConnectedTerminals($storeId)
{
$requestUrl = self::ENDPOINT_CONNECTED_TERMINALS_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_CONNECTED_TERMINALS_TEST;
}
$apiKey = $this->_helper()->getPosApiKey($storeId);
$merchantAccount = $this->_helper()->getAdyenMerchantAccount("pos_cloud", $storeId);
$request = array("merchantAccount" => $merchantAccount);
//If store_code is configured, retrieve only terminals connected to that store
$storeCode = $this->_helper()->getConfigData('store_code', 'adyen_pos_cloud', $storeId);
if ($storeCode) {
$request["store"] = $storeCode;
}
$response = $this->doRequestJson($request, $requestUrl, $apiKey, $storeId);
return $response;
} | php | public function retrieveConnectedTerminals($storeId)
{
$requestUrl = self::ENDPOINT_CONNECTED_TERMINALS_LIVE;
if ($this->_helper()->getConfigDataDemoMode($storeId)) {
$requestUrl = self::ENDPOINT_CONNECTED_TERMINALS_TEST;
}
$apiKey = $this->_helper()->getPosApiKey($storeId);
$merchantAccount = $this->_helper()->getAdyenMerchantAccount("pos_cloud", $storeId);
$request = array("merchantAccount" => $merchantAccount);
//If store_code is configured, retrieve only terminals connected to that store
$storeCode = $this->_helper()->getConfigData('store_code', 'adyen_pos_cloud', $storeId);
if ($storeCode) {
$request["store"] = $storeCode;
}
$response = $this->doRequestJson($request, $requestUrl, $apiKey, $storeId);
return $response;
} | [
"public",
"function",
"retrieveConnectedTerminals",
"(",
"$",
"storeId",
")",
"{",
"$",
"requestUrl",
"=",
"self",
"::",
"ENDPOINT_CONNECTED_TERMINALS_LIVE",
";",
"if",
"(",
"$",
"this",
"->",
"_helper",
"(",
")",
"->",
"getConfigDataDemoMode",
"(",
"$",
"storeI... | Do a synchronous request to retrieve the connected terminals
@param $storeId
@return mixed | [
"Do",
"a",
"synchronous",
"request",
"to",
"retrieve",
"the",
"connected",
"terminals"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Api.php#L442-L460 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Observer.php | Adyen_Payment_Model_Observer._getHmacKey | protected function _getHmacKey(Mage_Core_Model_Store $store)
{
$adyenHelper = Mage::helper('adyen');
switch ($adyenHelper->getConfigDataDemoMode()) {
case true:
$secretWord = trim($adyenHelper->getConfigData('secret_wordt', 'adyen_hpp'));
break;
default:
$secretWord = trim($adyenHelper->getConfigData('secret_wordp', 'adyen_hpp'));
break;
}
return $secretWord;
} | php | protected function _getHmacKey(Mage_Core_Model_Store $store)
{
$adyenHelper = Mage::helper('adyen');
switch ($adyenHelper->getConfigDataDemoMode()) {
case true:
$secretWord = trim($adyenHelper->getConfigData('secret_wordt', 'adyen_hpp'));
break;
default:
$secretWord = trim($adyenHelper->getConfigData('secret_wordp', 'adyen_hpp'));
break;
}
return $secretWord;
} | [
"protected",
"function",
"_getHmacKey",
"(",
"Mage_Core_Model_Store",
"$",
"store",
")",
"{",
"$",
"adyenHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'adyen'",
")",
";",
"switch",
"(",
"$",
"adyenHelper",
"->",
"getConfigDataDemoMode",
"(",
")",
")",
"{",
"ca... | Get the Hmac key from the config
@param Mage_Core_Model_Store $store
@return string | [
"Get",
"the",
"Hmac",
"key",
"from",
"the",
"config"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Observer.php#L447-L460 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Observer.php | Adyen_Payment_Model_Observer.captureInvoiceOnShipment | public function captureInvoiceOnShipment(Varien_Event_Observer $observer)
{
/* @var Mage_Sales_Model_Order_Shipment $shipment */
$shipment = $observer->getShipment();
/** @var Mage_Sales_Model_Order $order */
$order = $shipment->getOrder();
/** @var Adyen_Payment_Helper_Data $adyenHelper */
$adyenHelper = Mage::helper('adyen');
$storeId = $order->getStoreId();
$captureOnShipment = $adyenHelper->getConfigData('capture_on_shipment', 'adyen_abstract', $storeId);
$createPendingInvoice = $adyenHelper->getConfigData('create_pending_invoice', 'adyen_abstract', $storeId);
// validate if payment method is adyen and if capture_on_shipment is enabled
if ($this->isPaymentMethodAdyen($order) && $captureOnShipment) {
if ($createPendingInvoice) {
$transaction = Mage::getModel('core/resource_transaction');
$transaction->addObject($order);
foreach ($order->getInvoiceCollection() as $invoice) {
/* @var Mage_Sales_Model_Order_Invoice $invoice */
if (!$invoice->canCapture()) {
throw new Adyen_Payment_Exception($adyenHelper->__("Could not capture the invoice"));
}
$invoice->capture();
$invoice->setCreatedAt(now());
$transaction->addObject($invoice);
}
$order->setIsInProcess(true);
$transaction->save();
} else {
// create an invoice and do a capture to adyen
if ($order->canInvoice()) {
try {
/* @var Mage_Sales_Model_Order_Invoice $invoice */
$invoice = $order->prepareInvoice();
$invoice->getOrder()->setIsInProcess(true);
// set transaction id so you can do a online refund from credit memo
$invoice->setTransactionId(1);
$invoice->register()->capture();
$invoice->save();
} catch (Exception $e) {
Mage::logException($e);
throw new Adyen_Payment_Exception($adyenHelper->__("Could not capture the invoice"));
}
$invoiceAutoMail = (bool)$adyenHelper->getConfigData(
'send_invoice_update_mail', 'adyen_abstract',
$storeId
);
if ($invoiceAutoMail) {
$invoice->sendEmail();
}
} else {
// If there is already an invoice created, continue shipment
if ($order->hasInvoices() == 0) {
throw new Adyen_Payment_Exception($adyenHelper->__("Could not create the invoice"));
}
}
}
}
return $this;
} | php | public function captureInvoiceOnShipment(Varien_Event_Observer $observer)
{
/* @var Mage_Sales_Model_Order_Shipment $shipment */
$shipment = $observer->getShipment();
/** @var Mage_Sales_Model_Order $order */
$order = $shipment->getOrder();
/** @var Adyen_Payment_Helper_Data $adyenHelper */
$adyenHelper = Mage::helper('adyen');
$storeId = $order->getStoreId();
$captureOnShipment = $adyenHelper->getConfigData('capture_on_shipment', 'adyen_abstract', $storeId);
$createPendingInvoice = $adyenHelper->getConfigData('create_pending_invoice', 'adyen_abstract', $storeId);
// validate if payment method is adyen and if capture_on_shipment is enabled
if ($this->isPaymentMethodAdyen($order) && $captureOnShipment) {
if ($createPendingInvoice) {
$transaction = Mage::getModel('core/resource_transaction');
$transaction->addObject($order);
foreach ($order->getInvoiceCollection() as $invoice) {
/* @var Mage_Sales_Model_Order_Invoice $invoice */
if (!$invoice->canCapture()) {
throw new Adyen_Payment_Exception($adyenHelper->__("Could not capture the invoice"));
}
$invoice->capture();
$invoice->setCreatedAt(now());
$transaction->addObject($invoice);
}
$order->setIsInProcess(true);
$transaction->save();
} else {
// create an invoice and do a capture to adyen
if ($order->canInvoice()) {
try {
/* @var Mage_Sales_Model_Order_Invoice $invoice */
$invoice = $order->prepareInvoice();
$invoice->getOrder()->setIsInProcess(true);
// set transaction id so you can do a online refund from credit memo
$invoice->setTransactionId(1);
$invoice->register()->capture();
$invoice->save();
} catch (Exception $e) {
Mage::logException($e);
throw new Adyen_Payment_Exception($adyenHelper->__("Could not capture the invoice"));
}
$invoiceAutoMail = (bool)$adyenHelper->getConfigData(
'send_invoice_update_mail', 'adyen_abstract',
$storeId
);
if ($invoiceAutoMail) {
$invoice->sendEmail();
}
} else {
// If there is already an invoice created, continue shipment
if ($order->hasInvoices() == 0) {
throw new Adyen_Payment_Exception($adyenHelper->__("Could not create the invoice"));
}
}
}
}
return $this;
} | [
"public",
"function",
"captureInvoiceOnShipment",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"/* @var Mage_Sales_Model_Order_Shipment $shipment */",
"$",
"shipment",
"=",
"$",
"observer",
"->",
"getShipment",
"(",
")",
";",
"/** @var Mage_Sales_Model_Order $orde... | Capture the invoice just before the shipment is created
@param Varien_Event_Observer $observer
@return Adyen_Payment_Model_Observer $this
@throws Exception | [
"Capture",
"the",
"invoice",
"just",
"before",
"the",
"shipment",
"is",
"created"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Observer.php#L521-L590 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Observer.php | Adyen_Payment_Model_Observer.addCurrentInvoiceToPayment | public function addCurrentInvoiceToPayment(Varien_Event_Observer $observer)
{
$invoice = $observer->getInvoice();
$payment = $observer->getPayment();
$payment->setCurrentInvoice($invoice);
return $this;
} | php | public function addCurrentInvoiceToPayment(Varien_Event_Observer $observer)
{
$invoice = $observer->getInvoice();
$payment = $observer->getPayment();
$payment->setCurrentInvoice($invoice);
return $this;
} | [
"public",
"function",
"addCurrentInvoiceToPayment",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"$",
"invoice",
"=",
"$",
"observer",
"->",
"getInvoice",
"(",
")",
";",
"$",
"payment",
"=",
"$",
"observer",
"->",
"getPayment",
"(",
")",
";",
"$"... | Set current invoice to payment when capturing.
@param Varien_Event_Observer $observer
@return Adyen_Payment_Model_Observer $this | [
"Set",
"current",
"invoice",
"to",
"payment",
"when",
"capturing",
"."
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Observer.php#L598-L605 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Gettingstarted.php | Adyen_Payment_Block_Adminhtml_System_Config_Fieldset_Gettingstarted._getHeaderCommentHtml | protected function _getHeaderCommentHtml($element)
{
$html = $element->getComment()
? '<div class="comment">' . $element->getComment() . '</div>'
: '';
$url = Mage::helper('adminhtml')->getUrl('adminhtml/ExportAdyenSettings');
$html .= <<<HTML
<div class="button-container">
<button type="button" class="button" id="{$element->getHtmlId()}-export" onclick="location.href='{$url}'">
{$this->__('Export Settings')}
</button>
</div>
HTML;
return $html;
} | php | protected function _getHeaderCommentHtml($element)
{
$html = $element->getComment()
? '<div class="comment">' . $element->getComment() . '</div>'
: '';
$url = Mage::helper('adminhtml')->getUrl('adminhtml/ExportAdyenSettings');
$html .= <<<HTML
<div class="button-container">
<button type="button" class="button" id="{$element->getHtmlId()}-export" onclick="location.href='{$url}'">
{$this->__('Export Settings')}
</button>
</div>
HTML;
return $html;
} | [
"protected",
"function",
"_getHeaderCommentHtml",
"(",
"$",
"element",
")",
"{",
"$",
"html",
"=",
"$",
"element",
"->",
"getComment",
"(",
")",
"?",
"'<div class=\"comment\">'",
".",
"$",
"element",
"->",
"getComment",
"(",
")",
".",
"'</div>'",
":",
"''",
... | Return header comment part of html for fieldset
Add the Export Settings button
@param Varien_Data_Form_Element_Abstract $element
@return string | [
"Return",
"header",
"comment",
"part",
"of",
"html",
"for",
"fieldset",
"Add",
"the",
"Export",
"Settings",
"button"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Gettingstarted.php#L39-L54 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Observers/Quote.php | Adyen_Payment_Model_Observers_Quote._salesQuoteItemSetAttributes | protected function _salesQuoteItemSetAttributes(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
$quoteItem = $observer->getQuoteItem();
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
$quoteItem->setAdyenPreOrder((bool)$product->getAdyenPreOrder()); // set if product is pre order
} | php | protected function _salesQuoteItemSetAttributes(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
$quoteItem = $observer->getQuoteItem();
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
$quoteItem->setAdyenPreOrder((bool)$product->getAdyenPreOrder()); // set if product is pre order
} | [
"protected",
"function",
"_salesQuoteItemSetAttributes",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"/** @var Mage_Sales_Model_Quote_Item $quoteItem */",
"$",
"quoteItem",
"=",
"$",
"observer",
"->",
"getQuoteItem",
"(",
")",
";",
"/** @var Mage_Catalog_Model_Pr... | set the quote item values based on product attribute values
@param Varien_Event_Observer $observer | [
"set",
"the",
"quote",
"item",
"values",
"based",
"on",
"product",
"attribute",
"values"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Observers/Quote.php#L44-L52 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Pci.php | Adyen_Payment_Helper_Pci.obscureSensitiveData | public function obscureSensitiveData($object)
{
if (is_array($object)) {
return $this->_obscureSensitiveArray($object);
}
if ($object instanceof ArrayAccess) {
return $this->_obscureSensitiveObject($object);
}
if (is_string($object) || is_numeric($object)) {
return $this->_obscureSensitiveElements($object);
}
return $object;
} | php | public function obscureSensitiveData($object)
{
if (is_array($object)) {
return $this->_obscureSensitiveArray($object);
}
if ($object instanceof ArrayAccess) {
return $this->_obscureSensitiveObject($object);
}
if (is_string($object) || is_numeric($object)) {
return $this->_obscureSensitiveElements($object);
}
return $object;
} | [
"public",
"function",
"obscureSensitiveData",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_obscureSensitiveArray",
"(",
"$",
"object",
")",
";",
"}",
"if",
"(",
"$",
"object",
"i... | Recursively work through an array object obscuring the values of sensitive keys
Obscure any substrings matched as sensitive XML elements
@param mixed $object
@return mixed Original type of object | [
"Recursively",
"work",
"through",
"an",
"array",
"object",
"obscuring",
"the",
"values",
"of",
"sensitive",
"keys",
"Obscure",
"any",
"substrings",
"matched",
"as",
"sensitive",
"XML",
"elements"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Pci.php#L42-L57 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Pci.php | Adyen_Payment_Helper_Pci._obscureSensitiveElements | protected function _obscureSensitiveElements($string)
{
return preg_replace_callback(
self::$_sensitiveElementPatterns, function ($matches) {
return $matches[1] . $this->_obscureString($matches[2]) . $matches[3];
}, $string
);
} | php | protected function _obscureSensitiveElements($string)
{
return preg_replace_callback(
self::$_sensitiveElementPatterns, function ($matches) {
return $matches[1] . $this->_obscureString($matches[2]) . $matches[3];
}, $string
);
} | [
"protected",
"function",
"_obscureSensitiveElements",
"(",
"$",
"string",
")",
"{",
"return",
"preg_replace_callback",
"(",
"self",
"::",
"$",
"_sensitiveElementPatterns",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
... | Replace any matched sensitive strings with an obscured version
@param string $string
@return string | [
"Replace",
"any",
"matched",
"sensitive",
"strings",
"with",
"an",
"obscured",
"version"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Pci.php#L90-L97 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Pci.php | Adyen_Payment_Helper_Pci._obscureSensitiveKeyValue | protected function _obscureSensitiveKeyValue($key, $value)
{
// do not log additionalData in request
if ($key == "additionalData") {
$value = "NOT BEING LOGGED FOR SECURITY PURPOSES";
}
// Is this a sensitive key with a string or numeric value?
if (in_array(strtolower($key), self::$_sensitiveDataKeys) && (is_string($value) || is_numeric($value))) {
$strVal = (string)$value;
return $this->_obscureString($strVal);
}
// Recursively work through the value
return $this->obscureSensitiveData($value);
} | php | protected function _obscureSensitiveKeyValue($key, $value)
{
// do not log additionalData in request
if ($key == "additionalData") {
$value = "NOT BEING LOGGED FOR SECURITY PURPOSES";
}
// Is this a sensitive key with a string or numeric value?
if (in_array(strtolower($key), self::$_sensitiveDataKeys) && (is_string($value) || is_numeric($value))) {
$strVal = (string)$value;
return $this->_obscureString($strVal);
}
// Recursively work through the value
return $this->obscureSensitiveData($value);
} | [
"protected",
"function",
"_obscureSensitiveKeyValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// do not log additionalData in request",
"if",
"(",
"$",
"key",
"==",
"\"additionalData\"",
")",
"{",
"$",
"value",
"=",
"\"NOT BEING LOGGED FOR SECURITY PURPOSES\"",
... | Return value, obscured if sensitive based on key and value
@param $key
@param $value
@return mixed | [
"Return",
"value",
"obscured",
"if",
"sensitive",
"based",
"on",
"key",
"and",
"value"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Pci.php#L120-L135 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment/Data.php | Adyen_Payment_Helper_Payment_Data.getMethodInstance | public function getMethodInstance($code)
{
$key = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/model';
$class = Mage::getStoreConfig($key);
if (!$class && strpos($code, 'adyen_hpp') !== false) {
$methodCode = substr($code, strlen('adyen_hpp_'));
Mage::getSingleton('adyen/observer')->createPaymentMethodFromHpp(
$methodCode, array(),
Mage::app()->getStore(), '0'
);
$class = Mage::getStoreConfig($key);
} elseif (!$class && strpos($code, 'adyen_oneclick') !== false) {
$methodCode = substr($code, strlen('adyen_oneclick_'));
$store = Mage::getSingleton('adminhtml/session_quote')->getStore();
Mage::getSingleton('adyen/billing_agreement_observer')->createPaymentMethodFromOneClick(
$methodCode,
array(), $store
);
$class = Mage::getStoreConfig($key, $store->getId());
}
$methodInstance = Mage::getModel($class);
if (method_exists($methodInstance, 'setCode')) {
$methodInstance->setCode($code);
}
return $methodInstance;
} | php | public function getMethodInstance($code)
{
$key = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/model';
$class = Mage::getStoreConfig($key);
if (!$class && strpos($code, 'adyen_hpp') !== false) {
$methodCode = substr($code, strlen('adyen_hpp_'));
Mage::getSingleton('adyen/observer')->createPaymentMethodFromHpp(
$methodCode, array(),
Mage::app()->getStore(), '0'
);
$class = Mage::getStoreConfig($key);
} elseif (!$class && strpos($code, 'adyen_oneclick') !== false) {
$methodCode = substr($code, strlen('adyen_oneclick_'));
$store = Mage::getSingleton('adminhtml/session_quote')->getStore();
Mage::getSingleton('adyen/billing_agreement_observer')->createPaymentMethodFromOneClick(
$methodCode,
array(), $store
);
$class = Mage::getStoreConfig($key, $store->getId());
}
$methodInstance = Mage::getModel($class);
if (method_exists($methodInstance, 'setCode')) {
$methodInstance->setCode($code);
}
return $methodInstance;
} | [
"public",
"function",
"getMethodInstance",
"(",
"$",
"code",
")",
"{",
"$",
"key",
"=",
"self",
"::",
"XML_PATH_PAYMENT_METHODS",
".",
"'/'",
".",
"$",
"code",
".",
"'/model'",
";",
"$",
"class",
"=",
"Mage",
"::",
"getStoreConfig",
"(",
"$",
"key",
")",... | Retrieve method model object
@param string $code
@return Mage_Payment_Model_Method_Abstract|false | [
"Retrieve",
"method",
"model",
"object"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment/Data.php#L36-L64 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment/Data.php | Adyen_Payment_Helper_Payment_Data.getStoreMethods | public function getStoreMethods($store = null, $quote = null)
{
$res = array();
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
/** @var Mage_Payment_Model_Method_Abstract $methodInstance */
$methodInstance = Mage::getModel($model);
if (method_exists($methodInstance, 'setCode')) {
$methodInstance->setCode($code);
}
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
usort($res, array($this, '_sortMethods'));
return $res;
} | php | public function getStoreMethods($store = null, $quote = null)
{
$res = array();
foreach ($this->getPaymentMethods($store) as $code => $methodConfig) {
$prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/';
if (!$model = Mage::getStoreConfig($prefix . 'model', $store)) {
continue;
}
/** @var Mage_Payment_Model_Method_Abstract $methodInstance */
$methodInstance = Mage::getModel($model);
if (method_exists($methodInstance, 'setCode')) {
$methodInstance->setCode($code);
}
if (!$methodInstance) {
continue;
}
$methodInstance->setStore($store);
if (!$methodInstance->isAvailable($quote)) {
/* if the payment method cannot be used at this time */
continue;
}
$sortOrder = (int)$methodInstance->getConfigData('sort_order', $store);
$methodInstance->setSortOrder($sortOrder);
$res[] = $methodInstance;
}
usort($res, array($this, '_sortMethods'));
return $res;
} | [
"public",
"function",
"getStoreMethods",
"(",
"$",
"store",
"=",
"null",
",",
"$",
"quote",
"=",
"null",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPaymentMethods",
"(",
"$",
"store",
")",
"as",
"$",
"... | Get and sort available payment methods for specified or current store
array structure:
$index => Varien_Simplexml_Element
@todo maybe we can use this method instead of loading the payment methods on each pageload.
@param mixed $store
@param Mage_Sales_Model_Quote $quote
@return array | [
"Get",
"and",
"sort",
"available",
"payment",
"methods",
"for",
"specified",
"or",
"current",
"store"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment/Data.php#L77-L109 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment/Data.php | Adyen_Payment_Helper_Payment_Data.getInfoBlock | public function getInfoBlock(Mage_Payment_Model_Info $info)
{
$instance = $this->getMethodInstance($info->getMethod());
if ($instance) {
$instance->setInfoInstance($info);
$info->setMethodInstance($instance);
}
$blockType = $instance->getInfoBlockType();
if ($this->getLayout()) {
$block = $this->getLayout()->createBlock($blockType);
} else {
$className = Mage::getConfig()->getBlockClassName($blockType);
$block = new $className;
}
$block->setInfo($info);
return $block;
} | php | public function getInfoBlock(Mage_Payment_Model_Info $info)
{
$instance = $this->getMethodInstance($info->getMethod());
if ($instance) {
$instance->setInfoInstance($info);
$info->setMethodInstance($instance);
}
$blockType = $instance->getInfoBlockType();
if ($this->getLayout()) {
$block = $this->getLayout()->createBlock($blockType);
} else {
$className = Mage::getConfig()->getBlockClassName($blockType);
$block = new $className;
}
$block->setInfo($info);
return $block;
} | [
"public",
"function",
"getInfoBlock",
"(",
"Mage_Payment_Model_Info",
"$",
"info",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"getMethodInstance",
"(",
"$",
"info",
"->",
"getMethod",
"(",
")",
")",
";",
"if",
"(",
"$",
"instance",
")",
"{",
"$",... | Retrieve payment information block
@param Mage_Payment_Model_Info $info
@return Mage_Core_Block_Template | [
"Retrieve",
"payment",
"information",
"block"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment/Data.php#L117-L135 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Resource/Adyen/Event.php | Adyen_Payment_Model_Resource_Adyen_Event.getEvent | public function getEvent($pspReference, $adyenEventCode, $success = null)
{
$db = $this->_getReadAdapter();
if ($success == null) {
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('adyen_event_code = ?', $adyenEventCode)
->where('psp_reference = ?', $pspReference);
} else {
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('adyen_event_code = ?', $adyenEventCode)
->where('psp_reference = ?', $pspReference)
->where('success = ?', $success);
}
$stmt = $db->query($sql);
return $stmt->fetch();
} | php | public function getEvent($pspReference, $adyenEventCode, $success = null)
{
$db = $this->_getReadAdapter();
if ($success == null) {
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('adyen_event_code = ?', $adyenEventCode)
->where('psp_reference = ?', $pspReference);
} else {
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('adyen_event_code = ?', $adyenEventCode)
->where('psp_reference = ?', $pspReference)
->where('success = ?', $success);
}
$stmt = $db->query($sql);
return $stmt->fetch();
} | [
"public",
"function",
"getEvent",
"(",
"$",
"pspReference",
",",
"$",
"adyenEventCode",
",",
"$",
"success",
"=",
"null",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"_getReadAdapter",
"(",
")",
";",
"if",
"(",
"$",
"success",
"==",
"null",
")",
"{"... | Retrieve back events
@param type $pspReference
@param type $adyenEventCode
@return type | [
"Retrieve",
"back",
"events"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Resource/Adyen/Event.php#L46-L65 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Resource/Adyen/Event.php | Adyen_Payment_Model_Resource_Adyen_Event.getEventById | public function getEventById($incrementId, $adyenEventCode = Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION)
{
$db = $this->_getReadAdapter();
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('increment_id = ?', $incrementId)
->where('adyen_event_result = ?', $adyenEventCode);
return $db->fetchOne($sql);
} | php | public function getEventById($incrementId, $adyenEventCode = Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION)
{
$db = $this->_getReadAdapter();
$sql = $db->select()
->from($this->getMainTable(), array('*'))
->where('increment_id = ?', $incrementId)
->where('adyen_event_result = ?', $adyenEventCode);
return $db->fetchOne($sql);
} | [
"public",
"function",
"getEventById",
"(",
"$",
"incrementId",
",",
"$",
"adyenEventCode",
"=",
"Adyen_Payment_Model_Event",
"::",
"ADYEN_EVENT_AUTHORISATION",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"_getReadAdapter",
"(",
")",
";",
"$",
"sql",
"=",
"$",... | Get Event by order id
@param type $incrementId
@param type $adyenEventCode
@return type event id | [
"Get",
"Event",
"by",
"order",
"id"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Resource/Adyen/Event.php#L73-L81 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Resource/Billing/Agreement/Collection.php | Adyen_Payment_Model_Resource_Billing_Agreement_Collection.addNameToSelect | public function addNameToSelect()
{
$fields = $this->_getNameFields();
$adapter = $this->getConnection();
$concatenate = array();
if (isset($fields['prefix'])) {
$concatenate[] = $adapter->getCheckSql(
'{{prefix}} IS NOT NULL AND {{prefix}} != \'\'',
$adapter->getConcatSql(array('LTRIM(RTRIM({{prefix}}))', '\' \'')),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
$concatenate[] = '\' \'';
if (isset($fields['middlename'])) {
$concatenate[] = $adapter->getCheckSql(
'{{middlename}} IS NOT NULL AND {{middlename}} != \'\'',
$adapter->getConcatSql(array('LTRIM(RTRIM({{middlename}}))', '\' \'')),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
if (isset($fields['suffix'])) {
$concatenate[] = $adapter
->getCheckSql(
'{{suffix}} IS NOT NULL AND {{suffix}} != \'\'',
$adapter->getConcatSql(array('\' \'', 'LTRIM(RTRIM({{suffix}}))')),
'\'\''
);
}
$nameExpr = $adapter->getConcatSql($concatenate);
$this->addExpressionFieldToSelect('name', $nameExpr, $fields);
return $this;
} | php | public function addNameToSelect()
{
$fields = $this->_getNameFields();
$adapter = $this->getConnection();
$concatenate = array();
if (isset($fields['prefix'])) {
$concatenate[] = $adapter->getCheckSql(
'{{prefix}} IS NOT NULL AND {{prefix}} != \'\'',
$adapter->getConcatSql(array('LTRIM(RTRIM({{prefix}}))', '\' \'')),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
$concatenate[] = '\' \'';
if (isset($fields['middlename'])) {
$concatenate[] = $adapter->getCheckSql(
'{{middlename}} IS NOT NULL AND {{middlename}} != \'\'',
$adapter->getConcatSql(array('LTRIM(RTRIM({{middlename}}))', '\' \'')),
'\'\''
);
}
$concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
if (isset($fields['suffix'])) {
$concatenate[] = $adapter
->getCheckSql(
'{{suffix}} IS NOT NULL AND {{suffix}} != \'\'',
$adapter->getConcatSql(array('\' \'', 'LTRIM(RTRIM({{suffix}}))')),
'\'\''
);
}
$nameExpr = $adapter->getConcatSql($concatenate);
$this->addExpressionFieldToSelect('name', $nameExpr, $fields);
return $this;
} | [
"public",
"function",
"addNameToSelect",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"_getNameFields",
"(",
")",
";",
"$",
"adapter",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"$",
"concatenate",
"=",
"array",
"(",
")",
";",
"... | Add Name to select
@return Mage_Customer_Model_Resource_Customer_Collection | [
"Add",
"Name",
"to",
"select"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Resource/Billing/Agreement/Collection.php#L125-L165 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Installments.php | Adyen_Payment_Helper_Installments._encodeArrayFieldValue | protected function _encodeArrayFieldValue(array $value)
{
$result = array();
foreach ($value as $triplet) {
$currency = (isset($triplet[0])) ? $triplet[0] : "";
$boundary = (isset($triplet[1])) ? $triplet[1] : "";
$frequency = (isset($triplet[2])) ? $triplet[2] : "";
$interest = (isset($triplet[3])) ? $triplet[3] : "";
$_id = Mage::helper('core')->uniqHash('_');
$result[$_id] = array(
'installment_currency' => $currency,
'installment_boundary' => $boundary,
'installment_frequency' => $frequency,
'installment_interest' => $interest
);
}
return $result;
} | php | protected function _encodeArrayFieldValue(array $value)
{
$result = array();
foreach ($value as $triplet) {
$currency = (isset($triplet[0])) ? $triplet[0] : "";
$boundary = (isset($triplet[1])) ? $triplet[1] : "";
$frequency = (isset($triplet[2])) ? $triplet[2] : "";
$interest = (isset($triplet[3])) ? $triplet[3] : "";
$_id = Mage::helper('core')->uniqHash('_');
$result[$_id] = array(
'installment_currency' => $currency,
'installment_boundary' => $boundary,
'installment_frequency' => $frequency,
'installment_interest' => $interest
);
}
return $result;
} | [
"protected",
"function",
"_encodeArrayFieldValue",
"(",
"array",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"triplet",
")",
"{",
"$",
"currency",
"=",
"(",
"isset",
"(",
"$",
"triplet",
... | Encode value to be used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
deserialized DB entry => HTML form
@param array
@return array | [
"Encode",
"value",
"to",
"be",
"used",
"in",
"Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract",
"deserialized",
"DB",
"entry",
"=",
">",
"HTML",
"form"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Installments.php#L115-L134 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Installments.php | Adyen_Payment_Helper_Installments._decodeArrayFieldValue | protected function _decodeArrayFieldValue(array $value)
{
$result = array();
unset($value['__empty']);
foreach ($value as $_id => $row) {
if (!is_array($row) || !array_key_exists(
'installment_currency',
$row
) || !array_key_exists(
'installment_boundary',
$row
) || !array_key_exists(
'installment_frequency',
$row
) || !array_key_exists('installment_interest', $row)) {
continue;
}
$currency = $row['installment_currency'];
$boundary = $row['installment_boundary'];
$frequency = $row['installment_frequency'];
$interest = $row['installment_interest'];
$result[] = array($currency, $boundary, $frequency, $interest);
}
return $result;
} | php | protected function _decodeArrayFieldValue(array $value)
{
$result = array();
unset($value['__empty']);
foreach ($value as $_id => $row) {
if (!is_array($row) || !array_key_exists(
'installment_currency',
$row
) || !array_key_exists(
'installment_boundary',
$row
) || !array_key_exists(
'installment_frequency',
$row
) || !array_key_exists('installment_interest', $row)) {
continue;
}
$currency = $row['installment_currency'];
$boundary = $row['installment_boundary'];
$frequency = $row['installment_frequency'];
$interest = $row['installment_interest'];
$result[] = array($currency, $boundary, $frequency, $interest);
}
return $result;
} | [
"protected",
"function",
"_decodeArrayFieldValue",
"(",
"array",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"unset",
"(",
"$",
"value",
"[",
"'__empty'",
"]",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"_id",
"=>",
"$... | Decode value from used in Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
HTML form => deserialized DB entry
@param array
@return array | [
"Decode",
"value",
"from",
"used",
"in",
"Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract",
"HTML",
"form",
"=",
">",
"deserialized",
"DB",
"entry"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Installments.php#L142-L168 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Installments.php | Adyen_Payment_Helper_Installments.getConfigValue | public function getConfigValue($curr, $amount, $store = null, $ccType = "installments")
{
$value = $this->getInstallments($store, $ccType);
if ($this->_isEncodedArrayFieldValue($value)) {
$value = $this->_decodeArrayFieldValue($value);
}
$cur_minimal_boundary = -1;
$resulting_freq = 1;
foreach ($value as $row) {
list($currency, $boundary, $frequency) = $row;
if ($curr == $currency) {
if ($amount <= $boundary && ($boundary <= $cur_minimal_boundary || $cur_minimal_boundary == -1)) {
$cur_minimal_boundary = $boundary;
$resulting_freq = $frequency;
}
if ($boundary == "" && $cur_minimal_boundary == -1) {
$resulting_freq = $frequency;
}
}
}
return $resulting_freq;
} | php | public function getConfigValue($curr, $amount, $store = null, $ccType = "installments")
{
$value = $this->getInstallments($store, $ccType);
if ($this->_isEncodedArrayFieldValue($value)) {
$value = $this->_decodeArrayFieldValue($value);
}
$cur_minimal_boundary = -1;
$resulting_freq = 1;
foreach ($value as $row) {
list($currency, $boundary, $frequency) = $row;
if ($curr == $currency) {
if ($amount <= $boundary && ($boundary <= $cur_minimal_boundary || $cur_minimal_boundary == -1)) {
$cur_minimal_boundary = $boundary;
$resulting_freq = $frequency;
}
if ($boundary == "" && $cur_minimal_boundary == -1) {
$resulting_freq = $frequency;
}
}
}
return $resulting_freq;
} | [
"public",
"function",
"getConfigValue",
"(",
"$",
"curr",
",",
"$",
"amount",
",",
"$",
"store",
"=",
"null",
",",
"$",
"ccType",
"=",
"\"installments\"",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getInstallments",
"(",
"$",
"store",
",",
"$",
... | Retrieve maximum number for installments for given amount with config
@param int $customerGroupId
@param mixed $store
@return float|null | [
"Retrieve",
"maximum",
"number",
"for",
"installments",
"for",
"given",
"amount",
"with",
"config"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Installments.php#L177-L202 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Installments.php | Adyen_Payment_Helper_Installments.makeArrayFieldValue | public function makeArrayFieldValue($value)
{
$value = $this->_unserializeValue($value);
if (!$this->_isEncodedArrayFieldValue($value)) {
$value = $this->_encodeArrayFieldValue($value);
}
return $value;
} | php | public function makeArrayFieldValue($value)
{
$value = $this->_unserializeValue($value);
if (!$this->_isEncodedArrayFieldValue($value)) {
$value = $this->_encodeArrayFieldValue($value);
}
return $value;
} | [
"public",
"function",
"makeArrayFieldValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"_unserializeValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_isEncodedArrayFieldValue",
"(",
"$",
"value",
")",
")",... | Make value readable by Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
@param mixed $value
@return array | [
"Make",
"value",
"readable",
"by",
"Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Installments.php#L280-L288 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Installments.php | Adyen_Payment_Helper_Installments.makeStorableArrayFieldValue | public function makeStorableArrayFieldValue($value)
{
if ($this->_isEncodedArrayFieldValue($value)) {
$value = $this->_decodeArrayFieldValue($value);
}
$value = $this->_serializeValue($value);
return $value;
} | php | public function makeStorableArrayFieldValue($value)
{
if ($this->_isEncodedArrayFieldValue($value)) {
$value = $this->_decodeArrayFieldValue($value);
}
$value = $this->_serializeValue($value);
return $value;
} | [
"public",
"function",
"makeStorableArrayFieldValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isEncodedArrayFieldValue",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"_decodeArrayFieldValue",
"(",
"$",
"value",
... | Make value ready for store
@param mixed $value
@return string | [
"Make",
"value",
"ready",
"for",
"store"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Installments.php#L296-L304 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Invoice/Totals.php | Adyen_Fee_Block_Adminhtml_Sales_Order_Invoice_Totals.addPaymentFeeWithTax | protected function addPaymentFeeWithTax($addTaxIndicationLabel = false)
{
if ($addTaxIndicationLabel) {
$label = $this->helper('adyen')->__('Payment Fee (Incl.Tax)');
} else {
$label = $this->helper('adyen')->__('Payment Fee');
}
if ($this->getSource()->getPaymentFeeAmount() != 0) {
$this->addTotal(
new Varien_Object(
array(
'code' => 'payment_fee_incl',
'strong' => false,
'value' => $this->getSource()->getPaymentFeeAmount() + $this->getSource()->getPaymentFeeTax(),
'base_value' => $this->getSource()->getBasePaymentFeeAmount() + $this->getSource()->getPaymentFeeTax(),
'label' => $label,
'area' => '',
)
),
'subtotal'
);
}
} | php | protected function addPaymentFeeWithTax($addTaxIndicationLabel = false)
{
if ($addTaxIndicationLabel) {
$label = $this->helper('adyen')->__('Payment Fee (Incl.Tax)');
} else {
$label = $this->helper('adyen')->__('Payment Fee');
}
if ($this->getSource()->getPaymentFeeAmount() != 0) {
$this->addTotal(
new Varien_Object(
array(
'code' => 'payment_fee_incl',
'strong' => false,
'value' => $this->getSource()->getPaymentFeeAmount() + $this->getSource()->getPaymentFeeTax(),
'base_value' => $this->getSource()->getBasePaymentFeeAmount() + $this->getSource()->getPaymentFeeTax(),
'label' => $label,
'area' => '',
)
),
'subtotal'
);
}
} | [
"protected",
"function",
"addPaymentFeeWithTax",
"(",
"$",
"addTaxIndicationLabel",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"addTaxIndicationLabel",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"helper",
"(",
"'adyen'",
")",
"->",
"__",
"(",
"'Payment Fee... | Add PaymentFee with Tax to totals array
@param bool|false $addTaxIndicationLabel | [
"Add",
"PaymentFee",
"with",
"Tax",
"to",
"totals",
"array"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Invoice/Totals.php#L123-L146 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/Adyen/Event/Queue/Grid.php | Adyen_Payment_Block_Adminhtml_Adyen_Event_Queue_Grid._prepareCollection | protected function _prepareCollection()
{
$collection = Mage::getResourceModel('adyen/event_queue_collection');
$this->setCollection($collection);
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('event_queue_id', 'desc');
}
return parent::_prepareCollection();
} | php | protected function _prepareCollection()
{
$collection = Mage::getResourceModel('adyen/event_queue_collection');
$this->setCollection($collection);
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('event_queue_id', 'desc');
}
return parent::_prepareCollection();
} | [
"protected",
"function",
"_prepareCollection",
"(",
")",
"{",
"$",
"collection",
"=",
"Mage",
"::",
"getResourceModel",
"(",
"'adyen/event_queue_collection'",
")",
";",
"$",
"this",
"->",
"setCollection",
"(",
"$",
"collection",
")",
";",
"if",
"(",
"!",
"$",
... | Prepare grid collection object
@return Adyen_Payment_Block_Adminhtml_Adyen_Event_Queue_Grid | [
"Prepare",
"grid",
"collection",
"object"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/Adyen/Event/Queue/Grid.php#L47-L56 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Billing/Agreement.php | Adyen_Payment_Model_Billing_Agreement.getPaymentMethodInstance | public function getPaymentMethodInstance()
{
if (is_null($this->_paymentMethodInstance)) {
$methodCode = $this->getMethodCode();
if ($this->getMethodCode() == 'adyen_oneclick') {
$referenceId = $this->getReferenceId();
$methodInstanceName = $methodCode . "_" . $referenceId;
} else {
$methodInstanceName = $methodCode;
}
$this->_paymentMethodInstance = Mage::helper('payment')->getMethodInstance($methodInstanceName);
if (!$this->_paymentMethodInstance) {
$this->_paymentMethodInstance = Mage::helper('payment')->getMethodInstance($this->getMethodCode());
}
}
if ($this->_paymentMethodInstance) {
$this->_paymentMethodInstance->setStore($this->getStoreId());
}
return $this->_paymentMethodInstance;
} | php | public function getPaymentMethodInstance()
{
if (is_null($this->_paymentMethodInstance)) {
$methodCode = $this->getMethodCode();
if ($this->getMethodCode() == 'adyen_oneclick') {
$referenceId = $this->getReferenceId();
$methodInstanceName = $methodCode . "_" . $referenceId;
} else {
$methodInstanceName = $methodCode;
}
$this->_paymentMethodInstance = Mage::helper('payment')->getMethodInstance($methodInstanceName);
if (!$this->_paymentMethodInstance) {
$this->_paymentMethodInstance = Mage::helper('payment')->getMethodInstance($this->getMethodCode());
}
}
if ($this->_paymentMethodInstance) {
$this->_paymentMethodInstance->setStore($this->getStoreId());
}
return $this->_paymentMethodInstance;
} | [
"public",
"function",
"getPaymentMethodInstance",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_paymentMethodInstance",
")",
")",
"{",
"$",
"methodCode",
"=",
"$",
"this",
"->",
"getMethodCode",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->... | Retrieve payment method instance
@return Mage_Payment_Model_Method_Abstract | [
"Retrieve",
"payment",
"method",
"instance"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Billing/Agreement.php#L120-L143 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/ProcessNotification.php | Adyen_Payment_Model_ProcessNotification.processResponse | public function processResponse($response)
{
// SOAP, JSON, HTTP POST
$storeId = null;
$this->_debugData['processResponse begin'] = 'Begin to process Notification';
if (empty($response)) {
$this->_debugData['error'] = 'Response is empty, please check your webserver that the result url accepts parameters';
$this->_debug($storeId);
return array('response' => '401');
}
// Log the results in log file and adyen_debug table
$this->_debugData['response'] = $response;
Mage::getResourceModel('adyen/adyen_debug')->assignData($response);
// $params = new Varien_Object($response);
// Create Varien_Object from response (soap compatible)
$params = new Varien_Object();
foreach ($response as $code => $value) {
$params->setData($code, $value);
}
$actionName = $this->_getRequest()->getActionName();
// authenticate result url
$authStatus = Mage::getModel('adyen/authenticate')->authenticate($actionName, $params);
if (!$authStatus['authentication']) {
$this->_debugData['error'] = 'Autentication failure please check your notification username and password. This must be the same in Magento as in the Adyen platform';
$this->_debug($storeId);
return array('response' => '401', 'message' => $authStatus['message']);
}
// skip notification if notification is REPORT_AVAILABLE
$eventCode = trim($params->getData('eventCode'));
if ($eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_REPORT_AVAILABLE) {
$this->_debugData['processResponse info'] = 'Skip notification REPORT_AVAILABLE';
$this->_debug($storeId);
return;
}
$this->_declareCommonVariables($params);
$isInvalidKcp = $this->_isInvalidKcp($this->_paymentMethod, $this->_value);
if ($isInvalidKcp) {
$this->_debugData['processResponse info'] = 'Skip notification for KCP and 0 amount';
$this->_debug($storeId);
return;
}
// check if notification is not duplicate
if (!$this->_isDuplicate($params)) {
$incrementId = $params->getData('merchantReference');
if ($incrementId) {
$this->_debugData['info'] = 'Add this notification with Order increment_id to queue: ' . $incrementId;
$this->_addNotificationToQueue($params);
} else {
$this->_debugData['error'] = 'Empty merchantReference';
}
} else {
$this->_debugData['processResponse info'] = 'Skipping duplicate notification';
}
$this->_debug($storeId);
} | php | public function processResponse($response)
{
// SOAP, JSON, HTTP POST
$storeId = null;
$this->_debugData['processResponse begin'] = 'Begin to process Notification';
if (empty($response)) {
$this->_debugData['error'] = 'Response is empty, please check your webserver that the result url accepts parameters';
$this->_debug($storeId);
return array('response' => '401');
}
// Log the results in log file and adyen_debug table
$this->_debugData['response'] = $response;
Mage::getResourceModel('adyen/adyen_debug')->assignData($response);
// $params = new Varien_Object($response);
// Create Varien_Object from response (soap compatible)
$params = new Varien_Object();
foreach ($response as $code => $value) {
$params->setData($code, $value);
}
$actionName = $this->_getRequest()->getActionName();
// authenticate result url
$authStatus = Mage::getModel('adyen/authenticate')->authenticate($actionName, $params);
if (!$authStatus['authentication']) {
$this->_debugData['error'] = 'Autentication failure please check your notification username and password. This must be the same in Magento as in the Adyen platform';
$this->_debug($storeId);
return array('response' => '401', 'message' => $authStatus['message']);
}
// skip notification if notification is REPORT_AVAILABLE
$eventCode = trim($params->getData('eventCode'));
if ($eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_REPORT_AVAILABLE) {
$this->_debugData['processResponse info'] = 'Skip notification REPORT_AVAILABLE';
$this->_debug($storeId);
return;
}
$this->_declareCommonVariables($params);
$isInvalidKcp = $this->_isInvalidKcp($this->_paymentMethod, $this->_value);
if ($isInvalidKcp) {
$this->_debugData['processResponse info'] = 'Skip notification for KCP and 0 amount';
$this->_debug($storeId);
return;
}
// check if notification is not duplicate
if (!$this->_isDuplicate($params)) {
$incrementId = $params->getData('merchantReference');
if ($incrementId) {
$this->_debugData['info'] = 'Add this notification with Order increment_id to queue: ' . $incrementId;
$this->_addNotificationToQueue($params);
} else {
$this->_debugData['error'] = 'Empty merchantReference';
}
} else {
$this->_debugData['processResponse info'] = 'Skipping duplicate notification';
}
$this->_debug($storeId);
} | [
"public",
"function",
"processResponse",
"(",
"$",
"response",
")",
"{",
"// SOAP, JSON, HTTP POST",
"$",
"storeId",
"=",
"null",
";",
"$",
"this",
"->",
"_debugData",
"[",
"'processResponse begin'",
"]",
"=",
"'Begin to process Notification'",
";",
"if",
"(",
"em... | Process the notification that is received by the Adyen platform
@param $response
@return string | [
"Process",
"the",
"notification",
"that",
"is",
"received",
"by",
"the",
"Adyen",
"platform"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/ProcessNotification.php#L52-L117 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/ProcessNotification.php | Adyen_Payment_Model_ProcessNotification._isDuplicate | protected function _isDuplicate($params)
{
$pspReference = trim($params->getData('pspReference'));
$success = trim($params->getData('success'));
$eventCode = trim($params->getData('eventCode'));
// if notification is already processed ignore it
$isDuplicate = Mage::getModel('adyen/event')
->isDuplicate($pspReference, $eventCode, $success);
if ($isDuplicate && $eventCode != Adyen_Payment_Model_Event::ADYEN_EVENT_RECURRING_CONTRACT) {
return true;
}
return false;
} | php | protected function _isDuplicate($params)
{
$pspReference = trim($params->getData('pspReference'));
$success = trim($params->getData('success'));
$eventCode = trim($params->getData('eventCode'));
// if notification is already processed ignore it
$isDuplicate = Mage::getModel('adyen/event')
->isDuplicate($pspReference, $eventCode, $success);
if ($isDuplicate && $eventCode != Adyen_Payment_Model_Event::ADYEN_EVENT_RECURRING_CONTRACT) {
return true;
}
return false;
} | [
"protected",
"function",
"_isDuplicate",
"(",
"$",
"params",
")",
"{",
"$",
"pspReference",
"=",
"trim",
"(",
"$",
"params",
"->",
"getData",
"(",
"'pspReference'",
")",
")",
";",
"$",
"success",
"=",
"trim",
"(",
"$",
"params",
"->",
"getData",
"(",
"... | Check if notification is already received
If this is the case ignore the notification
@param $params
@return bool | [
"Check",
"if",
"notification",
"is",
"already",
"received",
"If",
"this",
"is",
"the",
"case",
"ignore",
"the",
"notification"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/ProcessNotification.php#L141-L155 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/ProcessNotification.php | Adyen_Payment_Model_ProcessNotification._retrieveLast4DigitsFromReason | protected function _retrieveLast4DigitsFromReason($reason)
{
$result = "";
if ($reason != "") {
$reasonArray = explode(":", $reason);
if ($reasonArray != null && is_array($reasonArray)) {
if (isset($reasonArray[1])) {
$result = $reasonArray[1];
}
}
}
return $result;
} | php | protected function _retrieveLast4DigitsFromReason($reason)
{
$result = "";
if ($reason != "") {
$reasonArray = explode(":", $reason);
if ($reasonArray != null && is_array($reasonArray)) {
if (isset($reasonArray[1])) {
$result = $reasonArray[1];
}
}
}
return $result;
} | [
"protected",
"function",
"_retrieveLast4DigitsFromReason",
"(",
"$",
"reason",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"if",
"(",
"$",
"reason",
"!=",
"\"\"",
")",
"{",
"$",
"reasonArray",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"reason",
")",
";",
... | retrieve last 4 digits of card from the reason field
@param $reason
@return string | [
"retrieve",
"last",
"4",
"digits",
"of",
"card",
"from",
"the",
"reason",
"field"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/ProcessNotification.php#L441-L455 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/ProcessNotification.php | Adyen_Payment_Model_ProcessNotification._updateExistingBillingAgreementsStatus | protected function _updateExistingBillingAgreementsStatus($customerReference, $recurringReferencesList)
{
$billingAgreements = Mage::getResourceModel('adyen/billing_agreement_collection')
->addFieldToFilter('customer_id', $customerReference);
foreach ($billingAgreements as $billingAgreement) {
if (!in_array($billingAgreement->getReferenceId(), $recurringReferencesList)) {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_CANCELED);
} else {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_ACTIVE);
}
$billingAgreement->save();
}
} | php | protected function _updateExistingBillingAgreementsStatus($customerReference, $recurringReferencesList)
{
$billingAgreements = Mage::getResourceModel('adyen/billing_agreement_collection')
->addFieldToFilter('customer_id', $customerReference);
foreach ($billingAgreements as $billingAgreement) {
if (!in_array($billingAgreement->getReferenceId(), $recurringReferencesList)) {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_CANCELED);
} else {
$billingAgreement->setStatus(Adyen_Payment_Model_Billing_Agreement::STATUS_ACTIVE);
}
$billingAgreement->save();
}
} | [
"protected",
"function",
"_updateExistingBillingAgreementsStatus",
"(",
"$",
"customerReference",
",",
"$",
"recurringReferencesList",
")",
"{",
"$",
"billingAgreements",
"=",
"Mage",
"::",
"getResourceModel",
"(",
"'adyen/billing_agreement_collection'",
")",
"->",
"addFiel... | Update status of the agreements in Magento | [
"Update",
"status",
"of",
"the",
"agreements",
"in",
"Magento"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/ProcessNotification.php#L706-L720 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/ProcessNotification.php | Adyen_Payment_Model_ProcessNotification._manualCaptureAllowed | protected function _manualCaptureAllowed()
{
$manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod;
// For all openinvoice methods is manual capture allowed
if (Mage::helper('adyen')->isOpenInvoice($paymentMethod)) {
return true;
}
switch ($paymentMethod) {
case 'cup':
case 'cartebancaire':
case 'visa':
case 'visadankort':
case 'mc':
case 'uatp':
case 'amex':
case 'maestro':
case 'maestrouk':
case 'diners':
case 'discover':
case 'jcb':
case 'laser':
case 'paypal':
case 'sepadirectdebit':
$manualCaptureAllowed = true;
break;
default:
$manualCaptureAllowed = false;
}
return $manualCaptureAllowed;
} | php | protected function _manualCaptureAllowed()
{
$manualCaptureAllowed = null;
$paymentMethod = $this->_paymentMethod;
// For all openinvoice methods is manual capture allowed
if (Mage::helper('adyen')->isOpenInvoice($paymentMethod)) {
return true;
}
switch ($paymentMethod) {
case 'cup':
case 'cartebancaire':
case 'visa':
case 'visadankort':
case 'mc':
case 'uatp':
case 'amex':
case 'maestro':
case 'maestrouk':
case 'diners':
case 'discover':
case 'jcb':
case 'laser':
case 'paypal':
case 'sepadirectdebit':
$manualCaptureAllowed = true;
break;
default:
$manualCaptureAllowed = false;
}
return $manualCaptureAllowed;
} | [
"protected",
"function",
"_manualCaptureAllowed",
"(",
")",
"{",
"$",
"manualCaptureAllowed",
"=",
"null",
";",
"$",
"paymentMethod",
"=",
"$",
"this",
"->",
"_paymentMethod",
";",
"// For all openinvoice methods is manual capture allowed",
"if",
"(",
"Mage",
"::",
"h... | Validate if this payment methods allows manual capture
This is a default can be forced differently to overrule on acquirer level
@return bool|null | [
"Validate",
"if",
"this",
"payment",
"methods",
"allows",
"manual",
"capture",
"This",
"is",
"a",
"default",
"can",
"be",
"forced",
"differently",
"to",
"overrule",
"on",
"acquirer",
"level"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/ProcessNotification.php#L1240-L1273 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Event.php | Adyen_Payment_Model_Event.isDuplicate | public function isDuplicate($pspReference, $event, $success)
{
$success = (trim($success) == "true") ? true : false;
$result = $this->getResource()->getEvent(trim($pspReference), trim($event), $success);
return (empty($result)) ? false : true;
} | php | public function isDuplicate($pspReference, $event, $success)
{
$success = (trim($success) == "true") ? true : false;
$result = $this->getResource()->getEvent(trim($pspReference), trim($event), $success);
return (empty($result)) ? false : true;
} | [
"public",
"function",
"isDuplicate",
"(",
"$",
"pspReference",
",",
"$",
"event",
",",
"$",
"success",
")",
"{",
"$",
"success",
"=",
"(",
"trim",
"(",
"$",
"success",
")",
"==",
"\"true\"",
")",
"?",
"true",
":",
"false",
";",
"$",
"result",
"=",
... | Check if the Adyen Notification is already stored in the system
@param type $dbPspReference
@param type $dbEventCode
@return boolean true if the event is a duplicate | [
"Check",
"if",
"the",
"Adyen",
"Notification",
"is",
"already",
"stored",
"in",
"the",
"system"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Event.php#L75-L80 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/GetPosOrderStatus.php | Adyen_Payment_Model_GetPosOrderStatus._debug | protected function _debug($storeId)
{
if ($this->_getConfigData('debug', 'adyen_abstract', $storeId)) {
$file = 'adyen_orderstatus_pos.log';
Mage::getModel('core/log_adapter', $file)->log($this->_debugData);
}
} | php | protected function _debug($storeId)
{
if ($this->_getConfigData('debug', 'adyen_abstract', $storeId)) {
$file = 'adyen_orderstatus_pos.log';
Mage::getModel('core/log_adapter', $file)->log($this->_debugData);
}
} | [
"protected",
"function",
"_debug",
"(",
"$",
"storeId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_getConfigData",
"(",
"'debug'",
",",
"'adyen_abstract'",
",",
"$",
"storeId",
")",
")",
"{",
"$",
"file",
"=",
"'adyen_orderstatus_pos.log'",
";",
"Mage",
"::... | Log debug data to file
@param $storeId
@param mixed $debugData | [
"Log",
"debug",
"data",
"to",
"file"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/GetPosOrderStatus.php#L129-L135 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/controllers/Adminhtml/Adyen/Event/QueueController.php | Adyen_Payment_Adminhtml_Adyen_Event_QueueController.gridAction | public function gridAction()
{
try {
$this->loadLayout()->renderLayout();
return;
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
} catch (Exception $e) {
Adyen_Payment_Exception::logException($e);
}
$this->_redirect('*/*/');
} | php | public function gridAction()
{
try {
$this->loadLayout()->renderLayout();
return;
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
} catch (Exception $e) {
Adyen_Payment_Exception::logException($e);
}
$this->_redirect('*/*/');
} | [
"public",
"function",
"gridAction",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"loadLayout",
"(",
")",
"->",
"renderLayout",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"Mage_Core_Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"_getSession"... | Event queue ajax grid | [
"Event",
"queue",
"ajax",
"grid"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/controllers/Adminhtml/Adyen/Event/QueueController.php#L55-L67 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/controllers/Adminhtml/Adyen/Event/QueueController.php | Adyen_Payment_Adminhtml_Adyen_Event_QueueController.executeAction | public function executeAction()
{
// get event queue id
$eventQueueId = $this->getRequest()->getParam('event_queue_id');
$this->_executeEventQueue($eventQueueId);
// return back to the view
$this->_redirect('*/*/');
} | php | public function executeAction()
{
// get event queue id
$eventQueueId = $this->getRequest()->getParam('event_queue_id');
$this->_executeEventQueue($eventQueueId);
// return back to the view
$this->_redirect('*/*/');
} | [
"public",
"function",
"executeAction",
"(",
")",
"{",
"// get event queue id",
"$",
"eventQueueId",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"'event_queue_id'",
")",
";",
"$",
"this",
"->",
"_executeEventQueue",
"(",
"$",
"eventQu... | This tries to process the notification again | [
"This",
"tries",
"to",
"process",
"the",
"notification",
"again"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/controllers/Adminhtml/Adyen/Event/QueueController.php#L72-L80 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Totals.php | Adyen_Fee_Block_Adminhtml_Sales_Order_Totals.addPaymentFeeWithoutTax | protected function addPaymentFeeWithoutTax($addTaxIndationLabel = false)
{
if ($addTaxIndationLabel) {
$label = $this->helper('adyen')->__('Payment Fee (Excl.Tax)');
} else {
$label = $this->helper('adyen')->__('Payment Fee');
}
$this->addTotal(
new Varien_Object(
array(
'code' => 'payment_fee_excl',
'strong' => false,
'value' => $this->getSource()->getPaymentFeeAmount(),
'base_value' => $this->getSource()->getBasePaymentFeeAmount(),
'label' => $label,
'area' => '',
)
),
'subtotal'
);
} | php | protected function addPaymentFeeWithoutTax($addTaxIndationLabel = false)
{
if ($addTaxIndationLabel) {
$label = $this->helper('adyen')->__('Payment Fee (Excl.Tax)');
} else {
$label = $this->helper('adyen')->__('Payment Fee');
}
$this->addTotal(
new Varien_Object(
array(
'code' => 'payment_fee_excl',
'strong' => false,
'value' => $this->getSource()->getPaymentFeeAmount(),
'base_value' => $this->getSource()->getBasePaymentFeeAmount(),
'label' => $label,
'area' => '',
)
),
'subtotal'
);
} | [
"protected",
"function",
"addPaymentFeeWithoutTax",
"(",
"$",
"addTaxIndationLabel",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"addTaxIndationLabel",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"helper",
"(",
"'adyen'",
")",
"->",
"__",
"(",
"'Payment Fee ... | Add PaymentFee without Tax to totals array
@param bool|false $addTaxIndicationLabel | [
"Add",
"PaymentFee",
"without",
"Tax",
"to",
"totals",
"array"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Block/Adminhtml/Sales/Order/Totals.php#L93-L114 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Model/Tax/Config.php | Adyen_Fee_Model_Tax_Config.paymentFeePriceIncludesTax | public function paymentFeePriceIncludesTax($store = null)
{
if ($this->_paymentFeePriceIncludeTax === null) {
$this->_paymentFeePriceIncludeTax = (bool)$this->_getConfigDataCall(
self::CONFIG_XML_PATH_PAYMENT_FEE_INCLUDES_TAX,
$store
);
}
return $this->_paymentFeePriceIncludeTax;
} | php | public function paymentFeePriceIncludesTax($store = null)
{
if ($this->_paymentFeePriceIncludeTax === null) {
$this->_paymentFeePriceIncludeTax = (bool)$this->_getConfigDataCall(
self::CONFIG_XML_PATH_PAYMENT_FEE_INCLUDES_TAX,
$store
);
}
return $this->_paymentFeePriceIncludeTax;
} | [
"public",
"function",
"paymentFeePriceIncludesTax",
"(",
"$",
"store",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_paymentFeePriceIncludeTax",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_paymentFeePriceIncludeTax",
"=",
"(",
"bool",
")",
"$",
"t... | Check if payment fee prices include tax
@param store $store
@return bool | [
"Check",
"if",
"payment",
"fee",
"prices",
"include",
"tax"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Model/Tax/Config.php#L84-L94 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Helper/Data.php | Adyen_Fee_Helper_Data.isPaymentFeeEnabled | public function isPaymentFeeEnabled(Mage_Sales_Model_Quote $quote)
{
$paymentMethod = $quote->getPayment()->getMethod();
if ($paymentMethod == 'adyen_openinvoice') {
$fee = Mage::getStoreConfig('payment/adyen_openinvoice/fee');
if ($fee) {
return true;
}
} elseif ($paymentMethod == 'adyen_ideal') {
$fee = Mage::getStoreConfig('payment/adyen_ideal/fee');
if ($fee) {
return true;
}
} elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
$fee = $this->getHppPaymentMethodFee($paymentMethod);
if ($fee) {
return true;
}
}
return false;
} | php | public function isPaymentFeeEnabled(Mage_Sales_Model_Quote $quote)
{
$paymentMethod = $quote->getPayment()->getMethod();
if ($paymentMethod == 'adyen_openinvoice') {
$fee = Mage::getStoreConfig('payment/adyen_openinvoice/fee');
if ($fee) {
return true;
}
} elseif ($paymentMethod == 'adyen_ideal') {
$fee = Mage::getStoreConfig('payment/adyen_ideal/fee');
if ($fee) {
return true;
}
} elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
$fee = $this->getHppPaymentMethodFee($paymentMethod);
if ($fee) {
return true;
}
}
return false;
} | [
"public",
"function",
"isPaymentFeeEnabled",
"(",
"Mage_Sales_Model_Quote",
"$",
"quote",
")",
"{",
"$",
"paymentMethod",
"=",
"$",
"quote",
"->",
"getPayment",
"(",
")",
"->",
"getMethod",
"(",
")",
";",
"if",
"(",
"$",
"paymentMethod",
"==",
"'adyen_openinvo... | Check if payment method is enabled
@param Mage_Sales_Model_Quote
@return bool | [
"Check",
"if",
"payment",
"method",
"is",
"enabled"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Helper/Data.php#L43-L65 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Helper/Data.php | Adyen_Fee_Helper_Data.getPaymentFeeAmount | public function getPaymentFeeAmount(Mage_Sales_Model_Quote $quote, $store = null)
{
$paymentMethod = $quote->getPayment()->getMethod();
if ($paymentMethod == 'adyen_openinvoice') {
return Mage::getStoreConfig('payment/adyen_openinvoice/fee');
} elseif ($paymentMethod == 'adyen_ideal') {
return Mage::getStoreConfig('payment/adyen_ideal/fee');
} elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
return $this->getHppPaymentMethodFee($paymentMethod);
}
return 0;
} | php | public function getPaymentFeeAmount(Mage_Sales_Model_Quote $quote, $store = null)
{
$paymentMethod = $quote->getPayment()->getMethod();
if ($paymentMethod == 'adyen_openinvoice') {
return Mage::getStoreConfig('payment/adyen_openinvoice/fee');
} elseif ($paymentMethod == 'adyen_ideal') {
return Mage::getStoreConfig('payment/adyen_ideal/fee');
} elseif (substr($paymentMethod, 0, 10) == 'adyen_hpp_') {
return $this->getHppPaymentMethodFee($paymentMethod);
}
return 0;
} | [
"public",
"function",
"getPaymentFeeAmount",
"(",
"Mage_Sales_Model_Quote",
"$",
"quote",
",",
"$",
"store",
"=",
"null",
")",
"{",
"$",
"paymentMethod",
"=",
"$",
"quote",
"->",
"getPayment",
"(",
")",
"->",
"getMethod",
"(",
")",
";",
"if",
"(",
"$",
"... | Get the payment fee amount of the payment method that is selected
@param Mage_Sales_Model_Quote
@return float | [
"Get",
"the",
"payment",
"fee",
"amount",
"of",
"the",
"payment",
"method",
"that",
"is",
"selected"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Helper/Data.php#L73-L85 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Helper/Data.php | Adyen_Fee_Helper_Data.getHppPaymentMethodFee | public function getHppPaymentMethodFee($paymentMethod)
{
$paymentMethod = str_replace('adyen_hpp_', '', $paymentMethod);
$paymentFees = $this->getHppPaymentMethodFees();
if ($paymentFees && is_array($paymentFees) && !empty($paymentFees)) {
foreach ($paymentFees as $paymentFee) {
if (isset($paymentFee['code']) && $paymentFee['code'] == $paymentMethod) {
if (isset($paymentFee['amount'])) {
return $paymentFee['amount'];
}
}
}
}
return null;
} | php | public function getHppPaymentMethodFee($paymentMethod)
{
$paymentMethod = str_replace('adyen_hpp_', '', $paymentMethod);
$paymentFees = $this->getHppPaymentMethodFees();
if ($paymentFees && is_array($paymentFees) && !empty($paymentFees)) {
foreach ($paymentFees as $paymentFee) {
if (isset($paymentFee['code']) && $paymentFee['code'] == $paymentMethod) {
if (isset($paymentFee['amount'])) {
return $paymentFee['amount'];
}
}
}
}
return null;
} | [
"public",
"function",
"getHppPaymentMethodFee",
"(",
"$",
"paymentMethod",
")",
"{",
"$",
"paymentMethod",
"=",
"str_replace",
"(",
"'adyen_hpp_'",
",",
"''",
",",
"$",
"paymentMethod",
")",
";",
"$",
"paymentFees",
"=",
"$",
"this",
"->",
"getHppPaymentMethodFe... | Get the fixed payment method fee amount for the payment method that is selected
@param $paymentMethod
@return paymentFee | [
"Get",
"the",
"fixed",
"payment",
"method",
"fee",
"amount",
"for",
"the",
"payment",
"method",
"that",
"is",
"selected"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Helper/Data.php#L105-L122 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Helper/Data.php | Adyen_Fee_Helper_Data.getPaymentFeeExclVat | public function getPaymentFeeExclVat($address)
{
$config = Mage::getSingleton('adyen_fee/tax_config');
$quote = $address->getQuote();
$store = $quote->getStore();
$fee = $this->getPaymentFeeAmount($quote, $store);
if ($fee && $config->paymentFeePriceIncludesTax($store)) {
$fee -= $this->getPaymentFeeVat($address);
}
return $fee;
} | php | public function getPaymentFeeExclVat($address)
{
$config = Mage::getSingleton('adyen_fee/tax_config');
$quote = $address->getQuote();
$store = $quote->getStore();
$fee = $this->getPaymentFeeAmount($quote, $store);
if ($fee && $config->paymentFeePriceIncludesTax($store)) {
$fee -= $this->getPaymentFeeVat($address);
}
return $fee;
} | [
"public",
"function",
"getPaymentFeeExclVat",
"(",
"$",
"address",
")",
"{",
"$",
"config",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'adyen_fee/tax_config'",
")",
";",
"$",
"quote",
"=",
"$",
"address",
"->",
"getQuote",
"(",
")",
";",
"$",
"store",
"=",
... | Return Payment Fee Exclusive tax
@param $address
@return float | [
"Return",
"Payment",
"Fee",
"Exclusive",
"tax"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Helper/Data.php#L154-L165 | train |
Adyen/adyen-magento | app/code/community/Adyen/Fee/Helper/Data.php | Adyen_Fee_Helper_Data.getPaymentFeeVat | public function getPaymentFeeVat($shippingAddress)
{
$paymentTax = 0;
$quote = $shippingAddress->getQuote();
$store = $quote->getStore();
$fee = $this->getPaymentFeeAmount($quote, $store);
if ($fee) {
$config = Mage::getSingleton('adyen_fee/tax_config');
$custTaxClassId = $quote->getCustomerTaxClassId();
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$request = $taxCalculationModel->getRateRequest(
$shippingAddress, $quote->getBillingAddress(),
$custTaxClassId, $store
);
$paymentTaxClass = $config->getPaymentFeeTaxClass($store);
$rate = $taxCalculationModel->getRate($request->setProductClassId($paymentTaxClass));
if ($rate) {
$paymentTax = $taxCalculationModel->calcTaxAmount(
$fee, $rate,
$config->paymentFeePriceIncludesTax($store), true
);
}
}
return $paymentTax;
} | php | public function getPaymentFeeVat($shippingAddress)
{
$paymentTax = 0;
$quote = $shippingAddress->getQuote();
$store = $quote->getStore();
$fee = $this->getPaymentFeeAmount($quote, $store);
if ($fee) {
$config = Mage::getSingleton('adyen_fee/tax_config');
$custTaxClassId = $quote->getCustomerTaxClassId();
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$request = $taxCalculationModel->getRateRequest(
$shippingAddress, $quote->getBillingAddress(),
$custTaxClassId, $store
);
$paymentTaxClass = $config->getPaymentFeeTaxClass($store);
$rate = $taxCalculationModel->getRate($request->setProductClassId($paymentTaxClass));
if ($rate) {
$paymentTax = $taxCalculationModel->calcTaxAmount(
$fee, $rate,
$config->paymentFeePriceIncludesTax($store), true
);
}
}
return $paymentTax;
} | [
"public",
"function",
"getPaymentFeeVat",
"(",
"$",
"shippingAddress",
")",
"{",
"$",
"paymentTax",
"=",
"0",
";",
"$",
"quote",
"=",
"$",
"shippingAddress",
"->",
"getQuote",
"(",
")",
";",
"$",
"store",
"=",
"$",
"quote",
"->",
"getStore",
"(",
")",
... | Returns the payment fee tax for the payment fee
@param Mage_Sales_Model_Quote_Address $shippingAddress
@return float | [
"Returns",
"the",
"payment",
"fee",
"tax",
"for",
"the",
"payment",
"fee"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Fee/Helper/Data.php#L173-L199 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/System/Config/Backend/Installments.php | Adyen_Payment_Model_System_Config_Backend_Installments._afterLoad | protected function _afterLoad()
{
$value = $this->getValue();
$value = Mage::helper('adyen/installments')->makeArrayFieldValue($value);
$this->setValue($value);
} | php | protected function _afterLoad()
{
$value = $this->getValue();
$value = Mage::helper('adyen/installments')->makeArrayFieldValue($value);
$this->setValue($value);
} | [
"protected",
"function",
"_afterLoad",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"$",
"value",
"=",
"Mage",
"::",
"helper",
"(",
"'adyen/installments'",
")",
"->",
"makeArrayFieldValue",
"(",
"$",
"value",
")",
";",
... | Process data after load | [
"Process",
"data",
"after",
"load"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/System/Config/Backend/Installments.php#L30-L35 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/System/Config/Backend/Installments.php | Adyen_Payment_Model_System_Config_Backend_Installments._beforeSave | protected function _beforeSave()
{
$value = $this->getValue();
$value = Mage::helper('adyen/installments')->makeStorableArrayFieldValue($value);
$this->setValue($value);
} | php | protected function _beforeSave()
{
$value = $this->getValue();
$value = Mage::helper('adyen/installments')->makeStorableArrayFieldValue($value);
$this->setValue($value);
} | [
"protected",
"function",
"_beforeSave",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"$",
"value",
"=",
"Mage",
"::",
"helper",
"(",
"'adyen/installments'",
")",
"->",
"makeStorableArrayFieldValue",
"(",
"$",
"value",
")"... | Prepare data before save | [
"Prepare",
"data",
"before",
"save"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/System/Config/Backend/Installments.php#L40-L45 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/Sales/Billing/Agreement/Grid.php | Adyen_Payment_Block_Adminhtml_Sales_Billing_Agreement_Grid._prepareCollection | protected function _prepareCollection()
{
/** @var Adyen_Payment_Model_Resource_Billing_Agreement_Collection $collection */
$collection = Mage::getResourceModel('adyen/billing_agreement_collection')
->addCustomerDetails();
$collection->addNameToSelect();
$this->setCollection($collection);
call_user_func(array(get_parent_class(get_parent_class($this)), __FUNCTION__));
return $this;
} | php | protected function _prepareCollection()
{
/** @var Adyen_Payment_Model_Resource_Billing_Agreement_Collection $collection */
$collection = Mage::getResourceModel('adyen/billing_agreement_collection')
->addCustomerDetails();
$collection->addNameToSelect();
$this->setCollection($collection);
call_user_func(array(get_parent_class(get_parent_class($this)), __FUNCTION__));
return $this;
} | [
"protected",
"function",
"_prepareCollection",
"(",
")",
"{",
"/** @var Adyen_Payment_Model_Resource_Billing_Agreement_Collection $collection */",
"$",
"collection",
"=",
"Mage",
"::",
"getResourceModel",
"(",
"'adyen/billing_agreement_collection'",
")",
"->",
"addCustomerDetails",... | Prepare collection for grid
@return Mage_Adminhtml_Block_Widget_Grid | [
"Prepare",
"collection",
"for",
"grid"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/Sales/Billing/Agreement/Grid.php#L37-L48 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/Sales/Billing/Agreement/Grid.php | Adyen_Payment_Block_Adminhtml_Sales_Billing_Agreement_Grid._prepareColumns | protected function _prepareColumns()
{
parent::_prepareColumns();
$this->removeColumn('customer_firstname');
$this->removeColumn('customer_lastname');
$this->addColumnAfter(
'agreement_label', array(
'header' => Mage::helper('sales')->__('Agreement Label'),
'index' => 'agreement_label',
'type' => 'text',
), 'status'
);
$this->addColumnAfter(
'name', array(
'header' => Mage::helper('customer')->__('Name'),
'index' => 'name',
'type' => 'text',
'escape' => true
), 'customer_email'
);
// $status = $this->getColumn('status');
// $status->setData('frame_callback', [$this, 'decorateStatus']);
$createdAt = $this->getColumn('created_at');
$createdAt->setData('index', 'created_at');
$createdAt = $this->getColumn('updated_at');
$createdAt->setData('index', 'updated_at');
$this->sortColumnsByOrder();
return $this;
} | php | protected function _prepareColumns()
{
parent::_prepareColumns();
$this->removeColumn('customer_firstname');
$this->removeColumn('customer_lastname');
$this->addColumnAfter(
'agreement_label', array(
'header' => Mage::helper('sales')->__('Agreement Label'),
'index' => 'agreement_label',
'type' => 'text',
), 'status'
);
$this->addColumnAfter(
'name', array(
'header' => Mage::helper('customer')->__('Name'),
'index' => 'name',
'type' => 'text',
'escape' => true
), 'customer_email'
);
// $status = $this->getColumn('status');
// $status->setData('frame_callback', [$this, 'decorateStatus']);
$createdAt = $this->getColumn('created_at');
$createdAt->setData('index', 'created_at');
$createdAt = $this->getColumn('updated_at');
$createdAt->setData('index', 'updated_at');
$this->sortColumnsByOrder();
return $this;
} | [
"protected",
"function",
"_prepareColumns",
"(",
")",
"{",
"parent",
"::",
"_prepareColumns",
"(",
")",
";",
"$",
"this",
"->",
"removeColumn",
"(",
"'customer_firstname'",
")",
";",
"$",
"this",
"->",
"removeColumn",
"(",
"'customer_lastname'",
")",
";",
"$",... | Add columns to grid
@return Mage_Adminhtml_Block_Widget_Grid | [
"Add",
"columns",
"to",
"grid"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/Sales/Billing/Agreement/Grid.php#L55-L91 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Form/Openinvoice.php | Adyen_Payment_Block_Form_Openinvoice.getSortedDateInputs | public function getSortedDateInputs()
{
$strtr = array(
'%b' => '%1$s',
'%B' => '%1$s',
'%m' => '%1$s',
'%d' => '%2$s',
'%e' => '%2$s',
'%Y' => '%3$s',
'%y' => '%3$s'
);
$dateFormat = preg_replace('/[^\%\w]/', '\\1', $this->getDateFormat());
return sprintf(
strtr($dateFormat, $strtr),
$this->_dateInputs['m'], $this->_dateInputs['d'], $this->_dateInputs['y']
);
} | php | public function getSortedDateInputs()
{
$strtr = array(
'%b' => '%1$s',
'%B' => '%1$s',
'%m' => '%1$s',
'%d' => '%2$s',
'%e' => '%2$s',
'%Y' => '%3$s',
'%y' => '%3$s'
);
$dateFormat = preg_replace('/[^\%\w]/', '\\1', $this->getDateFormat());
return sprintf(
strtr($dateFormat, $strtr),
$this->_dateInputs['m'], $this->_dateInputs['d'], $this->_dateInputs['y']
);
} | [
"public",
"function",
"getSortedDateInputs",
"(",
")",
"{",
"$",
"strtr",
"=",
"array",
"(",
"'%b'",
"=>",
"'%1$s'",
",",
"'%B'",
"=>",
"'%1$s'",
",",
"'%m'",
"=>",
"'%1$s'",
",",
"'%d'",
"=>",
"'%2$s'",
",",
"'%e'",
"=>",
"'%2$s'",
",",
"'%Y'",
"=>",
... | Sort date inputs by dateformat order of current locale
@return string | [
"Sort",
"date",
"inputs",
"by",
"dateformat",
"order",
"of",
"current",
"locale"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Form/Openinvoice.php#L143-L161 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment.php | Adyen_Payment_Helper_Payment.adyenValueArray | public function adyenValueArray(
$orderCurrencyCode,
$shopperEmail,
$customerId,
$merchantAccount,
$merchantReference,
$amount,
$shipBeforeDate,
$skinCode,
$shopperLocale,
$countryCode,
$recurringType,
$dataString,
$browserInfo,
$shopperIP,
$billingAddressType,
$deliveryAddressType,
$shopperType,
$issuerId,
$returnUrl,
$brandCode,
$shopperInfo,
$billingAddress,
$deliveryAddress,
$openInvoiceData,
$dfValue = null
) {
$adyFields = array(
'merchantAccount' => $merchantAccount,
'merchantReference' => $merchantReference,
'paymentAmount' => (int)$amount,
'currencyCode' => $orderCurrencyCode,
'shipBeforeDate' => $shipBeforeDate->format('Y-m-d'),
'skinCode' => $skinCode,
'shopperLocale' => $shopperLocale,
'countryCode' => $countryCode,
'sessionValidity' => $shipBeforeDate->format("c"),
'shopperEmail' => $shopperEmail,
'recurringContract' => $recurringType,
'shopperReference' => $customerId,
'shopperIP' => $shopperIP,
'browserInfo' => $browserInfo,
'resURL' => $returnUrl,
'merchantReturnData' => substr(urlencode($dataString), 0, 128),
// @todo remove this and add allowed methods via a config xml node
'blockedMethods' => "",
// Will only work if billingAddress, deliveryAddress and shopperInfo is in request
'billingAddressType' => $billingAddressType,
'deliveryAddressType' => $deliveryAddressType,
'shopperType' => $shopperType
);
if (!empty($issuerId)) {
$adyFields["issuerId"] = $issuerId;
}
// explode details for request
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'shopper', $shopperInfo);
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'billingAddress', $billingAddress);
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'deliveryAddress', $deliveryAddress);
// merge openInvoiceData
$adyFields = $adyFields + $openInvoiceData;
// Add brandCode if payment selection is done
if ($brandCode) {
$adyFields['brandCode'] = $brandCode;
}
if ($dfValue) {
$adyFields['dfValue'] = $dfValue;
}
return $adyFields;
} | php | public function adyenValueArray(
$orderCurrencyCode,
$shopperEmail,
$customerId,
$merchantAccount,
$merchantReference,
$amount,
$shipBeforeDate,
$skinCode,
$shopperLocale,
$countryCode,
$recurringType,
$dataString,
$browserInfo,
$shopperIP,
$billingAddressType,
$deliveryAddressType,
$shopperType,
$issuerId,
$returnUrl,
$brandCode,
$shopperInfo,
$billingAddress,
$deliveryAddress,
$openInvoiceData,
$dfValue = null
) {
$adyFields = array(
'merchantAccount' => $merchantAccount,
'merchantReference' => $merchantReference,
'paymentAmount' => (int)$amount,
'currencyCode' => $orderCurrencyCode,
'shipBeforeDate' => $shipBeforeDate->format('Y-m-d'),
'skinCode' => $skinCode,
'shopperLocale' => $shopperLocale,
'countryCode' => $countryCode,
'sessionValidity' => $shipBeforeDate->format("c"),
'shopperEmail' => $shopperEmail,
'recurringContract' => $recurringType,
'shopperReference' => $customerId,
'shopperIP' => $shopperIP,
'browserInfo' => $browserInfo,
'resURL' => $returnUrl,
'merchantReturnData' => substr(urlencode($dataString), 0, 128),
// @todo remove this and add allowed methods via a config xml node
'blockedMethods' => "",
// Will only work if billingAddress, deliveryAddress and shopperInfo is in request
'billingAddressType' => $billingAddressType,
'deliveryAddressType' => $deliveryAddressType,
'shopperType' => $shopperType
);
if (!empty($issuerId)) {
$adyFields["issuerId"] = $issuerId;
}
// explode details for request
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'shopper', $shopperInfo);
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'billingAddress', $billingAddress);
$adyFields = $this->explodeArrayToRequestFields($adyFields, 'deliveryAddress', $deliveryAddress);
// merge openInvoiceData
$adyFields = $adyFields + $openInvoiceData;
// Add brandCode if payment selection is done
if ($brandCode) {
$adyFields['brandCode'] = $brandCode;
}
if ($dfValue) {
$adyFields['dfValue'] = $dfValue;
}
return $adyFields;
} | [
"public",
"function",
"adyenValueArray",
"(",
"$",
"orderCurrencyCode",
",",
"$",
"shopperEmail",
",",
"$",
"customerId",
",",
"$",
"merchantAccount",
",",
"$",
"merchantReference",
",",
"$",
"amount",
",",
"$",
"shipBeforeDate",
",",
"$",
"skinCode",
",",
"$"... | Format the data in a specific array
@param $orderCurrencyCode
@param $shopperEmail
@param $customerId
@param $merchantAccount
@param $merchantReference
@param $amount
@param $shipBeforeDate
@param $skinCode
@param $shopperLocale
@param $countryCode
@param $recurringType
@param $dataString
@param $browserInfo
@param $shopperIP
@param $billingAddressType
@param $deliveryAddressType
@param $shopperType
@param $issuerId
@param $returnUrl
@param $brandCode
@param $shopperInfo
@param $billingAddress
@param $deliveryAddress
@param $openInvoiceData
@return array | [
"Format",
"the",
"data",
"in",
"a",
"specific",
"array"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment.php#L310-L384 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment.php | Adyen_Payment_Helper_Payment.isHighVatCategory | public function isHighVatCategory($paymentMethod)
{
if ($this->isOpenInvoiceMethod($paymentMethod->getMethod()) || Mage::helper('adyen')->isAfterPay($paymentMethod->getMethodInstance()->getInfoInstance()->getCcType())) {
return true;
}
return false;
} | php | public function isHighVatCategory($paymentMethod)
{
if ($this->isOpenInvoiceMethod($paymentMethod->getMethod()) || Mage::helper('adyen')->isAfterPay($paymentMethod->getMethodInstance()->getInfoInstance()->getCcType())) {
return true;
}
return false;
} | [
"public",
"function",
"isHighVatCategory",
"(",
"$",
"paymentMethod",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOpenInvoiceMethod",
"(",
"$",
"paymentMethod",
"->",
"getMethod",
"(",
")",
")",
"||",
"Mage",
"::",
"helper",
"(",
"'adyen'",
")",
"->",
"isAf... | Checks if HigVat Cateogry is needed
@param $paymentMethod
@return bool | [
"Checks",
"if",
"HigVat",
"Cateogry",
"is",
"needed"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment.php#L822-L829 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Helper/Payment.php | Adyen_Payment_Helper_Payment.isOpenInvoiceMethod | public function isOpenInvoiceMethod($method)
{
$openinvoiceType = $this->getConfigData('openinvoicetypes', Adyen_Payment_Model_Adyen_Openinvoice::METHODCODE);
if ($method == Adyen_Payment_Model_Adyen_Openinvoice::METHODCODE && $openinvoiceType == self::AFTERPAY_DEFAULT) {
return true;
}
return false;
} | php | public function isOpenInvoiceMethod($method)
{
$openinvoiceType = $this->getConfigData('openinvoicetypes', Adyen_Payment_Model_Adyen_Openinvoice::METHODCODE);
if ($method == Adyen_Payment_Model_Adyen_Openinvoice::METHODCODE && $openinvoiceType == self::AFTERPAY_DEFAULT) {
return true;
}
return false;
} | [
"public",
"function",
"isOpenInvoiceMethod",
"(",
"$",
"method",
")",
"{",
"$",
"openinvoiceType",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
"'openinvoicetypes'",
",",
"Adyen_Payment_Model_Adyen_Openinvoice",
"::",
"METHODCODE",
")",
";",
"if",
"(",
"$",
"meth... | Check if the payment method is openinvoice and the payment method type is afterpay_default
@param $method
@return bool | [
"Check",
"if",
"the",
"payment",
"method",
"is",
"openinvoice",
"and",
"the",
"payment",
"method",
"type",
"is",
"afterpay_default"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Helper/Payment.php#L837-L846 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Adyen/Cc.php | Adyen_Payment_Model_Adyen_Cc.getFormUrl | public function getFormUrl()
{
$this->_initOrder();
$order = $this->_order;
$payment = $order->getPayment();
return $payment->getAdditionalInformation('issuerUrl');
} | php | public function getFormUrl()
{
$this->_initOrder();
$order = $this->_order;
$payment = $order->getPayment();
return $payment->getAdditionalInformation('issuerUrl');
} | [
"public",
"function",
"getFormUrl",
"(",
")",
"{",
"$",
"this",
"->",
"_initOrder",
"(",
")",
";",
"$",
"order",
"=",
"$",
"this",
"->",
"_order",
";",
"$",
"payment",
"=",
"$",
"order",
"->",
"getPayment",
"(",
")",
";",
"return",
"$",
"payment",
... | This method is called for redirect to 3D secure
@return mixed | [
"This",
"method",
"is",
"called",
"for",
"redirect",
"to",
"3D",
"secure"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Adyen/Cc.php#L137-L143 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Form/Cc.php | Adyen_Payment_Block_Form_Cc.hasVerification | public function hasVerification()
{
// if backend order and moto payments is turned on don't show cvc
if (Mage::app()->getStore()->isAdmin() && $this->getMethod()->getCode() == "adyen_cc") {
$store = Mage::getSingleton('adminhtml/session_quote')->getStore();
if (Mage::getStoreConfigFlag('payment/adyen_cc/enable_moto', $store)) {
return false;
}
}
return true;
} | php | public function hasVerification()
{
// if backend order and moto payments is turned on don't show cvc
if (Mage::app()->getStore()->isAdmin() && $this->getMethod()->getCode() == "adyen_cc") {
$store = Mage::getSingleton('adminhtml/session_quote')->getStore();
if (Mage::getStoreConfigFlag('payment/adyen_cc/enable_moto', $store)) {
return false;
}
}
return true;
} | [
"public",
"function",
"hasVerification",
"(",
")",
"{",
"// if backend order and moto payments is turned on don't show cvc",
"if",
"(",
"Mage",
"::",
"app",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"isAdmin",
"(",
")",
"&&",
"$",
"this",
"->",
"getMethod",
"(... | If MOTO for backend orders is turned on don't show CVC field in backend order creation
@return boolean | [
"If",
"MOTO",
"for",
"backend",
"orders",
"is",
"turned",
"on",
"don",
"t",
"show",
"CVC",
"field",
"in",
"backend",
"order",
"creation"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Form/Cc.php#L116-L128 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Model/Resource/Order/Payment.php | Adyen_Payment_Model_Resource_Order_Payment._prepareDataForSave | protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
{
$currentTime = Varien_Date::now();
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
$object->setCreatedAt($currentTime);
}
$object->setUpdatedAt($currentTime);
$data = parent::_prepareDataForSave($object);
return $data;
} | php | protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
{
$currentTime = Varien_Date::now();
if ((!$object->getId() || $object->isObjectNew()) && !$object->getCreatedAt()) {
$object->setCreatedAt($currentTime);
}
$object->setUpdatedAt($currentTime);
$data = parent::_prepareDataForSave($object);
return $data;
} | [
"protected",
"function",
"_prepareDataForSave",
"(",
"Mage_Core_Model_Abstract",
"$",
"object",
")",
"{",
"$",
"currentTime",
"=",
"Varien_Date",
"::",
"now",
"(",
")",
";",
"if",
"(",
"(",
"!",
"$",
"object",
"->",
"getId",
"(",
")",
"||",
"$",
"object",
... | Prepare data for save
@param Mage_Core_Model_Abstract $object
@return array | [
"Prepare",
"data",
"for",
"save"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Model/Resource/Order/Payment.php#L41-L51 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/ApplePay.php | Adyen_Payment_Block_ApplePay.getSubtotalInclTax | public function getSubtotalInclTax()
{
$cart = Mage::getModel('checkout/cart');
$subtotal = 0;
$totals = $cart->getQuote()->getTotals();
// calculate subtotal from grand total and shipping
// ignore Magento tax config, add tax to shipping depending on country
$total = $shipping = 0;
if(isset($totals['grand_total']) && $totals['grand_total']->getValue()) {
$total = $totals["grand_total"]->getValue();
}
if(isset($totals['shipping']) && $totals['shipping']->getValue()) {
$shipping = $totals["shipping"]->getValue();
$address = $cart->getQuote()->getShippingAddress();
$shipping = Mage::helper('tax')->getShippingPrice($shipping, true, $address);
}
$subtotal = $total - $shipping;
return $subtotal;
} | php | public function getSubtotalInclTax()
{
$cart = Mage::getModel('checkout/cart');
$subtotal = 0;
$totals = $cart->getQuote()->getTotals();
// calculate subtotal from grand total and shipping
// ignore Magento tax config, add tax to shipping depending on country
$total = $shipping = 0;
if(isset($totals['grand_total']) && $totals['grand_total']->getValue()) {
$total = $totals["grand_total"]->getValue();
}
if(isset($totals['shipping']) && $totals['shipping']->getValue()) {
$shipping = $totals["shipping"]->getValue();
$address = $cart->getQuote()->getShippingAddress();
$shipping = Mage::helper('tax')->getShippingPrice($shipping, true, $address);
}
$subtotal = $total - $shipping;
return $subtotal;
} | [
"public",
"function",
"getSubtotalInclTax",
"(",
")",
"{",
"$",
"cart",
"=",
"Mage",
"::",
"getModel",
"(",
"'checkout/cart'",
")",
";",
"$",
"subtotal",
"=",
"0",
";",
"$",
"totals",
"=",
"$",
"cart",
"->",
"getQuote",
"(",
")",
"->",
"getTotals",
"("... | Re-using subtotal calculation from Mage_Checkout_Block_Cart_Sidebar
@return decimal subtotal amount including tax | [
"Re",
"-",
"using",
"subtotal",
"calculation",
"from",
"Mage_Checkout_Block_Cart_Sidebar"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/ApplePay.php#L81-L99 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/ApplePay.php | Adyen_Payment_Block_ApplePay.optionToChangeAddress | public function optionToChangeAddress()
{
if (!$this->onReviewStep()) {
if (!Mage::helper('adyen')->getConfigData('allow_quest_checkout', 'adyen_apple_pay')) {
return Mage::helper('adyen')->getConfigData('change_address', 'adyen_apple_pay');
}
return true;
}
return false;
} | php | public function optionToChangeAddress()
{
if (!$this->onReviewStep()) {
if (!Mage::helper('adyen')->getConfigData('allow_quest_checkout', 'adyen_apple_pay')) {
return Mage::helper('adyen')->getConfigData('change_address', 'adyen_apple_pay');
}
return true;
}
return false;
} | [
"public",
"function",
"optionToChangeAddress",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"onReviewStep",
"(",
")",
")",
"{",
"if",
"(",
"!",
"Mage",
"::",
"helper",
"(",
"'adyen'",
")",
"->",
"getConfigData",
"(",
"'allow_quest_checkout'",
",",
"... | Only possible if quest checkout is turned off
@return bool | [
"Only",
"possible",
"if",
"quest",
"checkout",
"is",
"turned",
"off"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/ApplePay.php#L324-L335 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/ApplePay.php | Adyen_Payment_Block_ApplePay.getShippingMethodAmount | public function getShippingMethodAmount()
{
$address = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
$amount = $address->getShippingAmount();
return Mage::helper('tax')->getShippingPrice($amount, true, $address);
} | php | public function getShippingMethodAmount()
{
$address = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
$amount = $address->getShippingAmount();
return Mage::helper('tax')->getShippingPrice($amount, true, $address);
} | [
"public",
"function",
"getShippingMethodAmount",
"(",
")",
"{",
"$",
"address",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'checkout/session'",
")",
"->",
"getQuote",
"(",
")",
"->",
"getShippingAddress",
"(",
")",
";",
"$",
"amount",
"=",
"$",
"address",
"->"... | This is called when you are in the review step of the payment and use Apple Pay | [
"This",
"is",
"called",
"when",
"you",
"are",
"in",
"the",
"review",
"step",
"of",
"the",
"payment",
"and",
"use",
"Apple",
"Pay"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/ApplePay.php#L340-L345 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/controllers/PosController.php | Adyen_Payment_PosController.placeOrderAction | public function placeOrderAction()
{
$quote = (Mage::getModel('checkout/type_onepage') !== false) ? Mage::getModel('checkout/type_onepage')->getQuote() : Mage::getModel('checkout/session')->getQuote();
$service = Mage::getModel('sales/service_quote', $quote);
$quote->getPayment()->setMethod('adyen_pos_cloud');
$quote->collectTotals()->save();
try {
$service->submitAll();
$order = $service->getOrder();
$order->save();
$result = self::ORDER_SUCCESS;
// add order information to the session
$session = Mage::getSingleton('checkout/session');
$session->setLastOrderId($order->getId());
$session->setLastRealOrderId($order->getIncrementId());
$session->setLastSuccessQuoteId($order->getQuoteId());
$session->setLastQuoteId($order->getQuoteId());
$session->unsAdyenRealOrderId();
$session->setQuoteId($session->getAdyenQuoteId(true));
$session->getQuote()->setIsActive(false)->save();
} catch (Exception $e) {
Mage::logException($e);
$result = self::ORDER_ERROR;
}
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody($result);
return $result;
} | php | public function placeOrderAction()
{
$quote = (Mage::getModel('checkout/type_onepage') !== false) ? Mage::getModel('checkout/type_onepage')->getQuote() : Mage::getModel('checkout/session')->getQuote();
$service = Mage::getModel('sales/service_quote', $quote);
$quote->getPayment()->setMethod('adyen_pos_cloud');
$quote->collectTotals()->save();
try {
$service->submitAll();
$order = $service->getOrder();
$order->save();
$result = self::ORDER_SUCCESS;
// add order information to the session
$session = Mage::getSingleton('checkout/session');
$session->setLastOrderId($order->getId());
$session->setLastRealOrderId($order->getIncrementId());
$session->setLastSuccessQuoteId($order->getQuoteId());
$session->setLastQuoteId($order->getQuoteId());
$session->unsAdyenRealOrderId();
$session->setQuoteId($session->getAdyenQuoteId(true));
$session->getQuote()->setIsActive(false)->save();
} catch (Exception $e) {
Mage::logException($e);
$result = self::ORDER_ERROR;
}
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody($result);
return $result;
} | [
"public",
"function",
"placeOrderAction",
"(",
")",
"{",
"$",
"quote",
"=",
"(",
"Mage",
"::",
"getModel",
"(",
"'checkout/type_onepage'",
")",
"!==",
"false",
")",
"?",
"Mage",
"::",
"getModel",
"(",
"'checkout/type_onepage'",
")",
"->",
"getQuote",
"(",
")... | Places the order after a PAYMENT_SUCCESSFUL from
@see initiateAction or
@see checkStatusAction
@return string | [
"Places",
"the",
"order",
"after",
"a",
"PAYMENT_SUCCESSFUL",
"from"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/controllers/PosController.php#L274-L305 | train |
Adyen/adyen-magento | app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php | Adyen_Payment_Block_Adminhtml_System_Config_Fieldset_Expanded._getCollapseState | protected function _getCollapseState($element)
{
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
if (isset($extra['configState'][$element->getId()])) {
return $extra['configState'][$element->getId()];
}
return true;
} | php | protected function _getCollapseState($element)
{
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
if (isset($extra['configState'][$element->getId()])) {
return $extra['configState'][$element->getId()];
}
return true;
} | [
"protected",
"function",
"_getCollapseState",
"(",
"$",
"element",
")",
"{",
"$",
"extra",
"=",
"Mage",
"::",
"getSingleton",
"(",
"'admin/session'",
")",
"->",
"getUser",
"(",
")",
"->",
"getExtra",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"extra",
... | Return collapse state
@param Varien_Data_Form_Element_Abstract $element
@return bool | [
"Return",
"collapse",
"state"
] | 0abad647d354d88c2193a2dee1bc281f154124ec | https://github.com/Adyen/adyen-magento/blob/0abad647d354d88c2193a2dee1bc281f154124ec/app/code/community/Adyen/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php#L40-L48 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolReader.php | ProtocolReader.consumeTable | public function consumeTable(Buffer $originalBuffer)
{
$buffer = $originalBuffer->consumeSlice($originalBuffer->consumeUint32());
$data = [];
while (!$buffer->isEmpty()) {
$data[$buffer->consume($buffer->consumeUint8())] = $this->consumeFieldValue($buffer);
}
return $data;
} | php | public function consumeTable(Buffer $originalBuffer)
{
$buffer = $originalBuffer->consumeSlice($originalBuffer->consumeUint32());
$data = [];
while (!$buffer->isEmpty()) {
$data[$buffer->consume($buffer->consumeUint8())] = $this->consumeFieldValue($buffer);
}
return $data;
} | [
"public",
"function",
"consumeTable",
"(",
"Buffer",
"$",
"originalBuffer",
")",
"{",
"$",
"buffer",
"=",
"$",
"originalBuffer",
"->",
"consumeSlice",
"(",
"$",
"originalBuffer",
"->",
"consumeUint32",
"(",
")",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
... | Consumes AMQP table from buffer.
@param Buffer $originalBuffer
@return array | [
"Consumes",
"AMQP",
"table",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolReader.php#L156-L166 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolReader.php | ProtocolReader.consumeArray | public function consumeArray(Buffer $originalBuffer)
{
$buffer = $originalBuffer->consumeSlice($originalBuffer->consumeUint32());
$data = [];
while (!$buffer->isEmpty()) {
$data[] = $this->consumeFieldValue($buffer);
}
return $data;
} | php | public function consumeArray(Buffer $originalBuffer)
{
$buffer = $originalBuffer->consumeSlice($originalBuffer->consumeUint32());
$data = [];
while (!$buffer->isEmpty()) {
$data[] = $this->consumeFieldValue($buffer);
}
return $data;
} | [
"public",
"function",
"consumeArray",
"(",
"Buffer",
"$",
"originalBuffer",
")",
"{",
"$",
"buffer",
"=",
"$",
"originalBuffer",
"->",
"consumeSlice",
"(",
"$",
"originalBuffer",
"->",
"consumeUint32",
"(",
")",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
... | Consumes AMQP array from buffer.
@param Buffer $originalBuffer
@return array | [
"Consumes",
"AMQP",
"array",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolReader.php#L174-L182 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolReader.php | ProtocolReader.consumeTimestamp | public function consumeTimestamp(Buffer $buffer)
{
$d = new \DateTime();
$d->setTimestamp($buffer->consumeUint64());
return $d;
} | php | public function consumeTimestamp(Buffer $buffer)
{
$d = new \DateTime();
$d->setTimestamp($buffer->consumeUint64());
return $d;
} | [
"public",
"function",
"consumeTimestamp",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"d",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"d",
"->",
"setTimestamp",
"(",
"$",
"buffer",
"->",
"consumeUint64",
"(",
")",
")",
";",
"return",
"$",
"d"... | Consumes AMQP timestamp from buffer.
@param Buffer $buffer
@return \DateTime | [
"Consumes",
"AMQP",
"timestamp",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolReader.php#L190-L195 | train |
jakubkulhan/bunny | src/Bunny/Protocol/ProtocolReader.php | ProtocolReader.consumeBits | public function consumeBits(Buffer $buffer, $n)
{
$bits = [];
$value = $buffer->consumeUint8();
for ($i = 0; $i < $n; ++$i) {
$bits[] = ($value & (1 << $i)) > 0;
}
return $bits;
} | php | public function consumeBits(Buffer $buffer, $n)
{
$bits = [];
$value = $buffer->consumeUint8();
for ($i = 0; $i < $n; ++$i) {
$bits[] = ($value & (1 << $i)) > 0;
}
return $bits;
} | [
"public",
"function",
"consumeBits",
"(",
"Buffer",
"$",
"buffer",
",",
"$",
"n",
")",
"{",
"$",
"bits",
"=",
"[",
"]",
";",
"$",
"value",
"=",
"$",
"buffer",
"->",
"consumeUint8",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
... | Consumes packed bits from buffer.
@param Buffer $buffer
@param int $n
@return array | [
"Consumes",
"packed",
"bits",
"from",
"buffer",
"."
] | 05c431a0379ae89278aa23e7c1704ffecb180657 | https://github.com/jakubkulhan/bunny/blob/05c431a0379ae89278aa23e7c1704ffecb180657/src/Bunny/Protocol/ProtocolReader.php#L204-L212 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.