first commit
This commit is contained in:
8
app/Core/Contracts/MailInterface.php
Normal file
8
app/Core/Contracts/MailInterface.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Contracts;
|
||||
|
||||
interface MailInterface
|
||||
{
|
||||
public function process (array $params = null);
|
||||
}
|
||||
196
app/Core/Helper/LanguageService.php
Normal file
196
app/Core/Helper/LanguageService.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Helper;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LanguageService
|
||||
{
|
||||
private static $currentLanguage = null;
|
||||
private static $languageSupportList = null;
|
||||
private static $languageSupportCacheName = "langSupportCache";
|
||||
|
||||
public static function getDefaultLang()
|
||||
{
|
||||
return config("languageSupport.defaultLanguage");
|
||||
}
|
||||
|
||||
public static function getCurrentLang ( )
|
||||
{
|
||||
$language = self::$currentLanguage;
|
||||
$language = $language ? $language : self::getDefaultLang();
|
||||
return $language;
|
||||
}
|
||||
|
||||
public static function isValidLanguage ( $language )
|
||||
{
|
||||
$validLanguages = self::getValidLanguages();
|
||||
return in_array($language,$validLanguages);
|
||||
}
|
||||
|
||||
public static function getCurrentLangPack($language = null)
|
||||
{
|
||||
$language = $language ? $language : self::getCurrentLang();
|
||||
return config("language-pack-".$language);
|
||||
}
|
||||
|
||||
|
||||
public static function setCurrentLanguage($language)
|
||||
{
|
||||
$language = strtolower($language);
|
||||
self::$currentLanguage = self::isValidLanguage($language) ? $language : config("languageSupport.defaultLanguage");
|
||||
return self::$currentLanguage;
|
||||
}
|
||||
|
||||
public static function getValidLanguages ( $except = null )
|
||||
{
|
||||
return collect(config("languageSupport.availableLanguages"))->flip()->except($except)->flip()->toArray();
|
||||
}
|
||||
|
||||
public static function getAllLangPackages()
|
||||
{
|
||||
$langPackages = [];
|
||||
$validSystemLanguages = self::getValidLanguages();
|
||||
foreach ($validSystemLanguages as $perLanguage)
|
||||
{
|
||||
$langPackages[$perLanguage] = self::getCurrentLangPack($perLanguage);
|
||||
}
|
||||
return $langPackages;
|
||||
}
|
||||
|
||||
public static function convertAllLanguageSettingsAndCache()
|
||||
{
|
||||
$cacheParam = [];
|
||||
$wordIndexCounter = 0;
|
||||
$allLangPackages = self::getAllLangPackages();
|
||||
$systemDefaultLang = self::getDefaultLang();
|
||||
|
||||
foreach ($allLangPackages[$systemDefaultLang] as $perLangKey => $perLangWord)
|
||||
{
|
||||
$cacheParam[$wordIndexCounter]["md5"] = self::convertToMd5ForMultiLanguage($perLangWord);
|
||||
|
||||
foreach ($allLangPackages as $perLangPackKey => $perLangPack)
|
||||
{
|
||||
$cacheParam[$wordIndexCounter][$perLangPackKey] = $perLangPack[$wordIndexCounter];
|
||||
}
|
||||
$wordIndexCounter++;
|
||||
}
|
||||
|
||||
$cacheParam = collect($cacheParam)->keyBy("md5")->toArray();
|
||||
Cache::put(self::$languageSupportCacheName,$cacheParam,120);
|
||||
return $cacheParam;
|
||||
}
|
||||
|
||||
public static function getLanguageSupportList()
|
||||
{
|
||||
$cachedData = self::$languageSupportList;
|
||||
if ( !$cachedData)
|
||||
{
|
||||
$cachedData = Cache::get(self::$languageSupportCacheName);
|
||||
self::$languageSupportList = $cachedData;
|
||||
}
|
||||
$cachedData = $cachedData ? $cachedData : self::convertAllLanguageSettingsAndCache();
|
||||
return $cachedData;
|
||||
}
|
||||
|
||||
|
||||
private static function makeSlugForMultiLanguage( $word )
|
||||
{
|
||||
$word = lowerCase($word);
|
||||
preg_match_all("#[\pL\d+]+#iu",$word,$results);
|
||||
$results = $results[0];
|
||||
$converted = implode("",$results);
|
||||
return $converted;
|
||||
}
|
||||
|
||||
public static function convertToMd5ForMultiLanguage($word)
|
||||
{
|
||||
/*Clear The Parameters*/
|
||||
$word = preg_replace('/\{\#\d+\}/',"",$word);
|
||||
/**/
|
||||
/*Clear From Html*/
|
||||
$word = strip_tags($word);
|
||||
/**/
|
||||
$word = self::makeSlugForMultiLanguage($word);
|
||||
return md5($word);
|
||||
}
|
||||
|
||||
|
||||
public static function findWordForLanguage($word,$lang,array $parameters = [])
|
||||
{
|
||||
$md5Key = self::convertToMd5ForMultiLanguage($word);
|
||||
$langSupportList = self::getLanguageSupportList();
|
||||
$converted = fillOnUndefined($langSupportList,$md5Key.".".$lang);
|
||||
$converted = $converted ? $converted : fillOnUndefined($langSupportList,$md5Key.".".self::getDefaultLang());
|
||||
$converted = $converted ? $converted : $word;
|
||||
|
||||
/*Inject Parameters*/
|
||||
$parameters = reIndexArrayKeys($parameters,1);
|
||||
foreach ($parameters as $perParameterKey => $perParameter)
|
||||
{
|
||||
$converted = preg_replace('/\{\#'.$perParameterKey.'\}/',$perParameter,$converted);
|
||||
}
|
||||
/**/
|
||||
|
||||
return $converted;
|
||||
}
|
||||
|
||||
public static function lang ( $word,array $parameters = [],$lang = null )
|
||||
{
|
||||
$lang = $lang ? : self::$currentLanguage;
|
||||
return self::findWordForLanguage($word,$lang,$parameters);
|
||||
}
|
||||
|
||||
public static function langArrayStack ( array $langParamStack )
|
||||
{
|
||||
$result = [];
|
||||
$validCases = ["lower","title","upper"];
|
||||
|
||||
foreach ($langParamStack as $perLangParam)
|
||||
{
|
||||
$word = castToString(fillOnUndefined($perLangParam,"word"));
|
||||
$parameters = fillOnUndefined($perLangParam,"parameters",[]);
|
||||
$lang = castToString(fillOnUndefined($perLangParam,"lang"));
|
||||
$case = lowerCase(castToString(fillOnUndefined($perLangParam,"case")));
|
||||
$case = in_array($case,$validCases) ? $case : null;
|
||||
$caseFunction = $case ? camel_case("lang".$case."case") : "lang";
|
||||
$result[] = self::$caseFunction($word,$parameters,$lang);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function langArray ( array $words, $lang = null )
|
||||
{
|
||||
$result = [];
|
||||
foreach ($words as $perWord)
|
||||
{
|
||||
$result[] = self::lang($perWord, [], $lang);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function langLowerCase($word,array $parameters = [],$lang = null)
|
||||
{
|
||||
$lang = $lang ? : self::getCurrentLang();
|
||||
$translated = self::lang($word, $parameters,$lang);
|
||||
return $lang == "tr" ? lowerCase($translated) : mb_strtolower($translated);
|
||||
}
|
||||
|
||||
public static function langTitleCase($word,array $parameters = [],$lang = null)
|
||||
{
|
||||
$lang = $lang ? : self::getCurrentLang();
|
||||
$translated = self::lang($word, $parameters,$lang);
|
||||
return $lang == "tr" ? uCase($translated) : mb_convert_case($translated,MB_CASE_TITLE);
|
||||
}
|
||||
|
||||
public static function langUpperCase($word,array $parameters = [],$lang = null)
|
||||
{
|
||||
$lang = $lang ? : self::getCurrentLang();
|
||||
$translated = self::lang($word, $parameters,$lang);
|
||||
return $lang == "tr" ? upperCase($translated) : mb_strtoupper($translated);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
570
app/Core/Helper/PhpHelper.php
Normal file
570
app/Core/Helper/PhpHelper.php
Normal file
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Helper;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
|
||||
class PhpHelper {
|
||||
|
||||
private static $days = [
|
||||
'Pazartesi',
|
||||
'Salı',
|
||||
'Çarşamba',
|
||||
'Perşembe',
|
||||
'Cuma',
|
||||
'Cumartesi',
|
||||
'Pazar',
|
||||
];
|
||||
private static $months = [
|
||||
'Ocak',
|
||||
'Şubat',
|
||||
'Mart',
|
||||
'Nisan',
|
||||
'Mayıs',
|
||||
'Haziran',
|
||||
'Temmuz',
|
||||
'Ağustos',
|
||||
'Eylül',
|
||||
'Ekim',
|
||||
'Kasım',
|
||||
'Aralık',
|
||||
];
|
||||
private static $encryptionKey = 'd0a7e7997b6d5fcd55f4b5c32611b87cd923e88837b63bf2941ef819dc8ca282';
|
||||
|
||||
public static function json_decode($input) {
|
||||
return json_decode($input);
|
||||
}
|
||||
|
||||
public static function json_encode($input) {
|
||||
return json_encode($input);
|
||||
}
|
||||
|
||||
public static function pre($input) {
|
||||
echo '<pre>';
|
||||
print_r($input);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the difference between two dates
|
||||
* (30 years, 9 months, 25 days, 21 hours, 33 minutes, 3 seconds).
|
||||
*
|
||||
* @param string $start starting date
|
||||
* @param string $end=false ending date
|
||||
*
|
||||
* @return string formatted date difference
|
||||
*/
|
||||
public static function dateDiff($start, $end = false) {$return = [];
|
||||
|
||||
try {
|
||||
$start = new DateTime($start);
|
||||
$end = new DateTime($end);
|
||||
$form = $start->diff($end);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
$display = ['y' => 'Yıl', 'm' => 'Ay', 'd' => 'Gün', 'h' => 'Saat', 'i' => 'Dakika', 's' => 'Saniye'];
|
||||
|
||||
foreach ($display as $key => $value) {
|
||||
if ($form->$key > 0) {
|
||||
$return[] = $form->$key . ' ' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
return implode($return, ', ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the day count between two dates
|
||||
* (3 days).
|
||||
*
|
||||
* @param string $start starting date
|
||||
* @param string $end=false ending date
|
||||
*
|
||||
* @return string day count
|
||||
*/
|
||||
public static function dayCount($end, $start) {
|
||||
$return = [];
|
||||
|
||||
try {
|
||||
$start = new DateTime($start);
|
||||
$end = new DateTime($end);
|
||||
$form = $start->diff($end);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return $form->days;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the day and month name
|
||||
* (16 July).
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function dayNumberAndMonthWord($date) {
|
||||
return date('d', strtotime($date)) . ' ' . self::$months[date('m', strtotime($date)) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the month name
|
||||
* (July).
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function monthName($date) {
|
||||
return self::$months[date('m', strtotime($date)) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the day name
|
||||
* (Sunday).
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function dayName($date) {
|
||||
return self::$days[date('N', strtotime($date)) - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the day number
|
||||
* 01.
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function dayNumber($date) {
|
||||
return date('d', strtotime($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the human readable day
|
||||
* 01.
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function humanReadableDateWithDay($date) {
|
||||
return date('d', strtotime($date)) . ' ' . self::$months[date('m', strtotime($date)) - 1] . ' ' . date('Y', strtotime($date)) . ', ' . self::dayName($date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the human readable day
|
||||
* 01.
|
||||
*
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function humanReadableDate($date) {
|
||||
return date('d-m-Y H:i:s', strtotime($date));
|
||||
}
|
||||
|
||||
public static function humanReadableDateWithoutClock($date) {
|
||||
return date('d-m-Y', strtotime($date));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date date
|
||||
*
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function sqlDate($date) {
|
||||
$date = date('Y-m-d', strtotime($date));
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public static function getMonth() {
|
||||
return self::$months;
|
||||
}
|
||||
|
||||
public static function isValidDate($date) {
|
||||
if (!is_string($date)) {
|
||||
return false;
|
||||
}
|
||||
$day = substr($date, 0, 2);
|
||||
$mont = substr($date, 3, 2);
|
||||
$year = substr($date, 6, 4);
|
||||
return checkdate($mont, $day, $year);
|
||||
}
|
||||
|
||||
public static function fillNullIfEmpty(&$variable) {
|
||||
if (!isset($variable)) {
|
||||
$variable = null;
|
||||
}
|
||||
return $variable;
|
||||
}
|
||||
|
||||
public static function getWeekDays() {
|
||||
$days = self::$days;
|
||||
$result = array();
|
||||
$counter = 1;
|
||||
foreach ($days as $x) {
|
||||
$result[$counter] = $x;
|
||||
$counter++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function parseXmlToArray($xmlSource) {
|
||||
try {
|
||||
$xmlOut = simplexml_load_string($xmlSource, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
|
||||
$arrayOut = json_decode(json_encode($xmlOut), true);
|
||||
} catch (\Exception $e) {
|
||||
$arrayOut = false;
|
||||
}
|
||||
return $arrayOut;
|
||||
}
|
||||
|
||||
public static function encryptCodeNumber($string, $key) {
|
||||
$key = is_null($key) ? self::$encryptionKey : $key;
|
||||
|
||||
$result = '';
|
||||
for ($i = 0; $i < mb_strlen($string, "UTF-8"); $i++) {
|
||||
$char = mb_substr($string, $i, 1, "UTF-8");
|
||||
$keychar = mb_substr($key, ($i % mb_strlen($key, "UTF-8")) - 1, 1, "UTF-8");
|
||||
$char = chr(ord($char) + ord($keychar));
|
||||
$result.=$char;
|
||||
}
|
||||
$result = base64_encode($result);
|
||||
$result = str_replace("=", "", $result);
|
||||
return urlencode($result);
|
||||
}
|
||||
|
||||
public static function decryptCodeNumber($string, $key) {
|
||||
$key = is_null($key) ? self::$encryptionKey : $key;
|
||||
|
||||
$string = urldecode($string);
|
||||
$eqcount = strlen($string) % 4;
|
||||
if ($eqcount == 2)
|
||||
$string . "==";
|
||||
else if ($eqcount == 3)
|
||||
$string . "=";
|
||||
$result = '';
|
||||
$string = base64_decode($string);
|
||||
for ($i = 0; $i < mb_strlen($string); $i++) {
|
||||
$char = mb_substr($string, $i, 1);
|
||||
$keychar = mb_substr($key, ($i % mb_strlen($key)) - 1, 1);
|
||||
$char = chr(ord($char) - ord($keychar));
|
||||
$result.=$char;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function generateRandomString($length = 5) {
|
||||
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
|
||||
public static function convertArrayToCsv (array $valueArray )
|
||||
{
|
||||
if ( !$valueArray )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$csvResult = "";
|
||||
|
||||
$valueArray = singleElementArray($valueArray);
|
||||
|
||||
/*Get The Column Names*/
|
||||
$firstArray = reset($valueArray);
|
||||
|
||||
$csvResult.=implode(",",array_keys($firstArray))."\r\n";
|
||||
|
||||
foreach ($valueArray as $perArray)
|
||||
{
|
||||
$csvResult.=implode(",",$perArray)."\r\n";
|
||||
}
|
||||
return $csvResult;
|
||||
}
|
||||
|
||||
private static function nextExcelColName ( $colName = null )
|
||||
{
|
||||
$primary = range("A","Z");
|
||||
if ( !$colName)
|
||||
{
|
||||
return reset($primary);
|
||||
}
|
||||
|
||||
if(last($primary) == $colName)
|
||||
{
|
||||
return reset($primary);
|
||||
}
|
||||
|
||||
return $primary[array_search($colName,$primary)+1];
|
||||
|
||||
}
|
||||
|
||||
/* If $params[keyNames] is Empty Function Gonna Take All The Keys Of The Array */
|
||||
public static function convertArrayToXls (array $valueArray,array $params = [] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$excel = App::make('excel');
|
||||
$params[ "fileName" ] = isset( $params[ "fileName" ] ) ? $params[ "fileName" ] : "xls_file";
|
||||
$params[ "pagePrefix" ] = isset( $params[ "pagePrefix" ] ) ? $params[ "pagePrefix" ] : "Page";
|
||||
$params[ "onlyTheseKeys" ] = isset( $params[ "onlyTheseKeys" ] ) ? $params[ "onlyTheseKeys" ] : [];
|
||||
$params[ "keyNames" ] = isset( $params[ "keyNames" ] ) ? $params[ "keyNames" ] : [];
|
||||
$result = $excel->create ( $params[ "fileName" ], function ( $excel ) use ( $valueArray, $params )
|
||||
{
|
||||
$excel->sheet ( $params[ "pagePrefix" ], function ( $sheet ) use ( $valueArray, $params)
|
||||
{
|
||||
$rowCounter = 1;
|
||||
$sheet->setOrientation ( 'landscape' );
|
||||
if ($params["keyNames"])
|
||||
{
|
||||
$colCounter = 0;
|
||||
|
||||
foreach ($params["keyNames"] as $perKey)
|
||||
{
|
||||
if ($params["onlyTheseKeys"] && !in_array($perKey,$params["onlyTheseKeys"]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$sheet->setCellValueByColumnAndRow ( $colCounter, $rowCounter, $perKey );
|
||||
$style = array(
|
||||
'alignment' => array(
|
||||
'horizontal' => "center",
|
||||
)
|
||||
);
|
||||
|
||||
$sheet->getDefaultStyle()->applyFromArray($style);
|
||||
$colCounter++;
|
||||
}
|
||||
$rowCounter++;
|
||||
}
|
||||
|
||||
foreach ($valueArray as $perValue)
|
||||
{
|
||||
$colCounter = 0;
|
||||
foreach ($perValue as $perCol)
|
||||
{
|
||||
if ($params["onlyTheseKeys"] && !in_array($perKey,$params["onlyTheseKeys"]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (is_array($perCol))
|
||||
{
|
||||
$perCol = json_encode($perCol);
|
||||
}
|
||||
$sheet->setCellValueByColumnAndRow ( $colCounter, $rowCounter, $perCol );
|
||||
$colCounter++;
|
||||
}
|
||||
$rowCounter++;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
});
|
||||
return $result;
|
||||
} catch ( Exception $e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function singleElementArray ( $arrayElement,array $extraParams = null)
|
||||
{
|
||||
$isMultiArray = true;
|
||||
|
||||
if ( !is_array($arrayElement))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($arrayElement as $perItem)
|
||||
{
|
||||
if (gettype($perItem)!="array")
|
||||
{
|
||||
$isMultiArray = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$isMultiArray)
|
||||
{
|
||||
$isMultiArray = true;
|
||||
foreach (array_keys ( $arrayElement ) as $perKey)
|
||||
{
|
||||
if (!is_numeric($perKey))
|
||||
{
|
||||
$isMultiArray = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $isMultiArray?$arrayElement:array($arrayElement);
|
||||
|
||||
}
|
||||
|
||||
public static function checkWizardMenu($wizardArray, $menuCode)
|
||||
{
|
||||
return array_filter($wizardArray, function ($key) use ($menuCode) {
|
||||
return $key['menu_code'] == $menuCode ? true : false;
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
|
||||
/*If its an array enter the index of the array to $index variable*/
|
||||
public static function fillOnUndefined($variable,$index = null,$fillWith = null,$arrayDelimiter = ".")
|
||||
{
|
||||
if ( !$arrayDelimiter)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$index = trim($index,$arrayDelimiter);
|
||||
|
||||
if ( !$index && $index !== '0')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$indexes = explode($arrayDelimiter,$index);
|
||||
|
||||
$arrayDeep = $variable;
|
||||
|
||||
foreach ($indexes as $perIndex)
|
||||
{
|
||||
if ( !isset($arrayDeep[$perIndex]))
|
||||
{
|
||||
return $fillWith;
|
||||
}
|
||||
|
||||
$arrayDeep = $arrayDeep[$perIndex];
|
||||
}
|
||||
|
||||
return $arrayDeep;
|
||||
}
|
||||
public static function hexToBinary ( $hex )
|
||||
{
|
||||
if ( strlen($hex)<=0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
$str = "";
|
||||
for($i=0;$i<strlen($hex);$i+=2)
|
||||
$str .= chr(hexdec(substr($hex,$i,2)));
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function pickItemFromArray($index,array $targetArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
$result = [ ];
|
||||
foreach ($targetArray as $perIndex => $perValue)
|
||||
{
|
||||
if (isset($perValue[$index]))
|
||||
{
|
||||
$result[] = $perValue[$index];
|
||||
}
|
||||
|
||||
}
|
||||
return $result;
|
||||
} catch ( Exception $e )
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function pickNodeFromArray($index, $value, array $targetArray)
|
||||
{
|
||||
try {
|
||||
$result = [];
|
||||
foreach ($targetArray as $perIndex => $perValue) {
|
||||
if (isset($perValue[$index]) && $perValue[$index] == $value) {
|
||||
$result = $perValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function numberSortTurkish($number)
|
||||
{
|
||||
$returnString = '';
|
||||
$numberValue = [
|
||||
'inci' => [1,5,8,20,70,80],
|
||||
'üncü' => [3,4,100],
|
||||
'nci' => [2,7,50],
|
||||
'ıncı' => [0,40,60,90],
|
||||
'ncı' => [6],
|
||||
'uncu' => [9,10,30]
|
||||
];
|
||||
|
||||
if(strlen($number) < 4) {
|
||||
if ($number % 10 == 0) {
|
||||
$numberKey = $number;
|
||||
} else $numberKey = substr($number, -1,1);
|
||||
}
|
||||
|
||||
foreach ($numberValue as $orderKey => $numbers) {
|
||||
if (array_search($numberKey, $numbers) !== false) {
|
||||
$returnString = $orderKey;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnString;
|
||||
|
||||
}
|
||||
|
||||
public static function now ( array $param = [] )
|
||||
{
|
||||
return date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
public static function todayDate ( array $param = [] )
|
||||
{
|
||||
return date("Y-m-d");
|
||||
}
|
||||
|
||||
public static function moneyFormatWithTwoDecimals($money)
|
||||
{
|
||||
$money = str_replace(",","",$money);
|
||||
return number_format($money,2,'.','');
|
||||
}
|
||||
|
||||
public static function getXmlResponse ($view,$data)
|
||||
{
|
||||
$responseObj = App::make("Response");
|
||||
return $responseObj::view($view,$data)->header('Content-Type', 'text/xml');
|
||||
}
|
||||
|
||||
public static function preDie($args)
|
||||
{
|
||||
|
||||
echo '<pre>';
|
||||
print_r($args);
|
||||
echo '</pre>';
|
||||
|
||||
die;
|
||||
}
|
||||
}
|
||||
264
app/Core/Helper/compat_l5.php
Normal file
264
app/Core/Helper/compat_l5.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
if(!function_exists('config_path'))
|
||||
{
|
||||
/**
|
||||
* Return the path to config files
|
||||
* @param null $path
|
||||
* @return string
|
||||
*/
|
||||
function config_path($path=null)
|
||||
{
|
||||
return app()->getConfigurationPath(rtrim($path, ".php"));
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('public_path'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the path to public dir
|
||||
* @param null $path
|
||||
* @return string
|
||||
*/
|
||||
function public_path($path=null)
|
||||
{
|
||||
return rtrim(app()->basePath('public/'.$path), '/');
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('storage_path'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the path to storage dir
|
||||
* @param null $path
|
||||
* @return string
|
||||
*/
|
||||
function storage_path($path=null)
|
||||
{
|
||||
return app()->storagePath($path);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('database_path'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the path to database dir
|
||||
* @param null $path
|
||||
* @return string
|
||||
*/
|
||||
function database_path($path=null)
|
||||
{
|
||||
return app()->databasePath($path);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('resource_path'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the path to resource dir
|
||||
* @param null $path
|
||||
* @return string
|
||||
*/
|
||||
function resource_path($path=null)
|
||||
{
|
||||
return app()->resourcePath($path);
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('lang_path'))
|
||||
{
|
||||
|
||||
/**
|
||||
* Return the path to lang dir
|
||||
* @param null $str
|
||||
* @return string
|
||||
*/
|
||||
function lang_path($path=null)
|
||||
{
|
||||
return app()->getLanguagePath($path);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('asset'))
|
||||
{
|
||||
/**
|
||||
* Generate an asset path for the application.
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $secure
|
||||
* @return string
|
||||
*/
|
||||
function asset($path, $secure = null)
|
||||
{
|
||||
return app('url')->asset($path, $secure);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('elixir'))
|
||||
{
|
||||
/**
|
||||
* Get the path to a versioned Elixir file.
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
function elixir($file)
|
||||
{
|
||||
static $manifest = null;
|
||||
if (is_null($manifest))
|
||||
{
|
||||
$manifest = json_decode(file_get_contents(public_path().'/build/rev-manifest.json'), true);
|
||||
}
|
||||
if (isset($manifest[$file]))
|
||||
{
|
||||
return '/build/'.$manifest[$file];
|
||||
}
|
||||
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('auth'))
|
||||
{
|
||||
/**
|
||||
* Get the available auth instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Guard
|
||||
*/
|
||||
function auth()
|
||||
{
|
||||
return app('Illuminate\Contracts\Auth\Guard');
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('bcrypt'))
|
||||
{
|
||||
/**
|
||||
* Hash the given value.
|
||||
*
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
function bcrypt($value, $options = array())
|
||||
{
|
||||
return app('hash')->make($value, $options);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('redirect'))
|
||||
{
|
||||
/**
|
||||
* Get an instance of the redirector.
|
||||
*
|
||||
* @param string|null $to
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param bool $secure
|
||||
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
function redirect($to = null, $status = 302, $headers = array(), $secure = null)
|
||||
{
|
||||
if (is_null($to)) return app('redirect');
|
||||
return app('redirect')->to($to, $status, $headers, $secure);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('response'))
|
||||
{
|
||||
/**
|
||||
* Return a new response from the application.
|
||||
*
|
||||
* @param string $content
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @return \Symfony\Component\HttpFoundation\Response|\Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
function response($content = '', $status = 200, array $headers = array())
|
||||
{
|
||||
$factory = app('Illuminate\Contracts\Routing\ResponseFactory');
|
||||
if (func_num_args() === 0)
|
||||
{
|
||||
return $factory;
|
||||
}
|
||||
return $factory->make($content, $status, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('secure_asset'))
|
||||
{
|
||||
/**
|
||||
* Generate an asset path for the application.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function secure_asset($path)
|
||||
{
|
||||
return asset($path, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('secure_url'))
|
||||
{
|
||||
/**
|
||||
* Generate a HTTPS url for the application.
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $parameters
|
||||
* @return string
|
||||
*/
|
||||
function secure_url($path, $parameters = array())
|
||||
{
|
||||
return url($path, $parameters, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! function_exists('session'))
|
||||
{
|
||||
/**
|
||||
* Get / set the specified session value.
|
||||
*
|
||||
* If an array is passed as the key, we will assume you want to set an array of values.
|
||||
*
|
||||
* @param array|string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
function session($key = null, $default = null)
|
||||
{
|
||||
if (is_null($key)) return app('session');
|
||||
if (is_array($key)) return app('session')->put($key);
|
||||
return app('session')->get($key, $default);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! function_exists('cookie'))
|
||||
{
|
||||
/**
|
||||
* Create a new cookie instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int $minutes
|
||||
* @param string $path
|
||||
* @param string $domain
|
||||
* @param bool $secure
|
||||
* @param bool $httpOnly
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
|
||||
{
|
||||
$cookie = app('Illuminate\Contracts\Cookie\Factory');
|
||||
if (is_null($name))
|
||||
{
|
||||
return $cookie;
|
||||
}
|
||||
return $cookie->make($name, $value, $minutes, $path, $domain, $secure, $httpOnly);
|
||||
}
|
||||
}
|
||||
463
app/Core/Helper/helpers.php
Normal file
463
app/Core/Helper/helpers.php
Normal file
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Helper\LanguageService;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Laravel\Lumen\Bus\PendingDispatch;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Laravel\Lumen\Http\ResponseFactory;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Illuminate\Contracts\Broadcasting\Factory as BroadcastFactory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
function output($param)
|
||||
{
|
||||
|
||||
$statusArr = [1 => "success", -1 => "exception", 0 => "error"];
|
||||
$exceptionClassArr = ["exception" => "\Exception", "error" => "App\Exceptions\ApiErrorException"];
|
||||
$statusCodeArr = [1 => 200, -1 => 500, 0 => 400];
|
||||
$param["status"] = isset($param["status"]) ? $param["status"] : 1;
|
||||
$status = isset($statusArr[$param["status"]]) ? $statusArr[$param["status"]] : "success";
|
||||
$statusCode = isset($statusCodeArr[$param["status"]]) ? $statusCodeArr[$param["status"]] : 200;
|
||||
$message = (isset($param['message']) ? $param['message'] : '');
|
||||
$data = (isset($param['data']) ? $param['data'] : '');
|
||||
$exceptionClass = isset($exceptionClassArr[$status]) ? new $exceptionClassArr[$status]($message) : null;
|
||||
|
||||
return ['status' => $status, 'message' => $message, 'data' => $data, 'statusCode' => $statusCode, "exceptionClass" => $exceptionClass];
|
||||
}
|
||||
|
||||
function apiResponse($status = -1, $message = "", $data = [], $statusCode = null, $errorCode = null)
|
||||
{
|
||||
$genericMessage = "Bilinmeyen Bir Hata Oluştu";
|
||||
$error = $status <= 0 ? true : false;
|
||||
$statusCode = $statusCode ? $statusCode : 200;
|
||||
$errorCode = $errorCode ? $errorCode : null;
|
||||
//$statusCode = $error ? 500 : $statusCode;
|
||||
$message = $status != -1 ? $message : $genericMessage;
|
||||
$message = $message ? $message : null;
|
||||
$data = $data && is_array($data) ? $data : [];
|
||||
|
||||
$responseData = [
|
||||
"status" => $statusCode,
|
||||
"error" => $error,
|
||||
"errorCode" => $errorCode,
|
||||
"message" => $message,
|
||||
"data" => $data
|
||||
];
|
||||
|
||||
/** ServiceLog **/
|
||||
$serviceLogId = app('request')->serviceLogId;
|
||||
$serviceLogRequestTime = app('request')->serviceLogRequestTime;
|
||||
if (!empty($serviceLogId)) {
|
||||
$updateServiceLog = [
|
||||
'response' => json_encode($responseData),
|
||||
'response_time' => microtime(true) - $serviceLogRequestTime,
|
||||
'status' => 1
|
||||
];
|
||||
$serviceLog = App::make("App\Core\Service\ServiceLogService");
|
||||
$serviceLog->update($serviceLogId, $updateServiceLog);
|
||||
}
|
||||
/** ServiceLog **/
|
||||
|
||||
return response()->json($responseData, $statusCode);
|
||||
}
|
||||
|
||||
function fillOnUndefined($variable, $index = null, $fillWith = null, $arrayDelimiter = ".")
|
||||
{
|
||||
if (!$arrayDelimiter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!$index && $index !== '0' && $index !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$indexes = explode($arrayDelimiter, $index);
|
||||
|
||||
$arrayDeep = $variable;
|
||||
|
||||
foreach ($indexes as $perIndex) {
|
||||
if (!isset($arrayDeep[$perIndex])) {
|
||||
return $fillWith;
|
||||
}
|
||||
|
||||
$arrayDeep = $arrayDeep[$perIndex];
|
||||
}
|
||||
|
||||
|
||||
return $arrayDeep;
|
||||
|
||||
}
|
||||
|
||||
function fillOnUndefinedAndEmpty($variable, $index = null, $fillWith = null, $arrayDelimiter = ".")
|
||||
{
|
||||
if (!$arrayDelimiter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!$index && $index !== '' && $index !== '0' && $index !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$indexes = explode($arrayDelimiter, $index);
|
||||
|
||||
$arrayDeep = $variable;
|
||||
|
||||
foreach ($indexes as $perIndex) {
|
||||
if (!isset($arrayDeep[$perIndex]) || empty($arrayDeep[$perIndex])) {
|
||||
return $fillWith;
|
||||
}
|
||||
|
||||
$arrayDeep = $arrayDeep[$perIndex];
|
||||
}
|
||||
|
||||
|
||||
return $arrayDeep;
|
||||
|
||||
}
|
||||
|
||||
function createFolderAndSubFolder($structure, $path = __DIR__, &$createdPaths, $mode = 0777)
|
||||
{
|
||||
|
||||
foreach ($structure as $folder => $subFolder) {
|
||||
if (is_array($subFolder)) {
|
||||
$newPath = "{$path}/{$folder}";
|
||||
//$createdPaths[$newPath] = $newPath;
|
||||
$createdPaths[] = $newPath;
|
||||
|
||||
if (!is_dir($newPath)) mkdir($newPath, $mode);
|
||||
|
||||
createFolderAndSubFolder($subFolder, $newPath, $createdPaths);
|
||||
} else {
|
||||
$newPath = "{$path}/{$subFolder}";
|
||||
//$createdPaths[$newPath] = $newPath;
|
||||
$createdPaths[] = $newPath;
|
||||
if (!is_dir($newPath)) mkdir($newPath, $mode);
|
||||
}
|
||||
}
|
||||
|
||||
return $createdPaths;
|
||||
}
|
||||
|
||||
function smartyModifierFileSize($size)
|
||||
{
|
||||
$size = max(0, (int)$size);
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||
$power = $size > 0 ? floor(log($size, 1024)) : 0;
|
||||
$convertSize = number_format($size / pow(1024, $power), 2, '.', ',');
|
||||
$convertType = $units[$power];
|
||||
return [$convertSize, $convertType];
|
||||
}
|
||||
|
||||
function pickItemFromArray($index, array $targetArray)
|
||||
{
|
||||
try {
|
||||
$result = [];
|
||||
foreach ($targetArray as $perIndex => $perValue) {
|
||||
if (isset($perValue[$index])) {
|
||||
$result[] = $perValue[$index];
|
||||
}
|
||||
|
||||
}
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function lang($word, array $parameters = [], $lang = null)
|
||||
{
|
||||
return LanguageService::lang($word, $parameters, $lang);
|
||||
}
|
||||
|
||||
function getSystemLang()
|
||||
{
|
||||
return LanguageService::getCurrentLang();
|
||||
}
|
||||
|
||||
function getSystemLangSession()
|
||||
{
|
||||
return session("sysLang");
|
||||
}
|
||||
|
||||
function setSystemLangSession($language)
|
||||
{
|
||||
$validLanguages = LanguageService::getValidLanguages();
|
||||
if (!in_array($language, $validLanguages)) {
|
||||
throw new Exception("Invalid Language Selected language parameter : " . json_encode($language));
|
||||
}
|
||||
session()->set("sysLang", $language);
|
||||
return $language;
|
||||
}
|
||||
|
||||
function getSystemDefaultLang()
|
||||
{
|
||||
return LanguageService::getDefaultLang();
|
||||
}
|
||||
|
||||
function getLanguageSupportList()
|
||||
{
|
||||
return LanguageService::getLanguageSupportList();
|
||||
}
|
||||
|
||||
function upperCase($word, $charset = "UTF-8")
|
||||
{
|
||||
$word = str_replace("i", "İ", $word);
|
||||
return mb_strtoupper($word, $charset);
|
||||
}
|
||||
|
||||
function lowerCase($word, $charset = "UTF-8")
|
||||
{
|
||||
$word = str_replace("I", "ı", $word);
|
||||
return mb_strtolower($word, $charset);
|
||||
}
|
||||
|
||||
function uCase($word, $charset = "UTF-8")
|
||||
{
|
||||
$word = preg_replace("#(^\i)#", "İ", $word);
|
||||
$word = preg_replace("#(^\ı)#", "I", $word);
|
||||
return mb_convert_case($word, MB_CASE_TITLE, $charset);
|
||||
}
|
||||
|
||||
function reIndexArrayKeys(array $targetArray, $startNo = 0)
|
||||
{
|
||||
if (!$targetArray) {
|
||||
return [];
|
||||
}
|
||||
return array_combine(range($startNo, ($startNo - 1) + count($targetArray)), $targetArray);
|
||||
}
|
||||
|
||||
function singleElementXMLArray($array = [])
|
||||
{
|
||||
|
||||
return fillOnUndefined($array, 0) && is_array($array) ? $array : [$array];
|
||||
}
|
||||
|
||||
function toArray($value): array
|
||||
{
|
||||
return is_array($value) ? $value : ($value !== null ? [$value] : []);
|
||||
}
|
||||
|
||||
|
||||
function singleElementArray($arrayElement, array $extraParams = null)
|
||||
{
|
||||
|
||||
$isMultiArray = true;
|
||||
|
||||
if (!is_array($arrayElement)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($arrayElement as $perItem) {
|
||||
if (gettype($perItem) != "array") {
|
||||
$isMultiArray = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isMultiArray) {
|
||||
$isMultiArray = true;
|
||||
foreach (array_keys($arrayElement) as $perKey) {
|
||||
if (!is_numeric($perKey)) {
|
||||
$isMultiArray = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $isMultiArray ? $arrayElement : array($arrayElement);
|
||||
|
||||
}
|
||||
|
||||
function generateRandomString($length = 5)
|
||||
{
|
||||
return \App\Core\Helper\PhpHelper::generateRandomString($length);
|
||||
}
|
||||
|
||||
function humanReadableDate($date)
|
||||
{
|
||||
return date('d/m/Y', strtotime($date));
|
||||
}
|
||||
|
||||
function language_key($title)
|
||||
{
|
||||
return Str::slug($title, $separator = '_', $language = 'en');
|
||||
}
|
||||
|
||||
function getGuid()
|
||||
{
|
||||
$hash = md5(uniqid());
|
||||
$guid = substr($hash, 0, 8) .
|
||||
'-' .
|
||||
substr($hash, 8, 4) .
|
||||
'-' .
|
||||
substr($hash, 12, 4) .
|
||||
'-' .
|
||||
substr($hash, 16, 4) .
|
||||
'-' .
|
||||
substr($hash, 20, 12);
|
||||
|
||||
return $guid;
|
||||
}
|
||||
|
||||
function moneyDoubleFormat($money)
|
||||
{
|
||||
return number_format($money, 2, ',', '');
|
||||
}
|
||||
|
||||
|
||||
function moneyDoubleFormatDecimal($money)
|
||||
{
|
||||
return floatval(number_format($money, 2, '.', ''));
|
||||
}
|
||||
|
||||
function moneyFourFormatDecimal($money)
|
||||
{
|
||||
return floatval(number_format($money, 4, '.', ''));
|
||||
}
|
||||
|
||||
|
||||
function getCodeGenerate($prefix = 'ENW')
|
||||
{
|
||||
return $prefix . date('ymd') . '-' . upperCase(generateRandomString(8));
|
||||
}
|
||||
|
||||
function getPaymentGenerate($prefix = 'PYM')
|
||||
{
|
||||
$prefix = is_null($prefix) ? 'PYM' : $prefix;
|
||||
return 'ENW' . $prefix . date('ymd') . '_' . upperCase(generateRandomString(8));
|
||||
}
|
||||
|
||||
function getTicketCodeGenerate($prefix = 'TCK')
|
||||
{
|
||||
return $prefix . upperCase(generateRandomString(8));
|
||||
}
|
||||
|
||||
function creditCardMask($cardNumber)
|
||||
{
|
||||
return substr($cardNumber, 0, 6) . '******' . substr($cardNumber, -4);
|
||||
}
|
||||
|
||||
function occupancyCodeFormatted($occupancyCode)
|
||||
{
|
||||
|
||||
$occupancyFormatted = [];
|
||||
|
||||
$adultCount = substr_count($occupancyCode, 'A');
|
||||
if ($adultCount > 0) {
|
||||
$occupancyFormatted[] = $adultCount . ' Adult';
|
||||
}
|
||||
|
||||
$childCount = substr_count($occupancyCode, 'C');
|
||||
if ($childCount > 0) {
|
||||
|
||||
$childAges = [];
|
||||
$roomsChildArray = explode('C', $occupancyCode);
|
||||
for ($i = 1; $i < count($roomsChildArray); $i++) {
|
||||
if (!empty($roomsChildArray[$i]) || $roomsChildArray[$i] == 0) {
|
||||
$childAges[] = $roomsChildArray[$i];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($childAges)) {
|
||||
$childAges = implode(', ', $childAges);
|
||||
}
|
||||
|
||||
$occupancyFormatted[] = $childCount . ' Child' . (!empty($childAges) ? ' (' . $childAges . ')' : null);
|
||||
}
|
||||
|
||||
if (!empty($occupancyFormatted)) {
|
||||
$occupancyFormatted = implode(', ', $occupancyFormatted);
|
||||
}
|
||||
|
||||
return $occupancyFormatted;
|
||||
}
|
||||
|
||||
function occupancyCodeParser($occupancyCode)
|
||||
{
|
||||
|
||||
$occupancy = [];
|
||||
$occupancy['ADT'] = 0;
|
||||
$occupancy['CHD'] = 0;
|
||||
$occupancy['AGE'] = [];
|
||||
|
||||
$adultCount = substr_count($occupancyCode, 'A');
|
||||
if ($adultCount > 0) {
|
||||
$occupancy['ADT'] = $adultCount;
|
||||
}
|
||||
|
||||
$childCount = substr_count($occupancyCode, 'C');
|
||||
if ($childCount > 0) {
|
||||
|
||||
$childAges = [];
|
||||
$roomsChildArray = explode('C', $occupancyCode);
|
||||
for ($i = 1; $i < count($roomsChildArray); $i++) {
|
||||
if (!empty($roomsChildArray[$i])) {
|
||||
$childAges[] = $roomsChildArray[$i];
|
||||
}
|
||||
}
|
||||
|
||||
$occupancy['CHD'] = $childCount;
|
||||
$occupancy['AGE'] = $childAges;
|
||||
|
||||
//$occupancyFormatted[] = $childCount . ' Child' . (!empty($childAges) ? ' (' . $childAges . ')' : null);
|
||||
}
|
||||
|
||||
return $occupancy;
|
||||
}
|
||||
|
||||
|
||||
function occupancyGroup($maxAdult, $maxChild, $maxOccupancy, $excludeOccupancy = [])
|
||||
{
|
||||
|
||||
$occupancyGroup = [];
|
||||
//TODO: $excludeOccupancy
|
||||
for ($i = 0; $i < $maxAdult; $i++) {
|
||||
$occupancyCodeAdult = str_repeat('A', ($i + 1));
|
||||
if (strlen($occupancyCodeAdult) > $maxOccupancy) {
|
||||
break;
|
||||
}
|
||||
$occupancyGroup[] = $occupancyCodeAdult;
|
||||
|
||||
for ($j = 0; $j < $maxChild; $j++) {
|
||||
$occupancyCodeChild = str_repeat('C', ($j + 1));
|
||||
|
||||
if (strlen($occupancyCodeChild) > $maxOccupancy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strlen($occupancyCodeAdult . $occupancyCodeChild) > $maxOccupancy) {
|
||||
break;
|
||||
}
|
||||
|
||||
$occupancyGroup[] = $occupancyCodeAdult . $occupancyCodeChild;
|
||||
}
|
||||
}
|
||||
|
||||
return $occupancyGroup;
|
||||
}
|
||||
|
||||
|
||||
function cancellationPolicyTextFormatted($isNonRefundable, $isFreeCancellation, $beforeArrivalDay, $type, $value, $currency, $languageCode = 'en')
|
||||
{
|
||||
|
||||
$formattedText = null;
|
||||
if (!$isFreeCancellation) {
|
||||
if ($isNonRefundable) {
|
||||
$formattedText = __('btn-irrevocable', [], $languageCode);
|
||||
} else {
|
||||
|
||||
$formattedText = __('be-if_canceled_up_to_days', ['day' => $beforeArrivalDay], $languageCode) . ', ' . $value . ($type == 'PER' ? '%' : $currency) . ' ' . __('be-search-impose_penalty', [], $languageCode);
|
||||
}
|
||||
} else {
|
||||
$formattedText = ($beforeArrivalDay > 0 ? __('be-up_to_days', ['day' => $beforeArrivalDay], $languageCode) : '') . ' ' . __('btn-free_cancellation', [], $languageCode);
|
||||
}
|
||||
|
||||
return $formattedText;
|
||||
|
||||
}
|
||||
60
app/Core/Mail/AffiliateRequestMail.php
Normal file
60
app/Core/Mail/AffiliateRequestMail.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class AffiliateRequestMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$params = $this->param;
|
||||
$mailParams = $params['mailViewParams'] ;
|
||||
$mailData = $params['mailData'] ;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress') ;
|
||||
$mailTitle = $mailData['to']["name"]. ' | Affiliate Request Mail';
|
||||
|
||||
app('translator')->setLocale(fillOnUndefined($params['mailViewParams'],'language', 'en'));
|
||||
|
||||
|
||||
/*echo view('emails.affiliateRequestMail', compact('mailParams', 'mailTitle'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.affiliateRequestMail', compact('mailParams', 'mailTitle'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($mailTitle)
|
||||
->with(['message' => $this]);
|
||||
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$message = $e->getFile()." ".$e->getLine()." ".$e->getMessage();
|
||||
Log::error($message);
|
||||
return output( ['status' => -1, 'message' => $e->getMessage()] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
13
app/Core/Mail/BaseMail.php
Normal file
13
app/Core/Mail/BaseMail.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
|
||||
class BaseMail
|
||||
{
|
||||
|
||||
public function __construct ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
85
app/Core/Mail/BookingCancellationConfirmCodeMail.php
Normal file
85
app/Core/Mail/BookingCancellationConfirmCodeMail.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingCancellationConfirmCodeMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
$bookingService = App::make('App\Core\Service\BookingService');
|
||||
$userService = App::make('App\Core\Service\UserService');
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'booking_code', 'condition' => '=', 'value' => $params['bookingCode']]
|
||||
],
|
||||
'with' => ['bookingProperty.propertyBrand', 'bookingContact'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$bookingDetail = $bookingService->select($requestData);
|
||||
|
||||
if ($bookingDetail['status'] != 'success' || empty($bookingDetail['data'])) {
|
||||
throw new ApiErrorException('Booking not found.');
|
||||
}
|
||||
|
||||
$bookingDetail = $bookingDetail['data'];
|
||||
|
||||
$mailParams = [
|
||||
'to' => $bookingDetail['booking_contact']['email'],
|
||||
'toNameSurname' => $bookingDetail['booking_contact']['nameSurname'],
|
||||
'bcc' => [],
|
||||
'confirmCode' => $params['confirmCode'],
|
||||
'bookingId' => fillOnUndefined($bookingDetail, 'id'),
|
||||
'propertyId' => fillOnUndefined($bookingDetail, 'property_id'),
|
||||
'bookingCode' => fillOnUndefined($bookingDetail, 'booking_code'),
|
||||
'locale' => fillOnUndefined($bookingDetail['booking_contact'], 'language_code', 'en'),
|
||||
];
|
||||
|
||||
/*echo view('emails.bookingCancellationConfirmCode', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
$mailParams['bcc'][] = 'channel@extranetwork.com';
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.bookingCancellationConfirmCode', compact('mailParams'))
|
||||
->to($mailParams['to'], $mailParams['toNameSurname'])
|
||||
->bcc($mailParams['bcc'])
|
||||
->subject(__('api-mailing-cancellation_confirm_code-subject', ['bookingCode' => $mailParams['bookingCode']], $mailParams['locale']));
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
123
app/Core/Mail/BookingCancellationRequestMail.php
Normal file
123
app/Core/Mail/BookingCancellationRequestMail.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingCancellationRequestMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
$bookingService = App::make('App\Core\Service\BookingService');
|
||||
$userService = App::make('App\Core\Service\UserService');
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'booking_code', 'condition' => '=', 'value' => $params['bookingCode']]
|
||||
],
|
||||
'with' => [
|
||||
'bookingPayment', 'bookingRoom.roomRateMapping.propertyRoom', 'bookingRoom.roomRateMapping.propertyRoomRate',
|
||||
'bookingContact', 'bookingProperty.propertyBrand', 'bookingProperty.propertyExecutive', 'bookingProperty.propertyUser.user',
|
||||
'bookingPropertyWeb', 'propertyBookingEngine', 'propertyBookingChannel'
|
||||
],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$bookingDetail = $bookingService->select($requestData);
|
||||
|
||||
if ($bookingDetail['status'] != 'success' || empty($bookingDetail['data'])) {
|
||||
throw new ApiErrorException('Booking not found.');
|
||||
}
|
||||
|
||||
$bookingDetail = $bookingDetail['data'];
|
||||
|
||||
|
||||
//Language
|
||||
$userData = $bookingDetail['booking_property']['property_user'];
|
||||
$firstUserData = reset($userData);
|
||||
$bookingLanguageCode = fillOnUndefined($firstUserData['user'], 'language', 'en');
|
||||
|
||||
|
||||
//Mail Contact Data
|
||||
$bcc = [];
|
||||
foreach ($userData as $user) {
|
||||
if ($user['user']['email'] != $firstUserData['user']['email']) {
|
||||
$bcc[] = $user['user']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$reservationExecutives = [];
|
||||
if (isset($bookingDetail['booking_property']['property_executive'])) {
|
||||
$reservationExecutives = collect($bookingDetail['booking_property']['property_executive'])
|
||||
->where('executive_type_id', '=', '7')
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
foreach ($reservationExecutives as $reservationExecutive) {
|
||||
$bcc[] = $reservationExecutive['email'];
|
||||
}
|
||||
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $bookingDetail['booking_property']['name'],
|
||||
'email' => $firstUserData['user']['email']
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
$mailParams = [
|
||||
'to' => $firstUserData['user']['email'],
|
||||
'bcc' => $bcc,
|
||||
'toNameSurname' => $bookingDetail['booking_property']['name'],
|
||||
'bookingContactNameSurname' => $bookingDetail['booking_contact']['nameSurname'],
|
||||
'bookingCode' => fillOnUndefined($bookingDetail, 'booking_code'),
|
||||
'locale' => $bookingLanguageCode,
|
||||
];
|
||||
|
||||
$mailParams['detailUrl'] = config('app.client_server').'/app/network/reservation/'.$bookingDetail['id'].'?propertyid='.$bookingDetail['property_id'];
|
||||
|
||||
/*echo view('emails.bookingCancellationRequest', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
$mailParams['bcc'][] = 'channel@extranetwork.com';
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.bookingCancellationRequest', compact('mailParams'))
|
||||
->to($mailParams['to'], $mailParams['toNameSurname'])
|
||||
->bcc($mailParams['bcc'])
|
||||
->subject(__('api-mailing-cancellation_request-subject', ['bookingCode' => $mailParams['bookingCode']], $mailParams['locale']));
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Core/Mail/BookingEngineSearchReportMail.php
Normal file
54
app/Core/Mail/BookingEngineSearchReportMail.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingEngineSearchReportMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
/*echo view('emails.bookingEngineSearchReportMail', compact('params'));
|
||||
die();*/
|
||||
|
||||
$bcc = $params['propertyUserEmail'];
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.bookingEngineSearchReportMail', compact('params'))
|
||||
->to($mailSenderAddress, 'Extranetwork')
|
||||
->bcc($bcc)
|
||||
->subject($params['propertyName'].' - Günlük İşlem Raporu : '. $params['date']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
120
app/Core/Mail/BookingInvoiceUpdateMail.php
Normal file
120
app/Core/Mail/BookingInvoiceUpdateMail.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingInvoiceUpdateMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
|
||||
|
||||
$bookingService = App::make("App\Core\Service\BookingService");
|
||||
|
||||
$bookingDetailParam = [
|
||||
'criteria' => [
|
||||
['field' => 'booking_code', 'condition' => '=', 'value' => $params['bookingCode']],
|
||||
],
|
||||
'with' => ['property.propertyBrand', 'property.propertyExecutive', 'property.propertyUser.user','property.propertyBookingEngineToken'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$bookingDetail = $bookingService->select($bookingDetailParam);
|
||||
if ($bookingDetail['status'] != 'success') {
|
||||
throw new ApiErrorException($bookingDetail['message']);
|
||||
}
|
||||
|
||||
$bookingDetail = $bookingDetail['status'] == 'success' && !empty($bookingDetail['data']) ? $bookingDetail['data'] : null;
|
||||
|
||||
|
||||
$property = $bookingDetail['property'];
|
||||
|
||||
|
||||
//Mail Contact Data
|
||||
$reservationExecutives = [];
|
||||
if (isset($property['property_executive'])) {
|
||||
$reservationExecutives = collect($property['property_executive'])
|
||||
->where('executive_type_id', '=', '7')
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
foreach ($reservationExecutives as $reservationExecutive) {
|
||||
$bcc[] = $reservationExecutive['email'];
|
||||
}
|
||||
$bcc[] = "channel@extranetwork.com";
|
||||
|
||||
|
||||
$userData = $property['property_user'];
|
||||
$firstUserData = reset($userData);
|
||||
|
||||
foreach ($userData as $user) {
|
||||
if ($user['user']['email'] != $firstUserData['user']['email']) {
|
||||
$bcc[] = $user['user']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $firstUserData['user']['nameSurname'],
|
||||
'email' => $firstUserData['user']['email'],
|
||||
],
|
||||
'bcc' => $bcc
|
||||
|
||||
];
|
||||
|
||||
$locale = fillOnUndefined($firstUserData['user'], 'language', 'tr');
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
app('translator')->setLocale($locale);
|
||||
|
||||
|
||||
$mailParams = [
|
||||
'propertyName' => $property['name'],
|
||||
'bookingCode' => $params['bookingCode'],
|
||||
'logo' => $property['property_brand']['logoUrl'],
|
||||
'btnUrl' => config('app.bookingEngineUrl') . '/' . $property['property_booking_engine_token']['token'] . '/' . $locale . '/booking-detail/' . $params['bookingCode'],
|
||||
];
|
||||
|
||||
/*echo view('emails.bookingInvoiceUpdateMail', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['propertyName'])
|
||||
->view('emails.bookingInvoiceUpdateMail', compact('mailParams'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject(__('api-mailing-booking-invoice_update-title', ['bookingCode' => $mailParams['bookingCode']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
101
app/Core/Mail/BookingPaymentDataCodeMail.php
Normal file
101
app/Core/Mail/BookingPaymentDataCodeMail.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingPaymentDataCodeMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
$bookingService = App::make('App\Core\Service\BookingService');
|
||||
$userService = App::make('App\Core\Service\UserService');
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['booking_id']]
|
||||
],
|
||||
//'with' => ['bookingProperty.propertyExecutive', 'bookingProperty.propertyBookingEngineToken', 'bookingProperty.propertyBrand', 'bookingContact', 'bookingChannel', 'bookingPayment', 'bookingPaymentType', 'bookingStatus'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$booking = $bookingService->select($requestData);
|
||||
|
||||
if ($booking['status'] != 'success' || empty($booking['data'])) {
|
||||
throw new ApiErrorException(lang('Booking not found'));
|
||||
}
|
||||
|
||||
$booking = $booking['data'];
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['user_id']]
|
||||
],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$user = $userService->select($requestData);
|
||||
|
||||
if ($user['status'] != 'success' || empty($user['data'])) {
|
||||
throw new ApiErrorException(lang('User not found'));
|
||||
}
|
||||
|
||||
$user = $user['data'];
|
||||
|
||||
$mailParams = [
|
||||
'to' => $user['email'],
|
||||
'toNameSurname' => $user['nameSurname'],
|
||||
'bcc' => [],
|
||||
'unlockCode' => $params['unlock_code'],
|
||||
'bookingId' => fillOnUndefined($booking, 'id'),
|
||||
'propertyId' => fillOnUndefined($booking, 'property_id'),
|
||||
'bookingCode' => fillOnUndefined($booking, 'booking_code'),
|
||||
'locale' => fillOnUndefined($user, 'language', 'en'),
|
||||
];
|
||||
|
||||
|
||||
/*echo view('emails.bookingPaymentDataCode', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
$mailParams['bcc'][] = 'burhan@extranetwork.com';
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.bookingPaymentDataCode', compact('mailParams'))
|
||||
->to($mailParams['to'], $mailParams['toNameSurname'])
|
||||
->bcc($mailParams['bcc'])
|
||||
->subject(__('api-mailing-payment_data_code-subject',['bookingCode' => $mailParams['bookingCode']],$mailParams['locale']));
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
113
app/Core/Mail/BookingPropertyAddonUpdateMail.php
Normal file
113
app/Core/Mail/BookingPropertyAddonUpdateMail.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class BookingPropertyAddonUpdateMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\PropertyService");
|
||||
|
||||
$propertyParam = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['propertyId']],
|
||||
],
|
||||
'with' => ['propertyBrand', 'propertyExecutive', 'propertyUser.user','propertyBookingEngineToken'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$property = $propertyService->select($propertyParam);
|
||||
if ($property['status'] != 'success') {
|
||||
throw new ApiErrorException($property['message']);
|
||||
}
|
||||
|
||||
$property = $property['data'];
|
||||
|
||||
//Mail Contact Data
|
||||
$reservationExecutives = [];
|
||||
if (isset($property['property_executive'])) {
|
||||
$reservationExecutives = collect($property['property_executive'])
|
||||
->where('executive_type_id', '=', '7')
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
foreach ($reservationExecutives as $reservationExecutive) {
|
||||
$bcc[] = $reservationExecutive['email'];
|
||||
}
|
||||
$bcc[] = "channel@extranetwork.com";
|
||||
|
||||
|
||||
$userData = $property['property_user'];
|
||||
$firstUserData = reset($userData);
|
||||
|
||||
foreach ($userData as $user) {
|
||||
if ($user['user']['email'] != $firstUserData['user']['email']) {
|
||||
$bcc[] = $user['user']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $firstUserData['user']['nameSurname'],
|
||||
'email' => $firstUserData['user']['email'],
|
||||
],
|
||||
'bcc' => $bcc
|
||||
|
||||
];
|
||||
|
||||
$locale = fillOnUndefined($firstUserData['user'], 'language', 'tr');
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
app('translator')->setLocale($locale);
|
||||
|
||||
|
||||
$mailParams = [
|
||||
'propertyName' => $property['name'],
|
||||
'bookingCode' => $params['bookingCode'],
|
||||
'addonLanguageKey' => $params['addonLanguageKey'],
|
||||
'logo' => $property['property_brand']['logoUrl'],
|
||||
'btnUrl' => config('app.bookingEngineUrl') . '/' . $property['property_booking_engine_token']['token'] . '/' . $locale . '/booking-detail/' . $params['bookingCode'],
|
||||
];
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['propertyName'])
|
||||
->view('emails.bookingPropertyAddonUpdateMail', compact('mailParams'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject(__('api-mailing-booking-addon_update-title', ['bookingCode' => $mailParams['bookingCode'], 'addonLanguageKey' => __($mailParams['addonLanguageKey'])]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
140
app/Core/Mail/BookingTicketMail.php
Normal file
140
app/Core/Mail/BookingTicketMail.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use Exception;
|
||||
|
||||
class BookingTicketMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$bookingService = App::make('App\Core\Service\BookingService');
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['booking_id']]
|
||||
],
|
||||
'with' => ['bookingProperty.propertyExecutive', 'bookingProperty.propertyBookingEngineToken', 'bookingProperty.propertyBrand', 'bookingContact', 'bookingChannel', 'bookingPayment', 'bookingPaymentType', 'bookingStatus'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$booking = $bookingService->select($requestData);
|
||||
|
||||
if ($booking['status'] != 'success' || empty($booking['data'])) {
|
||||
throw new ApiErrorException(lang('Booking not found'));
|
||||
}
|
||||
|
||||
$booking = $booking['data'];
|
||||
|
||||
$locale = fillOnUndefined($params, 'locale', 'en');
|
||||
if (!is_null($params['user'])) {
|
||||
$locale = $booking['booking_contact']['language_code'];
|
||||
}
|
||||
app('translator')->setLocale($locale);
|
||||
|
||||
$propertyLogo = 'https://www.extranetwork.com/assets/img/logo/mini-logo.png';
|
||||
if (isset($booking['booking_property']['property_brand']['logo_name'])) {
|
||||
$propertyLogo = Config::get('app.imageUrl') . '/property-photos/' . $booking['booking_property']['id'] . "/logo/" . $booking['booking_property']['property_brand']['logo_name'] . '_250x250.' . $booking['booking_property']['property_brand']['logo_file_ext'];
|
||||
}
|
||||
|
||||
$bookingContact = [
|
||||
'mail' => $booking['booking_contact']['email'],
|
||||
'nameSurname' => $booking['booking_contact']['nameSurname'],
|
||||
];
|
||||
|
||||
if (!isset($booking['booking_property']['property_executive'])) {
|
||||
throw new ApiErrorException(lang('Property Executive not found'));
|
||||
}
|
||||
|
||||
$propertyExecutives = collect($booking['booking_property']['property_executive'])->where('status', 1)->where('executive_type_id', 7)->pluck('email')->toArray();
|
||||
|
||||
$params['subject'] = __('api-mailing-booking_ticket-subject', ['booking_code' => $booking['booking_code']]);//'Booking Ticket Message: ' . $booking['booking_code'];
|
||||
$params['mailSenderName'] = 'Extranetwork - ' . $booking['booking_property']['name'];
|
||||
|
||||
if (!is_null($params['user'])) {
|
||||
|
||||
$mailParams = [
|
||||
'to' => $bookingContact['mail'],
|
||||
'toNameSurname' => $bookingContact['mail'],
|
||||
'bcc' => [],
|
||||
'title' => __('general-hi') . ', ' . $bookingContact['nameSurname'],
|
||||
'logo' => $propertyLogo,
|
||||
'message' => __('api-mailing-booking_ticket-message-user', ['booking_code' => $booking['booking_code']]),
|
||||
'btnTitle' => __('api-mailing-booking_ticket-btn-message'),
|
||||
'btnUrl' => config('app.bookingEngineUrl') . '/' . $booking['booking_property']['property_booking_engine_token']['token'] . '/' . $locale . '/booking-detail/' . $booking['booking_code'],
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
if (empty($propertyExecutives)) {
|
||||
throw new ApiErrorException(lang('Property Executive not found'));
|
||||
}
|
||||
|
||||
$mailParams = [
|
||||
'to' => $propertyExecutives[0],
|
||||
'toNameSurname' => null,
|
||||
'bcc' => $propertyExecutives,
|
||||
'title' => __('general-hi') . ',',
|
||||
'logo' => $propertyLogo,
|
||||
'message' => __('api-mailing-booking_ticket-message-enw-user', ['booking_code' => $booking['booking_code'], 'property_name' => $booking['booking_property']['name']]),
|
||||
'btnTitle' => __('api-mailing-booking_ticket-btn-message'),
|
||||
'btnUrl' => config('app.client_server') . '/app/network/reservation/' . $booking['id'].'?propertyid='.$booking['property_id'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
//$bcc[] = "sales@extranetwork.com";
|
||||
$bcc = $mailParams['bcc'];
|
||||
$bcc[] = "channel@extranetwork.com";
|
||||
|
||||
/*echo view('emails.bookingTicketMail', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, $params['mailSenderName'])
|
||||
->view('emails.bookingTicketMail', compact('mailParams'))
|
||||
->to($mailParams['to'], $mailParams['toNameSurname'])
|
||||
->bcc($bcc)
|
||||
->subject($params['subject']);
|
||||
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
die();
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
277
app/Core/Mail/CancelBookingMail.php
Normal file
277
app/Core/Mail/CancelBookingMail.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class CancelBookingMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\PropertyService");
|
||||
$bookingService = App::make("App\Core\Service\BookingService");
|
||||
$propertyBrandService = App::make("App\Core\Service\PropertyBrandService");
|
||||
|
||||
$bookingDetailParam = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['booking_id']]
|
||||
],
|
||||
'with' => [
|
||||
'bookingPayment', 'bookingRoom.roomRateMapping.propertyRoom','bookingRoom.roomRateMapping.propertyRoomRate',
|
||||
'bookingContact','bookingProperty.propertyBrand', 'bookingProperty.propertyExecutive', 'bookingProperty.propertyUser.user',
|
||||
'bookingPropertyWeb', 'propertyBookingEngine', 'propertyBookingChannel'
|
||||
],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$bookingData = $bookingService->select($bookingDetailParam);
|
||||
$bookingData = $bookingData['data'];
|
||||
|
||||
|
||||
$hostAddress = Config::get('app.bookingEngineUrl') . '/' . $bookingData['property_booking_engine']['token'] . '/' . $bookingData['booking_contact']['language_code'] . '/booking-detail/' . $bookingData['booking_code'];
|
||||
|
||||
$brandRequestData = ['property_id' => $bookingData['property_id']];
|
||||
$getPropertyBrand = $propertyBrandService->getPropertyBrand($brandRequestData);
|
||||
if ($getPropertyBrand['status'] != "success") {
|
||||
throw new Exception($getPropertyBrand['message']);
|
||||
}
|
||||
|
||||
$propertyBrand = $getPropertyBrand['data'];
|
||||
$propertyBrandLogo = isset($propertyBrand['name'])
|
||||
? Config::get('app.fileSystemDriver') . '/property-photos/' . $propertyBrand['property_id'] . "/logo/" . $propertyBrand['name'] . '_250x250.' . $propertyBrand['logo_file_ext']
|
||||
: null;
|
||||
|
||||
$roomOrder = 1;
|
||||
$bookingChannelRoom = [];
|
||||
foreach ($bookingData['booking_room'] as $bookingRoom) {
|
||||
|
||||
if (!empty($bookingRoom['room_rate_mapping']['property_room'])) {
|
||||
$bookingRoom['room_name'] = $bookingRoom['room_rate_mapping']['property_room']['name'];
|
||||
}
|
||||
if (!empty($bookingRoom['room_rate_mapping']['property_room_rate'])) {
|
||||
$bookingRoom['room_rate_name'] = $bookingRoom['room_rate_mapping']['property_room_rate']['name'];
|
||||
}
|
||||
|
||||
$extraParam = null;
|
||||
if (!empty($bookingRoom['extra_param'])) {
|
||||
$extraParamDecode = json_decode($bookingRoom['extra_param'], 1);
|
||||
|
||||
foreach ($extraParamDecode as $extraParamKey => $extraParamValue) {
|
||||
|
||||
$extraParamTitle = explode('_', $extraParamKey);
|
||||
foreach ($extraParamTitle as $extraParamTitleKey => $extraParamTitleValue) {
|
||||
$extraParamTitle[$extraParamTitleKey] = ucwords($extraParamTitleValue);
|
||||
}
|
||||
$extraParamTitle = implode(' ', $extraParamTitle);
|
||||
|
||||
$extraParam[$extraParamKey] = [
|
||||
'title' => $extraParamTitle,
|
||||
'value' => $extraParamValue,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$additionalFee = null;
|
||||
if (!empty($bookingRoom['rate_detail'])) {
|
||||
$rateDetail = json_decode($bookingRoom['rate_detail'], 1);
|
||||
if(isset($rateDetail['taxes']) && $bookingData['channel_manager_id'] == 2) {
|
||||
$additionalFee = $rateDetail['taxes'];
|
||||
}
|
||||
}
|
||||
|
||||
$bookingChannelRoom[] = [
|
||||
'roomOrder' => $roomOrder,
|
||||
'roomName' => $bookingRoom['room_name'],
|
||||
'roomRateName' => $bookingRoom['room_rate_name'],
|
||||
'occupancyCode' => $bookingRoom['occupancy_code'],
|
||||
'occupancyText' => occupancyCodeFormatted($bookingRoom['occupancy_code']),
|
||||
'amount' => $bookingRoom['amount'],
|
||||
'discount_amount' => $bookingRoom['discount_amount'],
|
||||
'total' => $bookingRoom['total'],
|
||||
'currencyCode' => $bookingRoom['currency_code'],
|
||||
'dailyAmount' => !empty($bookingRoom['daily_amount']) ? json_decode($bookingRoom['daily_amount'],1) : null,
|
||||
'extraParam' => $extraParam,
|
||||
'occupancyFormatted' => occupancyCodeFormatted($bookingRoom['occupancy_code']),
|
||||
'additionalFee' => $additionalFee
|
||||
];
|
||||
|
||||
//$bookingChannelRoom[] = $roomOrder . '. ' . $bookingRoom['room_name'] . ' - ' . $bookingRoom['room_rate_name'] . ' - ' . occupancyCodeFormatted($bookingRoom['occupancy_code']);
|
||||
$roomOrder++;
|
||||
}
|
||||
|
||||
$userData = $bookingData['booking_property']['property_user'];
|
||||
$firstUserData = reset($userData);
|
||||
|
||||
if (in_array($bookingData['property_booking_channel']['channel_category_id'], [2,3])) {
|
||||
$bookingLanguageCode = fillOnUndefined($bookingData['booking_contact'], 'language_code', 'en');
|
||||
}else {
|
||||
$bookingLanguageCode = fillOnUndefined($firstUserData['user'], 'language', 'en');
|
||||
}
|
||||
|
||||
$bookingChannelPaymentType = __('property_booking_payment_type-pay_at_hotel',[],$bookingLanguageCode);
|
||||
$bookingChannelPaymentSource = null;
|
||||
if ($bookingData['booking_payment']['payment_type_code'] == 'CRD') {
|
||||
$bookingChannelPaymentType = __('property_booking_payment_type-credit_card',[],$bookingLanguageCode);
|
||||
if ($bookingData['booking_payment']['payment_source_code'] == 'OTA') {
|
||||
$bookingChannelPaymentSource = __('enw-ota-credit_card',[],$bookingLanguageCode);
|
||||
}
|
||||
if ($bookingData['booking_payment']['payment_source_code'] == 'GST') {
|
||||
$bookingChannelPaymentSource = __('enw-guest-credit_card',[],$bookingLanguageCode);
|
||||
}
|
||||
}
|
||||
|
||||
$creditCardInformation = null;
|
||||
if (!is_null($bookingData['booking_payment']['extra_param'])) {
|
||||
$paymentData = json_decode($bookingData['booking_payment']['extra_param'], 1);
|
||||
|
||||
if (isset($paymentData['attributes']['guarantee'])) {
|
||||
$creditCardInformation['cardNumber'] = isset($paymentData['attributes']['guarantee']['card_number']) ? $paymentData['attributes']['guarantee']['card_number'] : null;
|
||||
$creditCardInformation['cardHolderName'] = isset($paymentData['attributes']['guarantee']['cardholder_name']) ? $paymentData['attributes']['guarantee']['cardholder_name'] : null;
|
||||
$creditCardInformation['expirationDate'] = isset($paymentData['attributes']['guarantee']['expiration_date']) ? $paymentData['attributes']['guarantee']['expiration_date'] : null;
|
||||
$creditCardInformation['cvv'] = isset($paymentData['attributes']['guarantee']['cvv']) ? $paymentData['attributes']['guarantee']['cvv'] : null;
|
||||
}
|
||||
}
|
||||
|
||||
//Genius Member
|
||||
$bookingContactExtraParam = null;
|
||||
if(!empty($bookingData['booking_contact']['extra_param'])) {
|
||||
$bookingContactExtraParam = json_decode($bookingData['booking_contact']['extra_param'],1);
|
||||
}
|
||||
$isBookingGenius = false;
|
||||
if(isset($bookingContactExtraParam['is_genius']) && $bookingContactExtraParam['is_genius']) {
|
||||
$isBookingGenius = true;
|
||||
}
|
||||
|
||||
$mailParams = [
|
||||
'bookingId' => $bookingData['id'],
|
||||
'bookingCode' => $bookingData['booking_code'],
|
||||
'propertyId' => $bookingData['booking_property']['id'],
|
||||
'booking_code' => $bookingData['booking_code'],
|
||||
'search_key' => $bookingData['search_key'],
|
||||
'channel_token' => $bookingData['channel_token'],
|
||||
'booking_engine_token' => $bookingData['booking_engine_token'],
|
||||
'checkin_date' => Carbon::parse($bookingData['checkin_date'])->format('d.m.Y'),
|
||||
'checkout_date' => Carbon::parse($bookingData['checkout_date'])->format('d.m.Y'),
|
||||
'payment_type_code' => $bookingData['booking_payment']['payment_type_code'],
|
||||
'payment_source_code' => $bookingData['booking_payment']['payment_source_code'],
|
||||
'room_amount' => $bookingData['room_amount'],
|
||||
'addon_amount' => $bookingData['addon_amount'],
|
||||
'discount_amount' => $bookingData['discount_amount'],
|
||||
'total' => $bookingData['total'],
|
||||
'currency_code' => $bookingData['currency_code'],
|
||||
'name_surname' => $bookingData['booking_contact']['nameSurname'],
|
||||
'countryCode' => upperCase($bookingData['booking_contact']['country_code']),
|
||||
'email' => $bookingData['booking_contact']['email'],
|
||||
'property_name' => $bookingData['booking_property']['name'],
|
||||
'url' => $hostAddress,
|
||||
'logo' => $bookingData['booking_property']['property_brand']['logoUrl'],
|
||||
'language_code' => $bookingData['booking_contact']['language_code'],
|
||||
'bookingChannelId' => $bookingData['channel_id'],
|
||||
'bookingChannelName' => fillOnUndefined($bookingData['property_booking_channel'], 'name'),
|
||||
'bookingChannelCategoryId' => $bookingData['property_booking_channel']['channel_category_id'],
|
||||
'bookingChannelCode' => $bookingData['channel_booking_code'],
|
||||
'bookingChannelContactNameSurname' => $bookingData['booking_contact']['nameSurname'],
|
||||
'bookingChannelContactEmail' => $bookingData['booking_contact']['email'],
|
||||
'bookingChannelContactPhone' => $bookingData['booking_contact']['phone_number'],
|
||||
'bookingChannelNote' => $bookingData['booking_contact']['note'],
|
||||
'bookingChannelRoom' => $bookingChannelRoom,
|
||||
'bookingChannelPaymentType' => $bookingChannelPaymentType,
|
||||
'bookingChannelPaymentSource' => $bookingChannelPaymentSource,
|
||||
'creditCardInformation' => $creditCardInformation,
|
||||
'isBookingGenius' => $isBookingGenius
|
||||
];
|
||||
|
||||
//Mail Contact Data
|
||||
$reservationExecutives = [];
|
||||
if (isset($bookingData['booking_property']['property_executive'])) {
|
||||
$reservationExecutives = collect($bookingData['booking_property']['property_executive'])
|
||||
->where('executive_type_id', '=', '7') // sadece rezervasyon yetkisi olanlar ...
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
foreach ($reservationExecutives as $reservationExecutive) {
|
||||
$bcc[] = $reservationExecutive['email'];
|
||||
}
|
||||
$bcc[] = "channel@extranetwork.com";
|
||||
|
||||
foreach ($userData as $user) {
|
||||
if ($user['user']['email'] != $firstUserData['user']['email']) {
|
||||
$bcc[] = $user['user']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
//Booking Engine ve Offline Channel to Customer Info's
|
||||
if (in_array($bookingData['property_booking_channel']['channel_category_id'], [2,3])) {
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $bookingData['booking_contact']['nameSurname'],
|
||||
'email' => $bookingData['booking_contact']['email']
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $bookingData['booking_property']['name'],
|
||||
'email' => $firstUserData['user']['email']
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$mailData['bcc'] = $bcc;
|
||||
|
||||
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
//app('translator')->setLocale(fillOnUndefined($firstUserData['user'], 'language', 'tr'));
|
||||
app('translator')->setLocale($bookingLanguageCode);
|
||||
|
||||
$mailParams['showCreditCardUrl'] = null;
|
||||
if(!empty($mailParams['creditCardInformation'])) {
|
||||
$mailParams['showCreditCardUrl'] = Config::get('app.client_server').'/app/network/reservation/'.$mailParams['bookingId'].'?propertyid='.$mailParams['propertyId'];
|
||||
}
|
||||
|
||||
/*echo view('emails.cancelBookingMail', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.cancelBookingMail', compact('mailParams'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject(__('api-malling-booking-cancel_booking-title', ['channel' => $mailParams['bookingChannelName']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
70
app/Core/Mail/ChannelManagerNotificationMail.php
Normal file
70
app/Core/Mail/ChannelManagerNotificationMail.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class ChannelManagerNotificationMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$propertyService = App::make('App\Core\Service\PropertyService');
|
||||
|
||||
$requestData = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['propertyId']]
|
||||
],
|
||||
'with' => ['propertyUser.user'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$propertyDetail = $propertyService->select($requestData);
|
||||
|
||||
$propertyUser = [];
|
||||
if($propertyDetail['status'] == 'success' && !empty($propertyDetail['data'])) {
|
||||
$propertyUser = collect($propertyDetail['data']['property_user'])->where('status',1)->pluck('user.email')->toArray();
|
||||
}
|
||||
|
||||
/*echo view('emails.channelManagerNotificationMail', compact('params'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.channelManagerNotificationMail', compact('params'))
|
||||
->to('channel@extranetwork.com', 'Extranetwork Channel')
|
||||
->bcc($propertyUser)
|
||||
->subject('Channel Update Error: ' . $params['propertyName']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Core/Mail/ContactFormMail.php
Normal file
58
app/Core/Mail/ContactFormMail.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class ContactFormMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$params = $this->param;
|
||||
$mailParams = $params['mailViewParams'] ;
|
||||
$mailData = $params['mailData'] ;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress') ;
|
||||
$mailTitle = $mailData['to']["name"]. ' Contact Form (' . $mailParams['name']. ' '.$mailParams['surname']. ')' ;
|
||||
|
||||
|
||||
app('translator')->setLocale('en');
|
||||
|
||||
return $this->from($mailSenderAddress, $mailParams['name']. ' '.$mailParams['surname'])
|
||||
->view('emails.contactFormMail', compact('mailParams', 'mailTitle'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($mailTitle)
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$message = $e->getFile()." ".$e->getLine()." ".$e->getMessage();
|
||||
Log::error($message);
|
||||
return output( ['status' => -1, 'message' => $e->getMessage()] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
55
app/Core/Mail/DailyReportMail.php
Normal file
55
app/Core/Mail/DailyReportMail.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class DailyReportMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
/*echo view('emails.dailyReportMail', compact('params'));
|
||||
die();*/
|
||||
|
||||
$to = 'yoy@extranetwork.com';
|
||||
$bcc[] = 'burhan@extranetwork.com';
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.dailyReportMail', compact('params'))
|
||||
->to($to, 'Extranetwork')
|
||||
->bcc($bcc)
|
||||
->subject('Extranetwork Summary Report - '. $params['daily']['period']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Core/Mail/DailyReportMailSales.php
Normal file
58
app/Core/Mail/DailyReportMailSales.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class DailyReportMailSales extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
|
||||
/*echo view('emails.dailyReportMailSales', compact('params'));
|
||||
die();*/
|
||||
|
||||
$to = $params['email'];
|
||||
$bcc[] = 'yoy@extranetwork.com';
|
||||
$bcc[] = 'burhan@extranetwork.com';
|
||||
$bcc[] = 'cemile@extranetwork.com';
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.dailyReportMailSales', compact('params'))
|
||||
->to($to, 'Extranetwork')
|
||||
->bcc($bcc)
|
||||
->subject('Extranetwork Summary Report - '. $params['daily']['period'].' - '. $params['name']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Core/Mail/EnwContactFormMail.php
Normal file
54
app/Core/Mail/EnwContactFormMail.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class EnwContactFormMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$params = $this->param;
|
||||
$mailParams = $params['mailViewParams'] ;
|
||||
$mailData = $params['mailData'] ;
|
||||
$mailTitle = __('myweb-contact-contact_form-title');
|
||||
|
||||
app('translator')->setLocale($mailParams['language']);
|
||||
|
||||
return $this->view('emails.enwContactFormMail', compact('mailParams', 'mailTitle'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($mailTitle);
|
||||
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$message = $e->getFile()." ".$e->getLine()." ".$e->getMessage();
|
||||
Log::error($message);
|
||||
return output( ['status' => -1, 'message' => $e->getMessage()] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
60
app/Core/Mail/InventoryActionMail.php
Normal file
60
app/Core/Mail/InventoryActionMail.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class InventoryActionMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
app('translator')->setLocale(fillOnUndefined($params, 'locale', 'en'));
|
||||
|
||||
$params['title'] = $params['propertyName'] . ' - ' . __('enw-action-mail-title');
|
||||
$params['channelContact'] = $params['channelContact'];
|
||||
|
||||
if(empty($params['channelContact'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*echo view('emails.inventoryActionMail', compact('params'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - '.$params['propertyName'])
|
||||
->view('emails.inventoryActionMail', compact('params'))
|
||||
//->to($logMailAddress, 'Development Team')
|
||||
->bcc($params['channelContact'])
|
||||
->subject($params['title']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
60
app/Core/Mail/InventoryPdfLinkMail.php
Normal file
60
app/Core/Mail/InventoryPdfLinkMail.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class InventoryPdfLinkMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
app('translator')->setLocale(fillOnUndefined($params, 'locale', 'en'));
|
||||
|
||||
$params['title'] = $params['propertyName'] . ' - ' . __('enw-inventory-mail-pdf-link');
|
||||
$params['channelContact'] = $params['channelContact'];
|
||||
|
||||
if(empty($params['channelContact'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*echo view('emails.inventoryActionMail', compact('params'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - '.$params['propertyName'])
|
||||
->view('emails.inventoryPdfLinkMail', compact('params'))
|
||||
//->to($logMailAddress, 'Development Team')
|
||||
->bcc($params['channelContact'])
|
||||
->subject($params['title']);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
52
app/Core/Mail/LogMail.php
Normal file
52
app/Core/Mail/LogMail.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class LogMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 2;
|
||||
public $timeout = 20;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
$logMailAddress = Config::get('app.logMailAddress');
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$params['title'] = 'ENW LOG - ' . $params['title'];
|
||||
|
||||
app('translator')->setLocale('tr');
|
||||
|
||||
return $this->from($mailSenderAddress, 'Development Team')
|
||||
->view('emails.logMail', compact('params'))
|
||||
->to($logMailAddress, 'Development Team')
|
||||
//->bcc(['bd@extranetwork.com'])
|
||||
->subject($params['title']);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
64
app/Core/Mail/ManualPaymentMail.php
Normal file
64
app/Core/Mail/ManualPaymentMail.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class ManualPaymentMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$params = $this->param;
|
||||
$mailParams = $params['mailViewParams'] ;
|
||||
|
||||
$mailData = $params['mailData'] ;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress') ;
|
||||
app('translator')->setLocale($mailParams["language_code"]);
|
||||
|
||||
$description = __('api-manual_payment_mail-desc',[
|
||||
'title' => $mailParams['process_title'] ,
|
||||
'date' => $mailParams['date_time'],
|
||||
'amount' => $mailParams['amount'],
|
||||
'currency' => $mailParams['currency']
|
||||
]);
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - '.$mailParams['property_name'])
|
||||
->view('emails.manualPaymentMail', compact('mailParams', 'description'))
|
||||
->to($mailData['to']["email"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject(__('api-manual_payment_mail-subject'))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$message = $e->getFile()." ".$e->getLine()." ".$e->getMessage();
|
||||
Log::error($message);
|
||||
return output( ['status' => -1, 'message' => $e->getMessage()] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
264
app/Core/Mail/ModifiedBookingMail.php
Normal file
264
app/Core/Mail/ModifiedBookingMail.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Core\Service\PropertyBrandService;
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class ModifiedBookingMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\PropertyService");
|
||||
$bookingService = App::make("App\Core\Service\BookingService");
|
||||
$propertyBrandService = App::make("App\Core\Service\PropertyBrandService");
|
||||
|
||||
|
||||
$bookingDetailParam = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['booking_id']]
|
||||
],
|
||||
'with' => [
|
||||
'bookingPayment', 'bookingRoom.roomRateMapping.propertyRoom','bookingRoom.roomRateMapping.propertyRoomRate',
|
||||
'bookingContact','bookingProperty.propertyBrand', 'bookingProperty.propertyExecutive', 'bookingProperty.propertyUser.user',
|
||||
'bookingPropertyWeb', 'propertyBookingEngine', 'propertyBookingChannel'
|
||||
],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$bookingData = $bookingService->select($bookingDetailParam);
|
||||
$bookingData = $bookingData['data'];
|
||||
|
||||
|
||||
$hostAddress = Config::get('app.bookingEngineUrl') . '/' . $bookingData['property_booking_engine']['token'] . '/' . $bookingData['booking_contact']['language_code'] . '/booking-detail/' . $bookingData['booking_code'];
|
||||
|
||||
$brandRequestData = ['property_id' => $bookingData['property_id']];
|
||||
$getPropertyBrand = $propertyBrandService->getPropertyBrand($brandRequestData);
|
||||
if ($getPropertyBrand['status'] != "success") {
|
||||
throw new Exception($getPropertyBrand['message']);
|
||||
}
|
||||
|
||||
$propertyBrand = $getPropertyBrand['data'];
|
||||
$propertyBrandLogo = isset($propertyBrand['name'])
|
||||
? Config::get('app.fileSystemDriver') . '/property-photos/' . $propertyBrand['property_id'] . "/logo/" . $propertyBrand['name'] . '_250x250.' . $propertyBrand['logo_file_ext']
|
||||
: null;
|
||||
|
||||
$roomOrder = 1;
|
||||
$bookingChannelRoom = [];
|
||||
foreach ($bookingData['booking_room'] as $bookingRoom) {
|
||||
|
||||
if (!empty($bookingRoom['room_rate_mapping']['property_room'])) {
|
||||
$bookingRoom['room_name'] = $bookingRoom['room_rate_mapping']['property_room']['name'];
|
||||
}
|
||||
if (!empty($bookingRoom['room_rate_mapping']['property_room_rate'])) {
|
||||
$bookingRoom['room_rate_name'] = $bookingRoom['room_rate_mapping']['property_room_rate']['name'];
|
||||
}
|
||||
|
||||
$extraParam = null;
|
||||
if (!empty($bookingRoom['extra_param'])) {
|
||||
$extraParamDecode = json_decode($bookingRoom['extra_param'], 1);
|
||||
|
||||
foreach ($extraParamDecode as $extraParamKey => $extraParamValue) {
|
||||
|
||||
$extraParamTitle = explode('_', $extraParamKey);
|
||||
foreach ($extraParamTitle as $extraParamTitleKey => $extraParamTitleValue) {
|
||||
$extraParamTitle[$extraParamTitleKey] = ucwords($extraParamTitleValue);
|
||||
}
|
||||
$extraParamTitle = implode(' ', $extraParamTitle);
|
||||
|
||||
$extraParam[$extraParamKey] = [
|
||||
'title' => $extraParamTitle,
|
||||
'value' => $extraParamValue,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$additionalFee = null;
|
||||
if (!empty($bookingRoom['rate_detail'])) {
|
||||
$rateDetail = json_decode($bookingRoom['rate_detail'], 1);
|
||||
if(isset($rateDetail['taxes']) && $bookingData['channel_manager_id'] == 2) {
|
||||
$additionalFee = $rateDetail['taxes'];
|
||||
}
|
||||
}
|
||||
|
||||
$bookingChannelRoom[] = [
|
||||
'roomOrder' => $roomOrder,
|
||||
'roomName' => $bookingRoom['room_name'],
|
||||
'roomRateName' => $bookingRoom['room_rate_name'],
|
||||
'occupancyCode' => $bookingRoom['occupancy_code'],
|
||||
'occupancyText' => occupancyCodeFormatted($bookingRoom['occupancy_code']),
|
||||
'amount' => $bookingRoom['amount'],
|
||||
'discount_amount' => $bookingRoom['discount_amount'],
|
||||
'total' => $bookingRoom['total'],
|
||||
'currencyCode' => $bookingRoom['currency_code'],
|
||||
'dailyAmount' => !empty($bookingRoom['daily_amount']) ? json_decode($bookingRoom['daily_amount'],1) : null,
|
||||
'extraParam' => $extraParam,
|
||||
'occupancyFormatted' => occupancyCodeFormatted($bookingRoom['occupancy_code']),
|
||||
'additionalFee' => $additionalFee
|
||||
];
|
||||
|
||||
//$bookingChannelRoom[] = $roomOrder . '. ' . $bookingRoom['room_name'] . ' - ' . $bookingRoom['room_rate_name'] . ' - ' . occupancyCodeFormatted($bookingRoom['occupancy_code']);
|
||||
$roomOrder++;
|
||||
}
|
||||
|
||||
$userData = $bookingData['booking_property']['property_user'];
|
||||
$firstUserData = reset($userData);
|
||||
|
||||
$bookingLanguageCode = fillOnUndefined($firstUserData['user'], 'language', 'en');
|
||||
$bookingChannelPaymentType = __('property_booking_payment_type-pay_at_hotel',[],$bookingLanguageCode);
|
||||
$bookingChannelPaymentSource = null;
|
||||
if ($bookingData['booking_payment']['payment_type_code'] == 'CRD') {
|
||||
$bookingChannelPaymentType = __('property_booking_payment_type-credit_card',[],$bookingLanguageCode);
|
||||
if ($bookingData['booking_payment']['payment_source_code'] == 'OTA') {
|
||||
$bookingChannelPaymentSource = __('enw-ota-credit_card',[],$bookingLanguageCode);
|
||||
}
|
||||
if ($bookingData['booking_payment']['payment_source_code'] == 'GST') {
|
||||
$bookingChannelPaymentSource = __('enw-guest-credit_card',[],$bookingLanguageCode);
|
||||
}
|
||||
}
|
||||
|
||||
$creditCardInformation = null;
|
||||
if (!is_null($bookingData['booking_payment']['extra_param'])) {
|
||||
$paymentData = json_decode($bookingData['booking_payment']['extra_param'], 1);
|
||||
|
||||
if (isset($paymentData['attributes']['guarantee'])) {
|
||||
$creditCardInformation['cardNumber'] = isset($paymentData['attributes']['guarantee']['card_number']) ? $paymentData['attributes']['guarantee']['card_number'] : null;
|
||||
$creditCardInformation['cardHolderName'] = isset($paymentData['attributes']['guarantee']['cardholder_name']) ? $paymentData['attributes']['guarantee']['cardholder_name'] : null;
|
||||
$creditCardInformation['expirationDate'] = isset($paymentData['attributes']['guarantee']['expiration_date']) ? $paymentData['attributes']['guarantee']['expiration_date'] : null;
|
||||
$creditCardInformation['cvv'] = isset($paymentData['attributes']['guarantee']['cvv']) ? $paymentData['attributes']['guarantee']['cvv'] : null;
|
||||
}
|
||||
}
|
||||
|
||||
//Genius Member
|
||||
$bookingContactExtraParam = null;
|
||||
if(!empty($bookingData['booking_contact']['extra_param'])) {
|
||||
$bookingContactExtraParam = json_decode($bookingData['booking_contact']['extra_param'],1);
|
||||
}
|
||||
$isBookingGenius = false;
|
||||
if(isset($bookingContactExtraParam['is_genius']) && $bookingContactExtraParam['is_genius']) {
|
||||
$isBookingGenius = true;
|
||||
}
|
||||
|
||||
$mailParams = [
|
||||
'bookingId' => $bookingData['id'],
|
||||
'bookingCode' => $bookingData['booking_code'],
|
||||
'propertyId' => $bookingData['booking_property']['id'],
|
||||
'booking_code' => $bookingData['booking_code'],
|
||||
'search_key' => $bookingData['search_key'],
|
||||
'channel_token' => $bookingData['channel_token'],
|
||||
'booking_engine_token' => $bookingData['booking_engine_token'],
|
||||
'checkin_date' => Carbon::parse($bookingData['checkin_date'])->format('d.m.Y'),
|
||||
'checkout_date' => Carbon::parse($bookingData['checkout_date'])->format('d.m.Y'),
|
||||
'payment_type_code' => $bookingData['booking_payment']['payment_type_code'],
|
||||
'payment_source_code' => $bookingData['booking_payment']['payment_source_code'],
|
||||
'room_amount' => $bookingData['room_amount'],
|
||||
'addon_amount' => $bookingData['addon_amount'],
|
||||
'discount_amount' => $bookingData['discount_amount'],
|
||||
'total' => $bookingData['total'],
|
||||
'currency_code' => $bookingData['currency_code'],
|
||||
'name_surname' => $bookingData['booking_contact']['nameSurname'],
|
||||
'countryCode' => upperCase($bookingData['booking_contact']['country_code']),
|
||||
'email' => $bookingData['booking_contact']['email'],
|
||||
'property_name' => $bookingData['booking_property']['name'],
|
||||
'url' => $hostAddress,
|
||||
'logo' => $bookingData['booking_property']['property_brand']['logoUrl'],
|
||||
'language_code' => $bookingData['booking_contact']['language_code'],
|
||||
'bookingChannelId' => $bookingData['channel_id'],
|
||||
'bookingChannelName' => fillOnUndefined($bookingData['property_booking_channel'], 'name'),
|
||||
'bookingChannelCategoryId' => $bookingData['property_booking_channel']['channel_category_id'],
|
||||
'bookingChannelCode' => $bookingData['channel_booking_code'],
|
||||
'bookingChannelContactNameSurname' => $bookingData['booking_contact']['nameSurname'],
|
||||
'bookingChannelContactEmail' => $bookingData['booking_contact']['email'],
|
||||
'bookingChannelContactPhone' => $bookingData['booking_contact']['phone_number'],
|
||||
'bookingChannelNote' => $bookingData['booking_contact']['note'],
|
||||
'bookingChannelRoom' => $bookingChannelRoom,
|
||||
'bookingChannelPaymentType' => $bookingChannelPaymentType,
|
||||
'bookingChannelPaymentSource' => $bookingChannelPaymentSource,
|
||||
'creditCardInformation' => $creditCardInformation,
|
||||
'isBookingGenius' => $isBookingGenius
|
||||
];
|
||||
|
||||
//Mail Contact Data
|
||||
$reservationExecutives = [];
|
||||
if (isset($bookingData['booking_property']['property_executive'])) {
|
||||
$reservationExecutives = collect($bookingData['booking_property']['property_executive'])
|
||||
->where('executive_type_id', '=', '7') // sadece rezervasyon yetkisi olanlar ...
|
||||
->values()->all();
|
||||
}
|
||||
|
||||
foreach ($reservationExecutives as $reservationExecutive) {
|
||||
$bcc[] = $reservationExecutive['email'];
|
||||
}
|
||||
$bcc[] = "channel@extranetwork.com";
|
||||
|
||||
|
||||
|
||||
foreach ($userData as $user) {
|
||||
if ($user['user']['email'] != $firstUserData['user']['email']) {
|
||||
$bcc[] = $user['user']['email'];
|
||||
}
|
||||
}
|
||||
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $firstUserData['user']['nameSurname'],
|
||||
'email' => $firstUserData['user']['email'],
|
||||
],
|
||||
'bcc' => $bcc
|
||||
];
|
||||
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
//app('translator')->setLocale(fillOnUndefined($firstUserData['user'], 'language', 'tr'));
|
||||
app('translator')->setLocale($bookingLanguageCode);
|
||||
|
||||
$mailParams['showCreditCardUrl'] = null;
|
||||
if(!empty($mailParams['creditCardInformation'])) {
|
||||
$mailParams['showCreditCardUrl'] = Config::get('app.client_server').'/app/network/reservation/'.$mailParams['bookingId'].'?propertyid='.$mailParams['propertyId'];
|
||||
}
|
||||
|
||||
/*echo view('emails.modifiedBookingMail', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.modifiedBookingMail', compact('mailParams'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject(__('api-mailing-booking-modified_booking-title', ['channel' => $mailParams['bookingChannelName']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
68
app/Core/Mail/NewBookingMail.php
Normal file
68
app/Core/Mail/NewBookingMail.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class NewBookingMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
$mailParams = $params['mailViewParams'];
|
||||
|
||||
$mailData = $params['mailData'];
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
app('translator')->setLocale($mailParams["language_code"]);
|
||||
|
||||
$bookingData = __('api-mailling-booking-desc', [
|
||||
'booking_code' => $mailParams['booking_code'],
|
||||
'property_name' => $mailParams['property_name'],
|
||||
'checkin_date' => $mailParams['checkin_date'],
|
||||
'checkout_date' => $mailParams['checkout_date']
|
||||
]);
|
||||
|
||||
$mailSubject = __('api-malling-booking-new_booking_info-title');
|
||||
if (isset($mailParams['bookingChannelCategoryId']) && $mailParams['bookingChannelCategoryId'] != 3) {
|
||||
$mailSubject = $mailParams['bookingChannelName'] . ' - ' . $mailSubject;
|
||||
}
|
||||
|
||||
/*echo view('emails.newBookingMail', compact('mailParams', 'bookingData'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.newBookingMail', compact('mailParams', 'bookingData'))
|
||||
->to($mailData['to']["email"], $mailData['to']["name"])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject('🛎️ '.$mailSubject)
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
106
app/Core/Mail/OfferAcceptMail.php
Normal file
106
app/Core/Mail/OfferAcceptMail.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class OfferAcceptMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\OfferService");
|
||||
|
||||
$requestParams = [
|
||||
'offer_id' => fillOnUndefined($params, 'offer_id'),
|
||||
'property_id' => fillOnUndefined($params, 'property_id'),
|
||||
];
|
||||
|
||||
|
||||
$offerDetail = $propertyService->findOffer($requestParams);
|
||||
$offerDetail = fillOnUndefined($offerDetail, 'data');
|
||||
|
||||
app('translator')->setLocale($offerDetail["language"]);
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$mailParams['to'] = [];
|
||||
$mailParams['to'] = $offerDetail['email'];
|
||||
|
||||
$mailParams['cc'] = [];
|
||||
if (!empty($offerDetail['create_user'])) {
|
||||
$mailParams['cc'][] = $offerDetail['create_user']['email'];
|
||||
}
|
||||
|
||||
$mailParams['bcc'] = [];
|
||||
$mailParams['bcc'][] = Config::get('app.logMailAddress');
|
||||
|
||||
|
||||
$mailParams['property_name'] = $offerDetail['property']['name'];
|
||||
$mailParams['url'] = Config::get('app.client_server').'/offer/'.$offerDetail['offer_code'];
|
||||
|
||||
|
||||
$mailParams['paymentUrl'] = null;
|
||||
if(isset($params['paymentUrl']) && !is_null($params['paymentUrl'])) {
|
||||
$mailParams['paymentUrl'] = $params['paymentUrl'];
|
||||
}
|
||||
|
||||
$description = [];
|
||||
//$description[] = '<b>'.$offerDetail['property']['name'].'</b> tarafından oluşturulan <b>'.$offerDetail['ticket_code'].'</b> kodlu teklif onaylanmıştır.';
|
||||
$description[] = __('api-mailing-offer_accept_mail-description', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]);
|
||||
|
||||
if(!is_null($offerDetail['payment_type_mapping_id']) && !empty($mailParams['paymentUrl'])) {
|
||||
//$description[] = 'Teklife ait ödemenizi aşağıdaki <b>Ödeme Linki</b> üzerinden güvenle gerçekleştirebilirsiniz.';
|
||||
$description[] = __('api-mailing-offer_accept_mail-payment');
|
||||
}
|
||||
|
||||
$description = implode('<br><br>', $description);
|
||||
|
||||
$mailParams['logo'] = Config::get('app.webUrl').'/assets/img/logo/mini-logo.png';
|
||||
if(isset($offerDetail['property_brand']['logoUrl'])) {
|
||||
$mailParams['logo'] = $offerDetail['property_brand']['logoUrl'];
|
||||
}
|
||||
|
||||
|
||||
/*echo view('emails.offerAcceptMail', compact('mailParams', 'description'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.offerAcceptMail', compact('mailParams', 'description'))
|
||||
->to($mailParams['to'])
|
||||
->cc($mailParams['cc'])
|
||||
->bcc($mailParams['bcc'])
|
||||
->subject(__('api-mailing-offer_accept_mail-title', ['code' => $offerDetail['ticket_code']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
91
app/Core/Mail/OfferPreConfirmCustomerMail.php
Normal file
91
app/Core/Mail/OfferPreConfirmCustomerMail.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class OfferPreConfirmCustomerMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\OfferService");
|
||||
|
||||
$requestParams = [
|
||||
'offer_id' => fillOnUndefined($params, 'offer_id'),
|
||||
'property_id' => fillOnUndefined($params, 'property_id'),
|
||||
];
|
||||
|
||||
$offerDetail = $propertyService->findOffer($requestParams);
|
||||
$offerDetail = fillOnUndefined($offerDetail, 'data');
|
||||
|
||||
app('translator')->setLocale($offerDetail["language"]);
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$mailParams['to'] = [];
|
||||
$mailParams['to'] = $offerDetail['email'];
|
||||
|
||||
$mailParams['bcc'] = [];
|
||||
$mailParams['bcc'][] = Config::get('app.logMailAddress');
|
||||
|
||||
|
||||
$mailParams['property_name'] = $offerDetail['property']['name'];
|
||||
$mailParams['url'] = Config::get('app.client_server').'/offer/'.$offerDetail['offer_code'];
|
||||
|
||||
$mailParams['logo'] = Config::get('app.webUrl').'/assets/img/logo/mini-logo.png';
|
||||
if(isset($offerDetail['property_brand']['logoUrl'])) {
|
||||
$mailParams['logo'] = $offerDetail['property_brand']['logoUrl'];
|
||||
}
|
||||
|
||||
$description = [];
|
||||
//$description[] = '<b>'.$offerDetail['property']['name'].'</b> tarafından oluşturulan <b>'.$offerDetail['ticket_code'].'</b> kodlu teklifi onayladınız.';
|
||||
$description[] = __('api-mailing-offer_preconfirm_customer_mail-description-one', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]);
|
||||
//$description[] = 'Onayınız tesisimize bildirilmiştir. Tesisin teklifi onaylaması beklenmektedir, onaya istinaden size dönüş yapılacaktır.';
|
||||
$description[] = __('api-mailing-offer_preconfirm_customer_mail-description-two');
|
||||
|
||||
$description = implode('<br><br>', $description);
|
||||
|
||||
|
||||
/*echo view('emails.offerPreConfirmCustomerMail', compact('mailParams', 'description'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.offerPreConfirmCustomerMail', compact('mailParams', 'description'))
|
||||
->to($mailParams['to'])
|
||||
->bcc($mailParams['bcc'])
|
||||
//->subject($offerDetail['ticket_code'].' Kodlu Teklifiniz Tesis Onayı Bekliyor')
|
||||
->subject(__('api-mailing-offer_preconfirm_customer_mail-title', ['code' => $offerDetail['ticket_code']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
91
app/Core/Mail/OfferPreConfirmPropertyMail.php
Normal file
91
app/Core/Mail/OfferPreConfirmPropertyMail.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class OfferPreConfirmPropertyMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\OfferService");
|
||||
|
||||
$requestParams = [
|
||||
'offer_id' => fillOnUndefined($params, 'offer_id'),
|
||||
'property_id' => fillOnUndefined($params, 'property_id'),
|
||||
];
|
||||
|
||||
$offerDetail = $propertyService->findOffer($requestParams);
|
||||
$offerDetail = fillOnUndefined($offerDetail, 'data');
|
||||
|
||||
app('translator')->setLocale($offerDetail["language"]);
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$mailParams['to'] = [];
|
||||
$mailParams['to'] = $offerDetail['create_user']['email'];
|
||||
|
||||
$mailParams['bcc'] = [];
|
||||
$mailParams['bcc'][] = Config::get('app.logMailAddress');
|
||||
|
||||
|
||||
$mailParams['property_name'] = $offerDetail['property']['name'];
|
||||
$mailParams['url'] = Config::get('app.client_server').'/offer/'.$offerDetail['offer_code'];
|
||||
|
||||
$mailParams['logo'] = Config::get('app.webUrl').'/assets/img/logo/mini-logo.png';
|
||||
if(isset($offerDetail['property_brand']['logoUrl'])) {
|
||||
$mailParams['logo'] = $offerDetail['property_brand']['logoUrl'];
|
||||
}
|
||||
|
||||
$description = [];
|
||||
//$description[] = 'Misafir, <b>'.$offerDetail['ticket_code'].'</b> kodlu teklifi onaylamıştır.';
|
||||
$description[] = __('api-mailing-offer_preconfirm_property_mail-description-one', ['code' => $offerDetail['ticket_code']]);
|
||||
//$description[] = 'Teklif türü otel onaylı olduğu için, tesis onayı beklenmektedir. Tesis onayını Extranetwork üzerinden verebilirsiniz.';
|
||||
$description[] = __('api-mailing-offer_preconfirm_property_mail-description-two');
|
||||
|
||||
$description = implode('<br><br>', $description);
|
||||
|
||||
|
||||
/*echo view('emails.offerPreConfirmPropertyMail', compact('mailParams', 'description'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.offerPreConfirmPropertyMail', compact('mailParams', 'description'))
|
||||
->to($mailParams['to'])
|
||||
->bcc($mailParams['bcc'])
|
||||
//->subject($offerDetail['ticket_code'].' Kodlu Teklif Misafir Onayı')
|
||||
->subject(__('api-mailing-offer_preconfirm_property_mail-title', ['code' => $offerDetail['ticket_code']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
86
app/Core/Mail/OfferSendMail.php
Normal file
86
app/Core/Mail/OfferSendMail.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class OfferSendMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
$params = $this->param;
|
||||
|
||||
$propertyService = App::make("App\Core\Service\OfferService");
|
||||
|
||||
$requestParams = [
|
||||
'offer_id' => fillOnUndefined($params, 'offer_id'),
|
||||
'property_id' => fillOnUndefined($params, 'property_id'),
|
||||
];
|
||||
|
||||
$offerDetail = $propertyService->findOffer($requestParams);
|
||||
$offerDetail = fillOnUndefined($offerDetail, 'data');
|
||||
|
||||
app('translator')->setLocale($offerDetail["language"]);
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$mailParams['to'] = [];
|
||||
$mailParams['to'] = $offerDetail['email'];
|
||||
|
||||
$mailParams['bcc'] = [];
|
||||
$mailParams['bcc'][] = Config::get('app.logMailAddress');
|
||||
|
||||
|
||||
$mailParams['property_name'] = $offerDetail['property']['name'];
|
||||
$mailParams['url'] = Config::get('app.client_server').'/offer/'.$offerDetail['offer_code'];
|
||||
|
||||
$mailParams['logo'] = Config::get('app.webUrl').'/assets/img/logo/mini-logo.png';
|
||||
if(isset($offerDetail['property_brand']['logoUrl'])) {
|
||||
$mailParams['logo'] = $offerDetail['property_brand']['logoUrl'];
|
||||
}
|
||||
|
||||
$description = [];
|
||||
$description[] = __('api-mailing-offer_mail-description', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]);
|
||||
|
||||
$description = implode('<br><br>', $description);
|
||||
|
||||
/*echo view('emails.offerMail', compact('mailParams', 'description'));
|
||||
die();*/
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork - ' . $mailParams['property_name'])
|
||||
->view('emails.offerMail', compact('mailParams', 'description'))
|
||||
->to($mailParams['to'])
|
||||
->bcc($mailParams['bcc'])
|
||||
->subject(__('api-mailing-offer_mail-title', ['propertyName' => $offerDetail['property']['name'], 'code' => $offerDetail['ticket_code']]))
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
100
app/Core/Mail/PropertyProductOfferMail.php
Normal file
100
app/Core/Mail/PropertyProductOfferMail.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use App\Models\PropertyProductOffer;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class PropertyProductOfferMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
|
||||
|
||||
$propertyProductOffer = PropertyProductOffer::where('offer_key', $params['offerKey'])->first();
|
||||
$propertyProductOffer = $propertyProductOffer ? $propertyProductOffer->toArray() : null;
|
||||
|
||||
if (!$propertyProductOffer) {
|
||||
throw new ApiErrorException('The offer was not found');
|
||||
}
|
||||
|
||||
|
||||
$mailData = [
|
||||
'to' => [
|
||||
'name' => $propertyProductOffer['executive_name'],
|
||||
'email' => $propertyProductOffer['executive_email'],
|
||||
],
|
||||
'bcc' => ['sales@extranetwork.com']
|
||||
|
||||
];
|
||||
|
||||
$mailData['cc'] = [];
|
||||
if (isset($propertyProductOffer['account_manager_email'])) {
|
||||
$mailData['cc'][] = $propertyProductOffer['account_manager_email'];
|
||||
}
|
||||
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$mailParams = [
|
||||
'property_name' => $propertyProductOffer['property_name'],
|
||||
'executive_name' => $propertyProductOffer['executive_name'],
|
||||
'executive_email' => $propertyProductOffer['executive_email'],
|
||||
'executive_phone' => $propertyProductOffer['executive_phone'],
|
||||
'offer_expire_date' => $propertyProductOffer['offerExpireTimeFormatted'],
|
||||
'logo' => 'https://www.extranetwork.com/assets/img/logo/mini-logo.png',
|
||||
'btnUrl' => config('app.url') . '/property-product-offer/' . $propertyProductOffer['offer_key']
|
||||
];
|
||||
|
||||
if ($propertyProductOffer['version'] == 'v2') {
|
||||
$mailParams['btnUrl'] = config('app.webUrl') . '/property-product-offer/' . $propertyProductOffer['offer_key'];
|
||||
}
|
||||
|
||||
/*echo view('emails.propertyProductOfferMail', compact('mailParams'));
|
||||
die();*/
|
||||
|
||||
$subjectMail = 'Extranetwork ' . $mailParams['property_name'] . ' Fiyat Teklifi';
|
||||
if (isset($propertyProductOffer['detailArray']['paket'])) {
|
||||
$subjectMail = 'Extranetwork ' . $mailParams['property_name'] . ' - ' . $propertyProductOffer['detailArray']['paket'] . ' Fiyat Teklifi';
|
||||
}
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.propertyProductOfferMail', compact('mailParams'))
|
||||
->to($mailData['to']['email'], $mailData['to']['name'])
|
||||
->cc($mailData['cc'])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($subjectMail)
|
||||
->with(['message' => $this]);
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
104
app/Core/Mail/TrialFirstMail.php
Normal file
104
app/Core/Mail/TrialFirstMail.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class TrialFirstMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$propertyService = App::make('App\Core\Service\PropertyService');
|
||||
|
||||
$propertySelectCriteria = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['propertyId']],
|
||||
|
||||
],
|
||||
'with' => ['userPropertyMapping.user'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$propertyData = $propertyService->select($propertySelectCriteria);
|
||||
|
||||
if($propertyData['status'] == 'success') {
|
||||
|
||||
|
||||
$userPropertyMappingCollect = collect($propertyData['data']['user_property_mapping']);
|
||||
$userPropertyMapping = $userPropertyMappingCollect->where('status',1)->where('user.status',1)->sortBy('id');
|
||||
$userPropertyMapping = $userPropertyMapping ? $userPropertyMapping->toArray() : [];
|
||||
|
||||
|
||||
$defaultUser = reset($userPropertyMapping);
|
||||
|
||||
$mailData['to'] = [
|
||||
'email' => $defaultUser['user']['email'],
|
||||
'nameSurname' => $defaultUser['user']['nameSurname'],
|
||||
];
|
||||
|
||||
$mailData['bcc'] = [];
|
||||
foreach ($userPropertyMapping as $user) {
|
||||
//$mailData['bcc'][] = $user['user']['email'];
|
||||
}
|
||||
$mailData['bcc'] = 'channel@extranetwork.com';//TODO: Delete
|
||||
|
||||
$mailParams= [
|
||||
'email' => $mailData['to']['email'],
|
||||
'nameSurname' => $mailData['to']['nameSurname'],
|
||||
'propertyName' => $propertyData['data']['name'],
|
||||
];
|
||||
|
||||
|
||||
$mailTitle = 'Rezervasyonlarını ikiye katlamaya hazır mısın? 🚀';
|
||||
//app('translator')->setLocale('en');
|
||||
|
||||
//echo view('emails.reminder.trialFirstMail', compact('mailParams')); die();
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.reminder.trialFirstMail', compact('mailParams'))
|
||||
->to($mailData['to']['email'], $mailData['to']['nameSurname'])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($mailTitle)
|
||||
->with(['message' => $this]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
104
app/Core/Mail/TrialSecondMail.php
Normal file
104
app/Core/Mail/TrialSecondMail.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class TrialSecondMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
|
||||
$params = $this->param;
|
||||
$mailSenderAddress = Config::get('app.mailSenderAddress');
|
||||
|
||||
$propertyService = App::make('App\Core\Service\PropertyService');
|
||||
|
||||
$propertySelectCriteria = [
|
||||
'criteria' => [
|
||||
['field' => 'id', 'condition' => '=', 'value' => $params['propertyId']],
|
||||
|
||||
],
|
||||
'with' => ['userPropertyMapping.user'],
|
||||
'firstRow' => true
|
||||
];
|
||||
|
||||
$propertyData = $propertyService->select($propertySelectCriteria);
|
||||
|
||||
if($propertyData['status'] == 'success') {
|
||||
|
||||
|
||||
$userPropertyMappingCollect = collect($propertyData['data']['user_property_mapping']);
|
||||
$userPropertyMapping = $userPropertyMappingCollect->where('status',1)->where('user.status',1)->sortBy('id');
|
||||
$userPropertyMapping = $userPropertyMapping ? $userPropertyMapping->toArray() : [];
|
||||
|
||||
|
||||
$defaultUser = reset($userPropertyMapping);
|
||||
|
||||
$mailData['to'] = [
|
||||
'email' => $defaultUser['user']['email'],
|
||||
'nameSurname' => $defaultUser['user']['nameSurname'],
|
||||
];
|
||||
|
||||
$mailData['bcc'] = [];
|
||||
foreach ($userPropertyMapping as $user) {
|
||||
//$mailData['bcc'][] = $user['user']['email'];
|
||||
}
|
||||
$mailData['bcc'] = 'channel@extranetwork.com';//TODO: Delete
|
||||
|
||||
$mailParams= [
|
||||
'email' => $mailData['to']['email'],
|
||||
'nameSurname' => $mailData['to']['nameSurname'],
|
||||
'propertyName' => $propertyData['data']['name'],
|
||||
];
|
||||
|
||||
|
||||
$mailTitle = 'Çok görünürlük, daha çok satış.😎';
|
||||
//app('translator')->setLocale('en');
|
||||
|
||||
//echo view('emails.reminder.trialSecondMail', compact('mailParams')); die();
|
||||
|
||||
return $this->from($mailSenderAddress, 'Extranetwork')
|
||||
->view('emails.reminder.trialSecondMail', compact('mailParams'))
|
||||
->to($mailData['to']['email'], $mailData['to']['nameSurname'])
|
||||
->bcc($mailData['bcc'])
|
||||
->subject($mailTitle)
|
||||
->with(['message' => $this]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
46
app/Core/Mail/UserCreateMail.php
Normal file
46
app/Core/Mail/UserCreateMail.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserCreateMail extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
|
||||
public function build()
|
||||
{
|
||||
try {
|
||||
|
||||
$params = $this->param;
|
||||
app('translator')->setLocale($params["language"]);
|
||||
return $this->view('emails.createUserMail', compact('params'))
|
||||
->to($params["email"], $params["name_surname"])
|
||||
->subject(__('api-mailing-new_user_subject'));
|
||||
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::error($message);
|
||||
return output(['status' => -1, 'message' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
48
app/Core/Mail/UserForgotPassword.php
Normal file
48
app/Core/Mail/UserForgotPassword.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserForgotPassword extends Mailable
|
||||
{
|
||||
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $tries = 5;
|
||||
public $timeout = 30;
|
||||
|
||||
protected $param;
|
||||
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
public function build ()
|
||||
{
|
||||
try
|
||||
{
|
||||
$params = $this->param;
|
||||
app('translator')->setLocale($params["language"]);
|
||||
return $this->view('emails.userForgotPassword', compact('params'))
|
||||
->to($params["email"], $params["name_surname"])
|
||||
->subject(__('api-mailing-user_forgot_password_subject'))
|
||||
->with(['message' => $this]);
|
||||
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$message = $e->getFile()." ".$e->getLine()." ".$e->getMessage();
|
||||
Log::error($message);
|
||||
return output( ['status' => -1, 'message' => $e->getMessage()] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
47
app/Core/Mail/WellcomeMail.php
Normal file
47
app/Core/Mail/WellcomeMail.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Core\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
use Illuminate\Support\Facades\Log ;
|
||||
|
||||
|
||||
|
||||
class WellcomeMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected $param;
|
||||
|
||||
public function __construct($param)
|
||||
{
|
||||
$this->param = $param;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
|
||||
$val = $this->param;
|
||||
Log::debug($val);
|
||||
return $this->view('emails.wellCome', compact('val'))
|
||||
->to('ygundogdu@rezervasyon.com', 'yadican')
|
||||
->bcc('ygundogdu@rezervasyon.com', 'Burhan YUMAK')
|
||||
->bcc('ygundogdu@rezervasyon.com', 'Operasyon')
|
||||
->subject("WellCome Mail");
|
||||
}
|
||||
}
|
||||
224
app/Core/Payment/BankOfGeorgia/BankOfGeorgia.php
Normal file
224
app/Core/Payment/BankOfGeorgia/BankOfGeorgia.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\BankOfGeorgia;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class BankOfGeorgia
|
||||
{
|
||||
|
||||
private $requestUrl;
|
||||
private $clientId;
|
||||
private $secretKey;
|
||||
private $accessToken;
|
||||
|
||||
public function __construct($paymentInitializeParam)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://ipay.ge/opay/api/v1';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://dev.ipay.ge/opay/api/v1/';
|
||||
}
|
||||
|
||||
|
||||
$this->clientId = $paymentInitializeParam['clientId'];
|
||||
$this->secretKey = $paymentInitializeParam['secretKey'];
|
||||
|
||||
$getAccessToken = $this->getAccessToken();
|
||||
$this->accessToken = $getAccessToken['status'] ? $getAccessToken['token'] : null;
|
||||
|
||||
}
|
||||
|
||||
private function makeRequest($method, $payloadData, $methodType = 'POST')
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
try {
|
||||
|
||||
$requestParams['headers']['Content-Type'] = 'application/json';
|
||||
$requestParams['headers']['Authorization'] = 'Bearer ' . $this->accessToken;
|
||||
$requestParams['body'] = json_encode($payloadData);
|
||||
|
||||
$result = $this->restClient->request($methodType, $this->requestUrl . '/' . $method, $requestParams);
|
||||
|
||||
$getResponseBody = $result->getBody()->getContents();
|
||||
$getResponseData = $getResponseBody ? json_decode($getResponseBody, 1) : [];
|
||||
|
||||
if (isset($getResponseData['error_code'])) {
|
||||
$response['message'] = $getResponseData['status_description'];
|
||||
$response['serviceResponse'] = $getResponseData;
|
||||
} else {
|
||||
$response = [
|
||||
'status' => true,
|
||||
'serviceResponse' => $getResponseData
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
} catch (ClientException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!$response['status']) {
|
||||
Log::error($method);
|
||||
Log::error($payloadData);
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
private function getAccessToken()
|
||||
{
|
||||
|
||||
$getTokenData = null;
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
try {
|
||||
|
||||
$requestParams['headers']['Authorization'] = 'Basic ' . base64_encode($this->clientId . ':' . $this->secretKey);
|
||||
$requestParams['headers']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
$requestParams['form_params']['grant_type'] = 'client_credentials';
|
||||
|
||||
$result = $this->restClient->request('POST', $this->requestUrl . '/oauth2/token', $requestParams);
|
||||
|
||||
$getResponseBody = $result->getBody()->getContents();
|
||||
$getResponseData = $getResponseBody ? json_decode($getResponseBody, 1) : [];
|
||||
|
||||
if (isset($getResponseData['error_code'])) {
|
||||
throw new ApiErrorException($getResponseData['error_message']);
|
||||
}
|
||||
|
||||
$response['status'] = true;
|
||||
$response['token'] = $getResponseData['access_token'];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function paymentInitialize($param)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$paymentInitializeParam = [
|
||||
'intent' => 'CAPTURE',
|
||||
'items' => [
|
||||
[
|
||||
'amount' => $param['amount'],
|
||||
'description' => $param['orderCode'],
|
||||
'quantity' => 1,
|
||||
'product_id' => $param['orderCode'],
|
||||
]
|
||||
],
|
||||
'locale' => 'en-US',
|
||||
'shop_order_id' => $param['orderId'],
|
||||
'redirect_url' => $param['paymentCheckUrl'],
|
||||
'capture_method' => 'AUTOMATIC',
|
||||
'purchase_units' => [
|
||||
[
|
||||
'amount' => [
|
||||
'currency_code' => $param['currencyCode'],
|
||||
'value' => $param['amount'],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$paymentInitialize = $this->makeRequest('checkout/orders', $paymentInitializeParam);
|
||||
|
||||
if (!$paymentInitialize['status']) {
|
||||
throw new ApiErrorException($paymentInitialize['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $paymentInitialize['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function checkoutOrderInfo($orderId)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$method = 'checkout/orders/' . $orderId;
|
||||
$payloadData = [];
|
||||
|
||||
$checkoutOrderInfoRequest = $this->makeRequest($method, $payloadData, 'GET');
|
||||
|
||||
if (!$checkoutOrderInfoRequest['status']) {
|
||||
throw new ApiErrorException($checkoutOrderInfoRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $checkoutOrderInfoRequest['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
if (isset($checkoutOrderInfoRequest['serviceResponse'])) {
|
||||
$response['serviceResponse'] = $checkoutOrderInfoRequest['serviceResponse'];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
239
app/Core/Payment/Esnekpos/Esnekpos.php
Normal file
239
app/Core/Payment/Esnekpos/Esnekpos.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Esnekpos;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use App\Exceptions\ApplicationError;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class Esnekpos
|
||||
{
|
||||
|
||||
private $requestUrl;
|
||||
|
||||
public function __construct($paymentInitializeParam)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://posservice.esnekpos.com';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://posservicetest.esnekpos.com';
|
||||
}
|
||||
|
||||
|
||||
$this->merchant = $paymentInitializeParam['merchant'];
|
||||
$this->merchantKey = $paymentInitializeParam['merchantKey'];
|
||||
$this->contactMail = $paymentInitializeParam['contactMail'];
|
||||
$this->ipAddress = isset($paymentInitializeParam['ipAddress']) ? $paymentInitializeParam['ipAddress'] : '185.137.215.118';
|
||||
|
||||
$this->currencyMapping = [
|
||||
'TRY' => 'TRY',
|
||||
'USD' => 'USD',
|
||||
'EUR' => 'EUR',
|
||||
'GBP' => 'GBP',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
private function makeRequest($method, $payloadData)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
try {
|
||||
|
||||
$requestParams['headers']['Content-Type'] = 'application/json';
|
||||
|
||||
$requestParams['body'] = json_encode($payloadData);
|
||||
|
||||
$result = $this->restClient->post($this->requestUrl . '/' . $method, $requestParams);
|
||||
|
||||
$getResponseBody = $result->getBody()->getContents();
|
||||
$getResponseData = $getResponseBody ? json_decode($getResponseBody, 1) : [];
|
||||
|
||||
if ($getResponseData['STATUS'] == 'SUCCESS') {
|
||||
$response = [
|
||||
'status' => true,
|
||||
'serviceResponse' => $getResponseData
|
||||
];
|
||||
} else {
|
||||
throw new Exception($getResponseData['RETURN_MESSAGE']);
|
||||
}
|
||||
|
||||
} catch (ClientException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
$response['message'] = $message;
|
||||
Log::debug($message);
|
||||
|
||||
} catch (ServerException | Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
|
||||
}
|
||||
|
||||
if (!$response['status']) {
|
||||
Log::error($method);
|
||||
Log::error($payloadData);
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
if (isset($getResponseData)) {
|
||||
$response['serviceResponse'] = $getResponseData;
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function generateHashKey($total, $installment, $currency_code, $invoice_id)
|
||||
{
|
||||
|
||||
$data = $total . '|' . $installment . '|' . $currency_code . '|' . $this->merchantKey . '|' . $invoice_id;
|
||||
|
||||
$iv = substr(sha1(mt_rand()), 0, 16);
|
||||
$password = sha1($this->appSecret);
|
||||
|
||||
$salt = substr(sha1(mt_rand()), 0, 4);
|
||||
$saltWithPassword = hash('sha256', $password . $salt);
|
||||
|
||||
$encrypted = openssl_encrypt("$data", 'aes-256-cbc', "$saltWithPassword", null, $iv);
|
||||
|
||||
$msg_encrypted_bundle = "$iv:$salt:$encrypted";
|
||||
$msg_encrypted_bundle = str_replace('/', '__', $msg_encrypted_bundle);
|
||||
|
||||
return $msg_encrypted_bundle;
|
||||
}
|
||||
|
||||
public function EYV3DPay($param)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$param['creditCard']['installment'] = $param['creditCard']['installment'] == 0 ? 1 : $param['creditCard']['installment'];
|
||||
|
||||
$items = [];
|
||||
$items[] = [
|
||||
'PRODUCT_ID' => $param['orderCode'],
|
||||
'PRODUCT_NAME' => 'Booking',
|
||||
'PRODUCT_CATEGORY' => 'Booking',
|
||||
'PRODUCT_DESCRIPTION' => 'Booking',
|
||||
'PRODUCT_AMOUNT' => $param['amount']
|
||||
];
|
||||
|
||||
$method = 'api/pay/EYV3DPay';
|
||||
$payloadData = [
|
||||
'Config' => [
|
||||
'MERCHANT' => $this->merchant,
|
||||
'MERCHANT_KEY' => $this->merchantKey,
|
||||
'BACK_URL' => $param['paymentCheckUrl'],
|
||||
'PRICES_CURRENCY' => isset($this->currencyMapping[$param['currencyCode']]) ? $this->currencyMapping[$param['currencyCode']] : $param['currencyCode'],
|
||||
'ORDER_REF_NUMBER' => $param['orderId'],
|
||||
'ORDER_AMOUNT' => $param['amount'],
|
||||
],
|
||||
'CreditCard' => [
|
||||
'CC_NUMBER' => $param['creditCard']['number'],
|
||||
'EXP_MONTH' => $param['creditCard']['expiryMonth'],
|
||||
'EXP_YEAR' => $param['creditCard']['expiryYear'],
|
||||
'CC_CVV' => $param['creditCard']['cvv'],
|
||||
'CC_OWNER' => $param['creditCard']['holderName'],
|
||||
'INSTALLMENT_NUMBER' => $param['creditCard']['installment'],
|
||||
],
|
||||
'Customer' => [
|
||||
'FIRST_NAME' => $param['orderId'],
|
||||
'LAST_NAME' => $param['orderId'],
|
||||
'MAIL' => $this->contactMail,
|
||||
'PHONE' => '5555555555',
|
||||
'CITY' => $param['orderId'],
|
||||
'STATE' => $param['orderId'],
|
||||
'ADDRESS' => $param['orderId'],
|
||||
'CLIENT_IP' => $this->ipAddress,
|
||||
],
|
||||
'Product' => $items
|
||||
];
|
||||
|
||||
$checkRequest = $this->makeRequest($method, $payloadData);
|
||||
|
||||
if (!$checkRequest['status']) {
|
||||
throw new ApiErrorException($checkRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $checkRequest['serviceResponse']
|
||||
];
|
||||
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function checkPaymentStatus($orderId)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$method = 'api/services/ProcessQuery';
|
||||
$payloadData = [
|
||||
'MERCHANT' => $this->merchant,
|
||||
'MERCHANT_KEY' => $this->merchantKey,
|
||||
'ORDER_REF_NUMBER' => $orderId,
|
||||
];
|
||||
|
||||
$checkStatusRequest = $this->makeRequest($method, $payloadData);
|
||||
|
||||
if (!$checkStatusRequest['status']) {
|
||||
throw new ApiErrorException($checkStatusRequest['message']);
|
||||
}
|
||||
|
||||
if ($checkStatusRequest['serviceResponse']['STATUS'] != 'SUCCESS') {
|
||||
throw new ApiErrorException($checkStatusRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $checkStatusRequest['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
if (isset($checkStatusRequest['serviceResponse'])) {
|
||||
$response['serviceResponse'] = $checkStatusRequest['serviceResponse'];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
254
app/Core/Payment/HalkOde/HalkOde.php
Normal file
254
app/Core/Payment/HalkOde/HalkOde.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\HalkOde;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use App\Exceptions\ApplicationError;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class HalkOde
|
||||
{
|
||||
|
||||
private $requestUrl;
|
||||
|
||||
public function __construct($paymentInitializeParam)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://app.halkode.com.tr/ccpayment';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://test.halkode.com.tr/ccpayment';
|
||||
}
|
||||
|
||||
|
||||
$this->merchantId = $paymentInitializeParam['merchantId'];
|
||||
$this->merchantKey = $paymentInitializeParam['merchantKey'];
|
||||
$this->appKey = $paymentInitializeParam['appKey'];
|
||||
$this->appSecret = $paymentInitializeParam['appSecret'];
|
||||
|
||||
$this->getAccessToken = $this->getAccessToken();
|
||||
|
||||
}
|
||||
|
||||
private function makeRequest($method, $payloadData)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
try {
|
||||
|
||||
$requestParams['headers']['Content-Type'] = 'application/json';
|
||||
if ($method != 'api/token') {
|
||||
$requestParams['headers']['Authorization'] = 'Bearer ' . $this->getAccessToken;
|
||||
}
|
||||
|
||||
|
||||
$requestParams['body'] = json_encode($payloadData);
|
||||
|
||||
$result = $this->restClient->post($this->requestUrl . '/' . $method, $requestParams);
|
||||
|
||||
$getResponseBody = $result->getBody()->getContents();
|
||||
$getResponseData = $getResponseBody ? json_decode($getResponseBody, 1) : [];
|
||||
|
||||
if ($getResponseData['status_code'] == 100) {
|
||||
$response = [
|
||||
'status' => true,
|
||||
'serviceResponse' => $getResponseData
|
||||
];
|
||||
} else {
|
||||
$response['message'] = $getResponseData['status_description'];
|
||||
$response['serviceResponse'] = $getResponseData;
|
||||
}
|
||||
|
||||
|
||||
} catch (ClientException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!$response['status']) {
|
||||
Log::error($method);
|
||||
Log::error($payloadData);
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function getAccessToken()
|
||||
{
|
||||
|
||||
$method = 'api/token';
|
||||
$payloadData = [
|
||||
'app_id' => $this->appKey,
|
||||
'app_secret' => $this->appSecret,
|
||||
];
|
||||
|
||||
$getTokenDataRequest = $this->makeRequest($method, $payloadData);
|
||||
|
||||
if ($getTokenDataRequest['status']) {
|
||||
$getTokenData = $getTokenDataRequest['serviceResponse']['data']['token'];
|
||||
}
|
||||
|
||||
return $getTokenData;
|
||||
}
|
||||
|
||||
public function generateHashKey($total, $installment, $currency_code, $invoice_id)
|
||||
{
|
||||
|
||||
$data = $total . '|' . $installment . '|' . $currency_code . '|' . $this->merchantKey . '|' . $invoice_id;
|
||||
|
||||
$iv = substr(sha1(mt_rand()), 0, 16);
|
||||
$password = sha1($this->appSecret);
|
||||
|
||||
$salt = substr(sha1(mt_rand()), 0, 4);
|
||||
$saltWithPassword = hash('sha256', $password . $salt);
|
||||
|
||||
$encrypted = openssl_encrypt("$data", 'aes-256-cbc', "$saltWithPassword", null, $iv);
|
||||
|
||||
$msg_encrypted_bundle = "$iv:$salt:$encrypted";
|
||||
$msg_encrypted_bundle = str_replace('/', '__', $msg_encrypted_bundle);
|
||||
|
||||
return $msg_encrypted_bundle;
|
||||
}
|
||||
|
||||
public function generateRefundHashKey($invoice_id, $merchant_key, $app_secret)
|
||||
{
|
||||
$data = $invoice_id . '|' . $merchant_key;
|
||||
$iv = substr(sha1(mt_rand()), 0, 16);
|
||||
$password = sha1($app_secret);
|
||||
$salt = substr(sha1(mt_rand()), 0, 4);
|
||||
$saltWithPassword = hash('sha256', $password . $salt);
|
||||
$encrypted = openssl_encrypt(
|
||||
$data, 'aes-256-cbc', "$saltWithPassword", null, $iv
|
||||
);
|
||||
$msg_encrypted_bundle = "$iv:$salt:$encrypted";
|
||||
$hash_key = str_replace('/', '__', $msg_encrypted_bundle);
|
||||
return $hash_key;
|
||||
}
|
||||
|
||||
public function paySmart3D($param)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$param['creditCard']['installment'] = $param['creditCard']['installment'] == 0 ? 1 : $param['creditCard']['installment'];
|
||||
|
||||
$generateHashKey = $this->generateHashKey($param['amount'], $param['creditCard']['installment'], $param['currencyCode'], $param['orderId']);
|
||||
|
||||
$items = [];
|
||||
$items[] = [
|
||||
'name' => 'Booking',
|
||||
'price' => $param['amount'],
|
||||
'quantity' => 1,
|
||||
'description' => $param['orderCode'],
|
||||
];
|
||||
|
||||
$payment3dFormData['gateway'] = $this->requestUrl . '/api/paySmart3D';
|
||||
|
||||
$payment3dFormData['inputs'] = [
|
||||
'currency_code' => $param['currencyCode'],
|
||||
'installments_number' => $param['creditCard']['installment'],
|
||||
'invoice_id' => $param['orderId'],
|
||||
'invoice_description' => $param['orderCode'],
|
||||
'total' => $param['amount'],
|
||||
'merchant_key' => $this->merchantKey,
|
||||
'items' => json_encode($items),
|
||||
//'name' => $param['name'],
|
||||
//'surname' => $param['surname'],
|
||||
'hash_key' => $generateHashKey,
|
||||
'return_url' => $param['paymentCheckUrl'],
|
||||
'cancel_url' => $param['paymentCheckUrl'],
|
||||
'cc_holder_name' => $param['creditCard']['holderName'],
|
||||
'cc_no' => $param['creditCard']['number'],
|
||||
'expiry_month' => $param['creditCard']['expiryMonth'],
|
||||
'expiry_year' => $param['creditCard']['expiryYear'],
|
||||
'cvv' => $param['creditCard']['cvv'],
|
||||
'transaction_type' => 'Auth',
|
||||
'is_comission_from_user' => '2',
|
||||
'response_method' => 'GET',
|
||||
];
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $payment3dFormData
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function checkPaymentStatus($orderId)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$generateHashKey = $this->generateRefundHashKey($orderId, $this->merchantKey, $this->appSecret);
|
||||
|
||||
$method = 'api/checkstatus';
|
||||
$payloadData = [
|
||||
'invoice_id' => $orderId,
|
||||
'merchant_key' => $this->merchantKey,
|
||||
'include_pending_status' => true,
|
||||
'hash_key' => $generateHashKey
|
||||
];
|
||||
|
||||
$checkstatusRequest = $this->makeRequest($method, $payloadData);
|
||||
|
||||
if (!$checkstatusRequest['status']) {
|
||||
throw new ApiErrorException($checkstatusRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $checkstatusRequest['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
if (isset($checkstatusRequest['serviceResponse'])) {
|
||||
$response['serviceResponse'] = $checkstatusRequest['serviceResponse'];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
241
app/Core/Payment/KuveytTurk/KuveytTurk.php
Normal file
241
app/Core/Payment/KuveytTurk/KuveytTurk.php
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\KuveytTurk;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class KuveytTurk
|
||||
{
|
||||
|
||||
private $restClient;
|
||||
private $customerId;
|
||||
private $merchantId;
|
||||
private $userName;
|
||||
private $password;
|
||||
private $currencyCodeMapping;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
$paymentInitializeParam
|
||||
)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://boa.kuveytturk.com.tr/sanalposservice/Home';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://boatest.kuveytturk.com.tr/boa.virtualpos.services/Home';
|
||||
}
|
||||
|
||||
$this->customerId = $paymentInitializeParam['customerId'];
|
||||
$this->merchantId = $paymentInitializeParam['merchantId'];
|
||||
$this->userName = $paymentInitializeParam['userName'];
|
||||
$this->password = $paymentInitializeParam['password'];
|
||||
|
||||
$this->currencyCodeMapping = [
|
||||
'TRY' => '0949',
|
||||
'USD' => '0840',
|
||||
'EUR' => '0978',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
protected function post($param)
|
||||
{
|
||||
$getResponse = [];
|
||||
$param['logDebug'] = fillOnUndefined($param, 'logDebug', false);
|
||||
try {
|
||||
|
||||
$paymentRequest = $this->restClient->post($this->requestUrl . '/' . $param['method'], [
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/xml; charset=UTF8',
|
||||
],
|
||||
'body' => $param['payload']
|
||||
]);
|
||||
|
||||
$getResponseBody = $paymentRequest->getBody();
|
||||
$getResponseXmlBase = $getResponseBody->getContents();
|
||||
|
||||
if (!$getResponseXmlBase) {
|
||||
throw new ApiErrorException('Payment Initialize not processing.');
|
||||
} else {
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $getResponseXmlBase
|
||||
];
|
||||
}
|
||||
|
||||
if ($param['logDebug']) {
|
||||
Log::debug(json_encode($param['param']));
|
||||
Log::debug($param['param']);
|
||||
Log::debug($getResponse);
|
||||
}
|
||||
|
||||
} catch (ApiErrorException | Exception | ClientException | ServerException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function threeDModelPayGate($param = [])
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$hashData = null;
|
||||
$param['amount'] = (int)(floatval($param['amount']) * 100);
|
||||
$hashedPassword = base64_encode(sha1($this->password, "ISO-8859-9"));
|
||||
$hashData = base64_encode(sha1($this->merchantId . $param['orderId'] . $param['amount'] . $param['paymentCheckUrl'] . $param['paymentCheckUrl'] . $this->userName . $hashedPassword, "ISO-8859-9"));
|
||||
|
||||
$requestParam['method'] = 'ThreeDModelPayGate';
|
||||
$requestPayload = new \SimpleXMLElement('<KuveytTurkVPosMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></KuveytTurkVPosMessage>');
|
||||
|
||||
$currencyCodeBank = isset($this->currencyCodeMapping[$param['currencyCode']]) ? $this->currencyCodeMapping[$param['currencyCode']] : '0949';
|
||||
|
||||
$requestPayload->addChild('APIVersion', '1.0.0');
|
||||
$requestPayload->addChild('OkUrl', $param['paymentCheckUrl']);
|
||||
$requestPayload->addChild('FailUrl', $param['paymentCheckUrl']);
|
||||
$requestPayload->addChild('HashData', $hashData);
|
||||
$requestPayload->addChild('MerchantId', $this->merchantId);
|
||||
$requestPayload->addChild('CustomerId', $this->customerId);
|
||||
$requestPayload->addChild('UserName', $this->userName);
|
||||
$requestPayload->addChild('CardNumber', $param['creditCard']['number']);
|
||||
$requestPayload->addChild('CardExpireDateYear', mb_substr($param['creditCard']['expiryYear'], 2, 2));
|
||||
$requestPayload->addChild('CardExpireDateMonth', $param['creditCard']['expiryMonth']);
|
||||
$requestPayload->addChild('CardCVV2', $param['creditCard']['cvv']);
|
||||
$requestPayload->addChild('CardHolderName', $param['creditCard']['holderName']);
|
||||
//$requestPayload->addChild('CardType', null);
|
||||
$requestPayload->addChild('BatchID', 0);
|
||||
$requestPayload->addChild('TransactionType', 'Sale');
|
||||
$requestPayload->addChild('InstallmentCount', $param['creditCard']['installment']);
|
||||
$requestPayload->addChild('Amount', $param['amount']);
|
||||
$requestPayload->addChild('DisplayAmount', $param['amount']);
|
||||
$requestPayload->addChild('CurrencyCode', $currencyCodeBank);
|
||||
$requestPayload->addChild('MerchantOrderId', $param['orderId']);
|
||||
$requestPayload->addChild('TransactionSecurity', 3);
|
||||
|
||||
$requestParam['payload'] = $requestPayload->asXML();
|
||||
|
||||
$paymentRequest = $this->post($requestParam);
|
||||
|
||||
if (!$paymentRequest['status']) {
|
||||
throw new ApiErrorException($paymentRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $paymentRequest['data']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException | Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
|
||||
if (isset($getResponseData)) {
|
||||
$response['serviceResponse'] = $paymentRequest;
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function checkPaymentStatus($paymentCode, $param = [])
|
||||
{
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
$requestContent = null;
|
||||
$paymentRequest = [];
|
||||
|
||||
try {
|
||||
|
||||
$requestContent = urldecode($param["AuthenticationResponse"]);
|
||||
$requestContent = json_decode(json_encode(simplexml_load_string($requestContent)), 1);
|
||||
|
||||
|
||||
if ($requestContent['ResponseCode'] != "00") {
|
||||
$errorMessage = $requestContent['ResponseCode'] . ': ' . $requestContent['ResponseMessage'];
|
||||
$paymentRequest['serviceResponse'] = $requestContent;
|
||||
throw new ApiErrorException($errorMessage);
|
||||
}
|
||||
|
||||
$paymentCheckParam = [
|
||||
'merchantOrderId' => isset($requestContent['VPosMessage']['MerchantOrderId']) ? $requestContent['VPosMessage']['MerchantOrderId'] : null,
|
||||
'amount' => isset($requestContent['VPosMessage']['Amount']) ? $requestContent['VPosMessage']['Amount'] : null,
|
||||
'md' => isset($requestContent['MD']) ? $requestContent['MD'] : null,
|
||||
];
|
||||
|
||||
$hashData = null;
|
||||
//$param['amount'] = (int)(floatval($param['amount']) * 100);
|
||||
$hashedPassword = base64_encode(sha1($this->password, "ISO-8859-9"));
|
||||
$hashData = base64_encode(sha1($this->merchantId . $paymentCheckParam['merchantOrderId'] . $paymentCheckParam['amount'] . $this->userName . $hashedPassword, "ISO-8859-9"));
|
||||
|
||||
|
||||
$requestParam['method'] = 'ThreeDModelProvisionGate';
|
||||
$requestPayload = new \SimpleXMLElement('<KuveytTurkVPosMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></KuveytTurkVPosMessage>');
|
||||
|
||||
$requestPayload->addChild('APIVersion', '1.0.0');
|
||||
$requestPayload->addChild('HashData', $hashData);
|
||||
$requestPayload->addChild('MerchantId', $this->merchantId);
|
||||
$requestPayload->addChild('CustomerId', $this->customerId);
|
||||
$requestPayload->addChild('UserName', $this->userName);
|
||||
$requestPayload->addChild('TransactionType', 'Sale');
|
||||
$requestPayload->addChild('InstallmentCount', 1);
|
||||
$requestPayload->addChild('CurrencyCode', '0949');
|
||||
$requestPayload->addChild('Amount', $paymentCheckParam['amount']);
|
||||
$requestPayload->addChild('MerchantOrderId', $paymentCheckParam['merchantOrderId']);
|
||||
$requestPayload->addChild('TransactionSecurity', 3);
|
||||
|
||||
$kuveytTurkVPosAdditionalData = $requestPayload->addChild('KuveytTurkVPosAdditionalData');
|
||||
$additionalData = $kuveytTurkVPosAdditionalData->addChild('AdditionalData');
|
||||
$additionalData->addChild('Key', 'MD');
|
||||
$additionalData->addChild('Data', $paymentCheckParam['md']);
|
||||
|
||||
$requestParam['payload'] = $requestPayload->asXML();
|
||||
|
||||
$paymentRequest = $this->post($requestParam);
|
||||
|
||||
if (!$paymentRequest['status']) {
|
||||
throw new ApiErrorException($paymentRequest['message']);
|
||||
}
|
||||
|
||||
$requestContent = simplexml_load_string($paymentRequest['data']);
|
||||
$requestContent = json_decode(json_encode($requestContent), 1);
|
||||
|
||||
$paymentRequest['serviceResponse'] = $requestContent;
|
||||
|
||||
if ($requestContent['ResponseCode'] != "00") {
|
||||
$errorMessage = $requestContent['ResponseCode'] . ': ' . $requestContent['ResponseMessage'];
|
||||
throw new ApiErrorException($errorMessage);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $requestContent
|
||||
];
|
||||
|
||||
} catch (ApiErrorException | Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
|
||||
if (isset($paymentRequest['serviceResponse'])) {
|
||||
$response['serviceResponse'] = $paymentRequest['serviceResponse'];
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
176
app/Core/Payment/Moka/Moka.php
Normal file
176
app/Core/Payment/Moka/Moka.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Moka;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class Moka
|
||||
{
|
||||
|
||||
private $restClient;
|
||||
private $userName;
|
||||
private $password;
|
||||
private $dealerCode;
|
||||
|
||||
public function __construct
|
||||
(
|
||||
$paymentInitializeParam
|
||||
)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://service.moka.com';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://service.refmoka.com';
|
||||
}
|
||||
|
||||
$this->userName = $paymentInitializeParam['userName'];
|
||||
$this->password = $paymentInitializeParam['password'];
|
||||
$this->dealerCode = $paymentInitializeParam['dealerCode'];
|
||||
|
||||
}
|
||||
|
||||
private function errorCodes($code)
|
||||
{
|
||||
$codes = [
|
||||
md5('PaymentDealer.CheckPaymentDealerAuthentication.InvalidRequest') => 'Hatalı hash bilgisi',
|
||||
md5('PaymentDealer.CheckPaymentDealerAuthentication.InvalidAccount') => 'Böyle bir bayi bulunamadı',
|
||||
md5('PaymentDealer.CheckPaymentDealerAuthentication.VirtualPosNotFound') => 'Bu bayi için sanal pos tanımı yapılmamış',
|
||||
md5('PaymentDealer.RequiredFields.AmountRequired') => 'Tutar girilmemiş',
|
||||
md5('PaymentDealer.DoCapture.DealerNotAuthorized') => 'Ön provizyonu provizyona çevirmek için yetkiniz yok',
|
||||
md5('PaymentDealer.DoDirectPayment3dRequest.CardTokenNotFound') => 'Tanımlı CardToken bulunamadı',
|
||||
md5('PaymentDealer.CheckCardInfo.InvalidCardInfo') => 'Geçersiz Kart Bilgisi',
|
||||
md5('PaymentDealer.DoDirectPayment3dRequest.VirtualPosNotAvailable') => 'Bu kredi kartı için ödeme desteklenmemektedir, lütfen farklı bir kart deneyiniz',
|
||||
md5('PaymentDealer.CheckDealerPaymentLimits.DailyDealerLimitExceeded') => 'Bu kredi kartı için günlük kullanım limiti dolmuştur, lütfen farklı bir kart deneyiniz',
|
||||
md5('PaymentDealer.DoDirectPayment3dRequest.ThisInstallmentNumberNotAvailableForDealer') => 'Bu taksit sayısı kullanılamaz',
|
||||
md5('EX') => 'Beklenmeyen bir hata oluştu'
|
||||
];
|
||||
|
||||
return fillOnUndefined($codes, md5($code), 'Bilinmeyen bir hata oluştu');
|
||||
}
|
||||
|
||||
private function mokaServiceResponse($getResponse, $param)
|
||||
{
|
||||
$response = ['status' => false, 'message' => '', 'error' => '', 'data' => []];
|
||||
|
||||
if ($getResponse['ResultCode'] != 'Success') {
|
||||
$response['message'] = $this->errorCodes($getResponse['ResultCode']);
|
||||
//Log::error($getResponse);
|
||||
} else {
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $getResponse['Data']
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
protected function post($param)
|
||||
{
|
||||
$getResponse = [];
|
||||
$param['logDebug'] = fillOnUndefined($param, 'logDebug', false);
|
||||
try {
|
||||
|
||||
$res = $this->restClient->post($this->requestUrl. $param['method'], [
|
||||
'verify' => false,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'body' => json_encode($param['param'])
|
||||
]);
|
||||
|
||||
$getResponseBody = $res->getBody();
|
||||
$getResponse = json_decode($getResponseBody, true);
|
||||
|
||||
if ($param['logDebug']) {
|
||||
Log::debug(json_encode($param['param']));
|
||||
Log::debug($param['param']);
|
||||
Log::debug($getResponse);
|
||||
}
|
||||
|
||||
$getResponse = $this->mokaServiceResponse($getResponse, $param);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getMessage();
|
||||
Log::error($message);
|
||||
}
|
||||
return $getResponse;
|
||||
|
||||
}
|
||||
|
||||
public function paymentDealerAuthentication()
|
||||
{
|
||||
return [
|
||||
'DealerCode' => $this->dealerCode,
|
||||
'Username' => $this->userName,
|
||||
'Password' => $this->password,
|
||||
'CheckKey' => hash('sha256', $this->dealerCode . 'MK' . $this->userName . 'PD' . $this->password)
|
||||
];
|
||||
}
|
||||
|
||||
public function DoDirectPaymentThreeD($param = [])
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$doDirectPaymentThreeD['method'] = '/PaymentDealer/DoDirectPaymentThreeD';
|
||||
$doDirectPaymentThreeD['param']['PaymentDealerAuthentication'] = $this->paymentDealerAuthentication();
|
||||
$doDirectPaymentThreeD['param']['PaymentDealerRequest'] = [
|
||||
'CardHolderFullName' => fillOnUndefined($param, 'CardHolderFullName'),
|
||||
'CardNumber' => fillOnUndefined($param, 'CardNumber', ''),
|
||||
'ExpMonth' => fillOnUndefined($param, 'ExpMonth'),//12
|
||||
'ExpYear' => fillOnUndefined($param, 'ExpYear'),//2022
|
||||
'CvcNumber' => fillOnUndefined($param, 'CvcNumber'),
|
||||
'CardToken' => fillOnUndefined($param, 'CardToken'),
|
||||
'Amount' => fillOnUndefined($param, 'Amount'),//10.50
|
||||
'Currency' => fillOnUndefined($param, 'Currency', 'TL'),
|
||||
'InstallmentNumber' => fillOnUndefined($param, 'InstallmentNumber', 1),
|
||||
'ClientIP' => fillOnUndefined($param, 'ClientIP', Request::ip()),
|
||||
'OtherTrxCode' => fillOnUndefined($param, 'OtherTrxCode', ''),
|
||||
'IsPreAuth' => fillOnUndefined($param, 'IsPreAuth', 1),
|
||||
'Software' => fillOnUndefined($param, 'Software', ''),
|
||||
'Description' => fillOnUndefined($param, 'Description', ''),
|
||||
'RedirectUrl' => fillOnUndefined($param, 'RedirectUrl'),
|
||||
];
|
||||
|
||||
$response = $this->post($doDirectPaymentThreeD);
|
||||
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getPaymentDetail($param = [])
|
||||
{
|
||||
try {
|
||||
|
||||
$getPaymentList['method'] = '/PaymentDealer/GetDealerPaymentTrxDetailList';
|
||||
$getPaymentList['param']['PaymentDealerAuthentication'] = $this->paymentDealerAuthentication();
|
||||
$getPaymentList['param']['PaymentDealerRequest'] = [
|
||||
'PaymentId' => fillOnUndefined($param, 'PaymentId', ''),
|
||||
'OtherTrxCode' => fillOnUndefined($param, 'OtherTrxCode', ''),
|
||||
];
|
||||
|
||||
$response = $this->post($getPaymentList);
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
170
app/Core/Payment/Payriff/Payriff.php
Normal file
170
app/Core/Payment/Payriff/Payriff.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Payriff;
|
||||
|
||||
use App\Exceptions\ApiErrorException;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Log;
|
||||
use Exception;
|
||||
|
||||
class Payriff
|
||||
{
|
||||
|
||||
private $requestUrl;
|
||||
private $secretKey;
|
||||
|
||||
public function __construct($paymentInitializeParam)
|
||||
{
|
||||
$this->restClient = new Client();
|
||||
|
||||
$this->requestUrl = 'https://api.payriff.com/api/v3';
|
||||
if ($paymentInitializeParam['env'] == 'test') {
|
||||
$this->requestUrl = 'https://api.payriff.com/api/v3';
|
||||
}
|
||||
|
||||
|
||||
$this->secretKey = $paymentInitializeParam['secretKey'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function makeRequest($method, $payloadData, $methodType = 'POST')
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
|
||||
try {
|
||||
|
||||
$requestParams['headers']['Content-Type'] = 'application/json';
|
||||
$requestParams['headers']['Authorization'] = $this->secretKey;
|
||||
$requestParams['body'] = json_encode($payloadData);
|
||||
|
||||
|
||||
$result = $this->restClient->request($methodType, $this->requestUrl . '/' . $method, $requestParams);
|
||||
|
||||
$getResponseBody = $result->getBody()->getContents();
|
||||
$getResponseData = $getResponseBody ? json_decode($getResponseBody, 1) : [];
|
||||
|
||||
|
||||
if ($getResponseData['code'] == '00000') {
|
||||
$response = [
|
||||
'status' => true,
|
||||
'serviceResponse' => $getResponseData
|
||||
];
|
||||
} else {
|
||||
$response['message'] = 'Redirect url not found.';
|
||||
$response['serviceResponse'] = $getResponseData;
|
||||
}
|
||||
|
||||
|
||||
} catch (ClientException $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage();
|
||||
Log::debug($message);
|
||||
$response['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!$response['status']) {
|
||||
Log::error($method);
|
||||
Log::error($payloadData);
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function paymentInitialize($param)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$paymentInitializeParam = [
|
||||
'amount' => $param['amount'],
|
||||
'language' => 'EN',
|
||||
'currency' => $param['currencyCode'],
|
||||
'description' => $param['orderId'],
|
||||
'callbackUrl' => $param['paymentCheckUrl'],
|
||||
'cardSave' => false,
|
||||
'operation' => 'PURCHASE',
|
||||
'metadata' => [
|
||||
'orderId' => $param['orderId'],
|
||||
]
|
||||
];
|
||||
|
||||
$paymentInitialize = $this->makeRequest('orders', $paymentInitializeParam);
|
||||
|
||||
if (!$paymentInitialize['status']) {
|
||||
throw new ApiErrorException($paymentInitialize['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $paymentInitialize['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function orderInformation($orderId)
|
||||
{
|
||||
|
||||
$response = ['status' => false, 'message' => ''];
|
||||
try {
|
||||
|
||||
$method = 'orders/' . $orderId;
|
||||
$payloadData = [];
|
||||
|
||||
$orderInformationRequest = $this->makeRequest($method, $payloadData, 'GET');
|
||||
|
||||
if (!$orderInformationRequest['status']) {
|
||||
throw new ApiErrorException($orderInformationRequest['message']);
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
'data' => $orderInformationRequest['serviceResponse']
|
||||
];
|
||||
|
||||
} catch (ApiErrorException $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
} catch (Exception $e) {
|
||||
$response = ['status' => false, 'message' => $e->getMessage()];
|
||||
Log::error($response);
|
||||
}
|
||||
|
||||
if (isset($orderInformationRequest['serviceResponse'])) {
|
||||
$response['serviceResponse'] = $orderInformationRequest['serviceResponse'];
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
701
app/Core/Payment/Pos/AkPos.php
Normal file
701
app/Core/Payment/Pos/AkPos.php
Normal file
@@ -0,0 +1,701 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GPBMetadata\Google\Api\Log;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class AkPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'AkPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $mbrId = 5;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getRandomNumberBase16()
|
||||
{
|
||||
$n = 128;
|
||||
|
||||
$characters = '0123456789ABCDEF';
|
||||
$randomString = '';
|
||||
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$index = rand(0, strlen($characters) - 1);
|
||||
$randomString .= $characters[$index];
|
||||
}
|
||||
|
||||
return strtoupper($randomString);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hashItems = [];
|
||||
|
||||
$hashItems[] = mb_strtoupper($this->account->model);
|
||||
$hashItems[] = $this->txnCode;
|
||||
$hashItems[] = $this->account->merchant_safe_id;
|
||||
$hashItems[] = $this->account->terminal_safe_id;
|
||||
$hashItems[] = $this->order->id;
|
||||
$hashItems[] = mb_strtoupper($this->order->lang);
|
||||
$hashItems[] = $this->order->amount;
|
||||
//$hashItems[] = $this->order->ccbRewardAmount;
|
||||
//$hashItems[] = $this->order->pcbRewardAmount;
|
||||
//$hashItems[] = $this->order->xcbRewardAmount;
|
||||
$hashItems[] = $this->order->currency;
|
||||
$hashItems[] = $this->order->installment;
|
||||
$hashItems[] = $this->order->success_url;
|
||||
$hashItems[] = $this->order->fail_url;
|
||||
//$hashItems[] = $this->order->emailAddress;
|
||||
//$hashItems[] = $this->order->subMerchantId;
|
||||
$hashItems[] = $this->card->number;
|
||||
$hashItems[] = $this->getCardExpDate();
|
||||
$hashItems[] = $this->card->cvv;
|
||||
$hashItems[] = $this->order->rand;
|
||||
$hashItems[] = $this->order->requestDateTime;
|
||||
//$hashItems[] = $this->order->b2bIdentityNumber;
|
||||
|
||||
$hashItemsString = implode('', $hashItems);
|
||||
|
||||
$hashItemsStringHashed = hash_hmac('sha512', $hashItemsString, $this->account->secret_key, true);
|
||||
|
||||
return base64_encode($hashItemsStringHashed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
|
||||
$params = explode('+', $data['hashParams']);
|
||||
|
||||
$builder = '';
|
||||
foreach ($params as $param) {
|
||||
$builder .= $data[$param];
|
||||
}
|
||||
|
||||
$hashItemsStringHashed = hash_hmac('sha512', $builder, $this->account->secret_key, true);
|
||||
$hashItemsStringHashed = base64_encode($hashItemsStringHashed);
|
||||
|
||||
if ($data['hash'] == $hashItemsStringHashed) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('responseCode') == 'VPS-0000') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
//if ($this->request->get('3DStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
// } elseif (in_array($this->request->get('3DStatus'), [2, 3, 4])) {
|
||||
//$transaction_security = 'Half 3D Secure';
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('authCode'),
|
||||
'order_id' => (string)$this->request->get('orderId'),
|
||||
'trans_id' => (string)$this->request->get('rrn'),
|
||||
'response' => (string)$this->request->get('responseCode'),
|
||||
'merchantSafeId' => (string)$this->request->get('merchantSafeId'),
|
||||
'terminalSafeId' => (string)$this->request->get('terminalSafeId'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => (string)$this->request->get('rrn'),
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => (string)$this->request->get('authCode'),
|
||||
'host_ref_num' => (string)$this->request->get('rrn'),
|
||||
'proc_return_code' => (string)$this->request->get('hostResponseCode'),
|
||||
'code' => (string)$this->request->get('responseCode'),
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseCode') : null,
|
||||
'error_message' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseMessage') : null,
|
||||
'md_status' => (string)$this->request->get('md_status'),
|
||||
'hash' => (string)$this->request->get('hash'),
|
||||
'rand' => null,
|
||||
'hash_params' => (string)$this->request->get('hashParams'),
|
||||
'hash_params_val' => (string)$this->request->get('hash'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'md_error_message' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseMessage') : null,
|
||||
'all' => $this->request->request->all()
|
||||
];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$this->order->amount = number_format($this->order->amount, 2, '.', '');
|
||||
$this->order->rand = $this->getRandomNumberBase16();
|
||||
$this->order->requestDateTime = mb_substr(Carbon::now()->toISOString(), 0, 23);
|
||||
$this->order->installment = $this->order->installment == 0 ? 1 : $this->order->installment;
|
||||
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'paymentModel' => mb_strtoupper($this->account->model),
|
||||
'txnCode' => $this->txnCode,
|
||||
'merchantSafeId' => $this->account->merchant_safe_id,
|
||||
'terminalSafeId' => $this->account->terminal_safe_id,
|
||||
'orderId' => $this->order->id,
|
||||
'lang' => mb_strtoupper($this->order->lang),
|
||||
'amount' => $this->order->amount,
|
||||
'currencyCode' => $this->order->currency,
|
||||
'installCount' => $this->order->installment,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'creditCard' => $this->card->number,
|
||||
'expiredDate' => $this->getCardExpDate(),
|
||||
'cvv' => $this->card->cvv,
|
||||
'randomNumber' => $this->order->rand,
|
||||
'requestDateTime' => $this->order->requestDateTime,
|
||||
'hash' => $this->order->hash,
|
||||
];
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
|
||||
//$formData = $data;
|
||||
//echo view('threeDSecureForm', compact('formData'));die();
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
$this->txnCode = 3000;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
881
app/Core/Payment/Pos/EstPos.php
Normal file
881
app/Core/Payment/Pos/EstPos.php
Normal file
@@ -0,0 +1,881 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class EstPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'EstPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
|
||||
if ($this->account->model == '3d') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->order->rand . $this->account->store_key;
|
||||
} elseif ($this->account->model == '3d_pay') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->store_key;
|
||||
}
|
||||
|
||||
return base64_encode(sha1($hash_str, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$hash_params = $data['HASHPARAMS'];
|
||||
$hash_params_val = $data['HASHPARAMSVAL'];
|
||||
$hash_param = $data['HASH'];
|
||||
$params_val = '';
|
||||
|
||||
$hashparams_arr = explode(':', $hash_params);
|
||||
foreach ($hashparams_arr as $value) {
|
||||
if(!empty($value) && isset($data[$value])){
|
||||
$params_val = $params_val . $data[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$hash_val = $params_val . $this->account->store_key;
|
||||
$hash = base64_encode(sha1($hash_val, true));
|
||||
|
||||
$return = false;
|
||||
if ($hash_params && !($params_val != $hash_params_val || $hash_param != $hash)) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
$contents = '';
|
||||
if (in_array($this->order->transaction, ['pay', 'pre'])) {
|
||||
$contents = $this->createRegularPaymentXML();
|
||||
} elseif ($this->order->transaction == 'post') {
|
||||
$contents = $this->createRegularPostXML();
|
||||
}
|
||||
|
||||
$this->send($contents);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'campaign_url' => null,
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'original' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->check3DHash($this->request->request->all())) {
|
||||
$contents = $this->create3DPaymentXML();
|
||||
$this->send($contents);
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'campaign_url' => null,
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'3d_all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'campaign_url' => null,
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hash' => $this->order->hash,
|
||||
'cardType' => $this->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
'firmaadi' => $this->order->name,
|
||||
'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
];
|
||||
|
||||
if ($this->account->model == '3d_pay') {
|
||||
$inputs = array_merge($inputs, [
|
||||
'islemtipi' => $this->type,
|
||||
'taksit' => $this->order->installment,
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Credit',
|
||||
]
|
||||
];
|
||||
|
||||
if ($meta['amount']) $nodes['Total'] = $meta['amount'];
|
||||
|
||||
$xml = $this->createXML($nodes, 'ISO-8859-9');
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Void',
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERSTATUS' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$first_amount = isset($this->data->Extra->ORIG_TRANS_AMT) ? $this->printData($this->data->Extra->ORIG_TRANS_AMT) : null;
|
||||
$capture_amount = isset($this->data->Extra->CAPTURE_AMT) ? $this->printData($this->data->Extra->CAPTURE_AMT) : null;
|
||||
$capture = $first_amount == $capture_amount ? true : false;
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'host_ref_num' => isset($this->data->Extra->HOST_REF_NUM) ? $this->printData($this->data->Extra->HOST_REF_NUM) : null,
|
||||
'order_status' => isset($this->data->Extra->ORDERSTATUS) ? $this->printData($this->data->Extra->ORDERSTATUS) : null,
|
||||
'process_type' => isset($this->data->Extra->CHARGE_TYPE_CD) ? $this->printData($this->data->Extra->CHARGE_TYPE_CD) : null,
|
||||
'pan' => isset($this->data->Extra->PAN) ? $this->printData($this->data->Extra->PAN) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'first_amount' => $first_amount,
|
||||
'capture_amount' => $capture_amount,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'capture' => $capture,
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERHISTORY' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'trans_count' => isset($this->data->Extra->TRXCOUNT) ? $this->printData($this->data->Extra->TRXCOUNT) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '2';
|
||||
}elseif($this->card->type == '1' || $this->card->type == '2'){
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
}
|
||||
913
app/Core/Payment/Pos/EstPosV3.php
Normal file
913
app/Core/Payment/Pos/EstPosV3.php
Normal file
@@ -0,0 +1,913 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class EstPosV3 implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'EstPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash($inputs)
|
||||
{
|
||||
|
||||
$hash3D = null;
|
||||
$postParams = [];
|
||||
foreach ($inputs as $key => $value){
|
||||
array_push($postParams, $key);
|
||||
}
|
||||
|
||||
natcasesort($postParams);
|
||||
|
||||
$hashval = "";
|
||||
foreach ($postParams as $param){
|
||||
$paramValue = $inputs[$param];
|
||||
$escapedParamValue = str_replace("|", "\\|", str_replace("\\", "\\\\", $paramValue));
|
||||
|
||||
$lowerParam = strtolower($param);
|
||||
if($lowerParam != "hash" && $lowerParam != "encoding" ) {
|
||||
$hashval = $hashval . $escapedParamValue . "|";
|
||||
}
|
||||
}
|
||||
|
||||
$storeKey = $this->account->store_key;
|
||||
$escapedStoreKey = str_replace("|", "\\|", str_replace("\\", "\\\\", $storeKey));
|
||||
$hashval = $hashval . $escapedStoreKey;
|
||||
|
||||
$calculatedHashValue = hash('sha512', $hashval);
|
||||
$hash3D = base64_encode (pack('H*',$calculatedHashValue));
|
||||
|
||||
return $hash3D;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
|
||||
$return = false;
|
||||
|
||||
Log::debug('LOG - 1');
|
||||
Log::debug($data);
|
||||
|
||||
$postParams = [];
|
||||
foreach ($data as $key => $value) {
|
||||
array_push($postParams, $key);
|
||||
}
|
||||
|
||||
natcasesort($postParams);
|
||||
|
||||
$hashval = "";
|
||||
foreach ($postParams as $param) {
|
||||
$paramValue = $data[$param];
|
||||
$escapedParamValue = str_replace("|", "\\|", str_replace("\\", "\\\\", $paramValue));
|
||||
|
||||
$lowerParam = strtolower($param);
|
||||
if ($lowerParam != "hash" && $lowerParam != "encoding") {
|
||||
$hashval = $hashval . $escapedParamValue . "|";
|
||||
}
|
||||
}
|
||||
|
||||
$storeKey = $this->account->store_key;
|
||||
$escapedStoreKey = str_replace("|", "\\|", str_replace("\\", "\\\\", $storeKey));
|
||||
$hashval = $hashval . $escapedStoreKey;
|
||||
|
||||
$calculatedHashValue = hash('sha512', $hashval);
|
||||
$actualHash = base64_encode(pack('H*', $calculatedHashValue));
|
||||
|
||||
$retrievedHash = fillOnUndefined($data,'HASH');
|
||||
|
||||
Log::debug('LOG - 2');
|
||||
Log::debug($data);
|
||||
|
||||
if ($retrievedHash == $actualHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
$contents = '';
|
||||
if (in_array($this->order->transaction, ['pay', 'pre'])) {
|
||||
$contents = $this->createRegularPaymentXML();
|
||||
} elseif ($this->order->transaction == 'post') {
|
||||
$contents = $this->createRegularPostXML();
|
||||
}
|
||||
|
||||
$this->send($contents);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'campaign_url' => null,
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'original' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->check3DHash($this->request->request->all())) {
|
||||
$contents = $this->create3DPaymentXML();
|
||||
$this->send($contents);
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'campaign_url' => null,
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'3d_all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'hashAlgorithm' => (string)$this->request->get('hashAlgorithm'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => ($status != 'approved' && empty((string)$this->request->get('ErrMsg'))) ? (string)$this->request->get('mdErrorMsg') : (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'merchantName' => (string)$this->request->get('merchantName'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$inputs = [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hashAlgorithm' => 'ver3',
|
||||
'cardType' => $this->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
//'firmaadi' => $this->order->name,
|
||||
//'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'callbackUrl' => null,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
'TranType' => 'Auth',
|
||||
'Instalment' => $this->order->installment,
|
||||
];
|
||||
|
||||
$inputs['HASH'] = $this->create3DHash($inputs);
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
//'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Credit',
|
||||
]
|
||||
];
|
||||
|
||||
if ($meta['amount']) $nodes['Total'] = $meta['amount'];
|
||||
|
||||
$xml = $this->createXML($nodes, 'ISO-8859-9');
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Void',
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERSTATUS' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$first_amount = isset($this->data->Extra->ORIG_TRANS_AMT) ? $this->printData($this->data->Extra->ORIG_TRANS_AMT) : null;
|
||||
$capture_amount = isset($this->data->Extra->CAPTURE_AMT) ? $this->printData($this->data->Extra->CAPTURE_AMT) : null;
|
||||
$capture = $first_amount == $capture_amount ? true : false;
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'host_ref_num' => isset($this->data->Extra->HOST_REF_NUM) ? $this->printData($this->data->Extra->HOST_REF_NUM) : null,
|
||||
'order_status' => isset($this->data->Extra->ORDERSTATUS) ? $this->printData($this->data->Extra->ORDERSTATUS) : null,
|
||||
'process_type' => isset($this->data->Extra->CHARGE_TYPE_CD) ? $this->printData($this->data->Extra->CHARGE_TYPE_CD) : null,
|
||||
'pan' => isset($this->data->Extra->PAN) ? $this->printData($this->data->Extra->PAN) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'first_amount' => $first_amount,
|
||||
'capture_amount' => $capture_amount,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'capture' => $capture,
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERHISTORY' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'trans_count' => isset($this->data->Extra->TRXCOUNT) ? $this->printData($this->data->Extra->TRXCOUNT) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '2';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
}
|
||||
25
app/Core/Payment/Pos/Exceptions/BankClassNullException.php
Normal file
25
app/Core/Payment/Pos/Exceptions/BankClassNullException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BankClassNullException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class BankClassNullException extends Exception
|
||||
{
|
||||
/**
|
||||
* BankClassNullException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Class must be specified!', $code = 331, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
25
app/Core/Payment/Pos/Exceptions/BankNotFoundException.php
Normal file
25
app/Core/Payment/Pos/Exceptions/BankNotFoundException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BankNotFoundException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class BankNotFoundException extends Exception
|
||||
{
|
||||
/**
|
||||
* BankNotFoundException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Bank not found!', $code = 330, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class UnsupportedPaymentModelException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class UnsupportedPaymentModelException extends Exception
|
||||
{
|
||||
/**
|
||||
* UnsupportedPaymentModelException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Unsupported payment model!', $code = 333, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class UnsupportedTransactionTypeException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class UnsupportedTransactionTypeException extends Exception
|
||||
{
|
||||
/**
|
||||
* UnsupportedTransactionTypeException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Unsupported transaction type!', $code = 332, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
1059
app/Core/Payment/Pos/GarantiPos.php
Normal file
1059
app/Core/Payment/Pos/GarantiPos.php
Normal file
File diff suppressed because it is too large
Load Diff
230
app/Core/Payment/Pos/Pos.php
Normal file
230
app/Core/Payment/Pos/Pos.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Exception;
|
||||
use Exceptions\BankClassNullException;
|
||||
use Exceptions\BankNotFoundException;
|
||||
|
||||
/**
|
||||
* Class Pos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class Pos
|
||||
{
|
||||
/**
|
||||
* Global Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $config = [];
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* Order
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Bank Class
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $bank;
|
||||
|
||||
/**
|
||||
* Pos constructor.
|
||||
*
|
||||
* @param array $account
|
||||
* @param array null $config
|
||||
* @throws BankNotFoundException
|
||||
* @throws BankClassNullException
|
||||
*/
|
||||
public function __construct(array $account, array $config = null)
|
||||
{
|
||||
|
||||
// Get Global Configuration
|
||||
$this->config = $config ? $config : require __DIR__ . '/config/pos.php';
|
||||
|
||||
// API Account
|
||||
$this->account = (object) $account;
|
||||
|
||||
// Bank API Exist
|
||||
if ( ! array_key_exists($this->account->bank, $this->config['banks'])) {
|
||||
throw new BankNotFoundException();
|
||||
}
|
||||
|
||||
// Instance Bank Class
|
||||
$this->instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance Bank Class
|
||||
*
|
||||
* @throws BankClassNullException
|
||||
*/
|
||||
public function instance()
|
||||
{
|
||||
// Bank Class
|
||||
$class = $this->config['banks'][$this->account->bank]['class'];
|
||||
|
||||
if ( ! $class) throw new BankClassNullException();
|
||||
|
||||
// Create Bank Class Object
|
||||
$this->bank = new $class($this->config['banks'][$this->account->bank], $this->account, $this->config['currencies']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param array $order
|
||||
* @param array [] $card
|
||||
* @return Pos
|
||||
*/
|
||||
public function prepare(array $order, array $card = [])
|
||||
{
|
||||
// Installment
|
||||
$installment = 0;
|
||||
if (isset($order['installment'])) {
|
||||
$installment = $order['installment'] ? (int) $order['installment'] : 0;
|
||||
}
|
||||
|
||||
// Currency
|
||||
$currency = null;
|
||||
if (isset($order['currency'])) {
|
||||
$currency = (int) $this->config['currencies'][$order['currency']];
|
||||
}
|
||||
|
||||
// Order
|
||||
$this->order = (object) array_merge($order, [
|
||||
'installment' => $installment,
|
||||
'currency' => $currency,
|
||||
]);
|
||||
|
||||
// Card
|
||||
$this->card = $card ? (object) $card : null;
|
||||
|
||||
// Prepare Order
|
||||
$this->bank->prepare($this->order, $this->card);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param array [] $card
|
||||
* @return mixed
|
||||
*/
|
||||
public function payment(array $card = [])
|
||||
{
|
||||
// Credit Card
|
||||
if ($card) {
|
||||
$card = array_merge($card, [
|
||||
'month' => str_pad((int) $card['month'], 2, 0, STR_PAD_LEFT),
|
||||
'year' => str_pad((int) $card['year'], 2, 0, STR_PAD_LEFT),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->card = (object) $card;
|
||||
|
||||
// Make Payment
|
||||
return $this->bank->payment($this->card);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gateway URL
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGatewayUrl()
|
||||
{
|
||||
return isset($this->bank->gateway) ? $this->bank->gateway : 'null';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig(){
|
||||
return $this->bank->getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount(){
|
||||
return $this->bank->getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies(){
|
||||
return $this->bank->getCurrencies();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder(){
|
||||
return $this->bank->getOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard(){
|
||||
return $this->bank->getCard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3dFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
try {
|
||||
$data = $this->bank->get3dFormData();
|
||||
} catch (Exception $e) {}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return $this->bank->isSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return $this->bank->isError();
|
||||
}
|
||||
}
|
||||
99
app/Core/Payment/Pos/PosHelpersTrait.php
Normal file
99
app/Core/Payment/Pos/PosHelpersTrait.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use SimpleXMLElement;
|
||||
|
||||
/**
|
||||
* Trait PosHelpersTrait
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
trait PosHelpersTrait
|
||||
{
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Create XML DOM Document
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param string $encoding
|
||||
* @return string the XML, or false if an error occurred.
|
||||
*/
|
||||
public function createXML(array $nodes, $encoding = 'UTF-8')
|
||||
{
|
||||
$rootNodeName = array_keys($nodes)[0];
|
||||
$encoder = new XmlEncoder();
|
||||
|
||||
$xml = $encoder->encode($nodes[$rootNodeName], 'xml', [
|
||||
XmlEncoder::ROOT_NODE_NAME => $rootNodeName,
|
||||
XmlEncoder::ENCODING => $encoding
|
||||
]);
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print Data
|
||||
*
|
||||
* @param $data
|
||||
* @return null|string
|
||||
*/
|
||||
public function printData($data)
|
||||
{
|
||||
if ((is_object($data) || is_array($data)) && !count((array)$data)) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
return (string)$data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
$success = false;
|
||||
if (isset($this->response) && $this->response->status == 'approved') {
|
||||
$success = true;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return !$this->isSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts XML string to object
|
||||
*
|
||||
* @param string data
|
||||
* @return object
|
||||
*/
|
||||
public function XMLStringToObject($data)
|
||||
{
|
||||
$encoder = new XmlEncoder();
|
||||
$xml = $encoder->decode($data, 'xml');
|
||||
return (object)json_decode(json_encode($xml));
|
||||
}
|
||||
}
|
||||
141
app/Core/Payment/Pos/PosInterface.php
Normal file
141
app/Core/Payment/Pos/PosInterface.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Mews\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
|
||||
/**
|
||||
* Interface PosInterface
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
interface PosInterface
|
||||
{
|
||||
/**
|
||||
* PosInterface constructor.
|
||||
*
|
||||
* @param object $config
|
||||
* @param object $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies);
|
||||
|
||||
/**
|
||||
* Create XML DOM Document
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param string $encoding
|
||||
* @return string the XML, or false if an error occurred.
|
||||
*/
|
||||
public function createXML(array $nodes, $encoding = 'UTF-8');
|
||||
|
||||
/**
|
||||
* Print Data
|
||||
*
|
||||
* @param $data
|
||||
* @return null|string
|
||||
*/
|
||||
public function printData($data);
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment();
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment();
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment();
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents);
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order);
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card);
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta);
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta);
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta);
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta);
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess();
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError();
|
||||
}
|
||||
1106
app/Core/Payment/Pos/PosNet.php
Normal file
1106
app/Core/Payment/Pos/PosNet.php
Normal file
File diff suppressed because it is too large
Load Diff
170
app/Core/Payment/Pos/PosNetCrypt.php
Normal file
170
app/Core/Payment/Pos/PosNetCrypt.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
/**
|
||||
* Class PosNetCrypt
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class PosNetCrypt
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $algo;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $ks;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $block;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* PosNetCrypt constructor.
|
||||
*/
|
||||
public function __construct ()
|
||||
{
|
||||
srand((double) microtime() * 10000000);
|
||||
$this->algo = 'des-ede3-cbc';
|
||||
$this->block = 8;
|
||||
$this->ks = 24;
|
||||
$this->error = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to get encryption errors.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastError ()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function createIV ()
|
||||
{
|
||||
$temp = sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
|
||||
return pack("H*", substr($temp, 0, 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $key
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($data, $key)
|
||||
{
|
||||
// Create IV
|
||||
$iv = $this->createIV();
|
||||
|
||||
// Encrypt Data
|
||||
$encrypted_data = openssl_encrypt($data, $this->algo, $this->detKey($key), OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
// Add IV and Convert to HEX
|
||||
$hex_encrypted_data = strtoupper(bin2hex($iv)).strtoupper(bin2hex($encrypted_data));
|
||||
|
||||
// Add CRC
|
||||
$hex_encrypted_data = $this->addCrc($hex_encrypted_data);
|
||||
|
||||
return $hex_encrypted_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $key
|
||||
* @return bool|string
|
||||
*/
|
||||
public function decrypt($data, $key) {
|
||||
|
||||
$parsed_data = $this->parseEncryptedData($data);
|
||||
|
||||
if (!$parsed_data) return false;
|
||||
|
||||
// Check CRC
|
||||
if (!$this->checkCrc($parsed_data['crc_data'], $parsed_data['crc'])) {
|
||||
$this->error = "CRC is not valid! (" . $parsed_data['crc'] . ")";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get IV
|
||||
$iv = pack("H*", $parsed_data['iv']);
|
||||
|
||||
// Get Encrypted Data
|
||||
$encrypted_data = pack("H*", $parsed_data['payload']);
|
||||
|
||||
// Decrypt Data
|
||||
$decrypted_data = openssl_decrypt($encrypted_data, $this->algo, $this->detKey($key), OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
return $decrypted_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return bool|string
|
||||
*/
|
||||
public function detKey($key)
|
||||
{
|
||||
$deskey = substr(strtoupper(md5($key)), 0, $this->ks);
|
||||
return $deskey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return string
|
||||
*/
|
||||
public function addCrc($data)
|
||||
{
|
||||
$crc = crc32($data);
|
||||
$hex_crc = sprintf("%08x", $crc);
|
||||
$data .= strtoupper($hex_crc);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $crc
|
||||
* @return bool
|
||||
*/
|
||||
public function checkCrc($data, $crc)
|
||||
{
|
||||
$crc_calc = crc32($data);
|
||||
$hex_crc = sprintf("%08x", $crc_calc);
|
||||
$crc_calc = strtoupper($hex_crc);
|
||||
|
||||
return strcmp($crc_calc, $crc) == 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return array|bool
|
||||
*/
|
||||
private function parseEncryptedData(string $data){
|
||||
|
||||
if (strlen($data) < 16 + 8) return false;
|
||||
|
||||
return [
|
||||
'crc' => substr($data, -8),
|
||||
'crc_data' => substr($data, 0, strlen($data)-8),
|
||||
'iv' => substr($data, 0, 16),
|
||||
'payload' => substr($data, 16, strlen($data)-16-8)
|
||||
];
|
||||
}
|
||||
}
|
||||
644
app/Core/Payment/Pos/QPos.php
Normal file
644
app/Core/Payment/Pos/QPos.php
Normal file
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class QPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $mbrId = 5;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
$hash_str = $this->mbrId . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->merchant_pass;
|
||||
|
||||
return base64_encode(pack('H*', sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
$responseHash = $data['ResponseHash'];
|
||||
|
||||
//MerchantID + MerchantPass + OrderId + AuthCode + ProcReturnCode + 3DStatus + ResponseRnd + UserCode
|
||||
$generatedHash = $this->account->merchant_id . $this->account->merchant_pass . $data['OrderId'] . $data['AuthCode'] . $data['ProcReturnCode'] . $data['3DStatus'] . $data['ResponseRnd'] . $this->account->user_code;
|
||||
$generatedHash = base64_encode(pack('H*', sha1($generatedHash)));
|
||||
|
||||
if ($generatedHash == $responseHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('3DStatus'), [1])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('3DStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('3DStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('RequestGuid'),
|
||||
'trans_id' => (string)$this->request->get('HostRefNum'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
//'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('OrderId'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('3DStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('ResponseHash'),
|
||||
'rand' => (string)$this->request->get('Rnd'),
|
||||
//'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
//'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('CardMask'),
|
||||
//'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
//'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('PurchAmount'),
|
||||
'currency' => (string)$this->request->get('Currency'),
|
||||
'tx_status' => (string)$this->request->get('TxnStatus'),
|
||||
'eci' => (string)$this->request->get('Eci'),
|
||||
'cavv' => (string)$this->request->get('CavvResult'),
|
||||
//'xid' => (string)$this->request->get('xid'),
|
||||
//'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
//'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('MrcName'),
|
||||
//'email' => (string)$this->request->get('Email'),
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'response_rnd' => $this->request->get('ResponseRnd'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'MbrId' => $this->mbrId,
|
||||
'MerchantID' => $this->account->merchant_id,
|
||||
'UserCode' => $this->account->user_code,
|
||||
'UserPass' => $this->account->user_pass,
|
||||
'SecureType' => $this->account->model == '3d_pay' ? '3DPay' : '3D',
|
||||
'TxnType' => $this->type,
|
||||
'InstallmentCount' => $this->order->installment,
|
||||
'Currency' => $this->order->currency,
|
||||
'OkUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->fail_url,
|
||||
'OrderId' => $this->order->id,
|
||||
'PurchAmount' => $this->order->amount,
|
||||
'Lang' => $this->order->lang,
|
||||
'Rnd' => $this->order->rand,
|
||||
'Hash' => $this->order->hash,
|
||||
'Pan' => $this->card->number,
|
||||
'Cvv2' => $this->card->cvv,
|
||||
'Expiry' => $this->getCardExpDate(),
|
||||
];
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
656
app/Core/Payment/Pos/VPos.php
Normal file
656
app/Core/Payment/Pos/VPos.php
Normal file
@@ -0,0 +1,656 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class VPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
|
||||
if ($this->account->model == '3d') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->order->rand . $this->account->store_key;
|
||||
} elseif ($this->account->model == '3d_pay') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->store_key;
|
||||
}
|
||||
|
||||
return base64_encode(pack('H*',sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$hash_params = $data['HASHPARAMS'];
|
||||
$hash_params_val = $data['HASHPARAMSVAL'];
|
||||
$hash_param = $data['HASH'];
|
||||
$params_val = '';
|
||||
|
||||
$hashparams_arr = explode(':', $hash_params);
|
||||
foreach ($hashparams_arr as $value) {
|
||||
if(!empty($value) && isset($data[$value])){
|
||||
$params_val = $params_val . $data[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$hash_val = $params_val . $this->account->store_key;
|
||||
$hash = base64_encode(sha1($hash_val, true));
|
||||
|
||||
$return = false;
|
||||
if ($hash_params && !($params_val != $hash_params_val || $hash_param != $hash)) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'campaign_url' => null,
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'Version3D' => '2.0',
|
||||
'ShopCode' => $this->account->client_id,
|
||||
'PurchAmount' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'OrderId' => $this->order->id,
|
||||
'OkUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->fail_url,
|
||||
'Rnd' => $this->order->rand,
|
||||
'Hash' => $this->order->hash,
|
||||
'TxnType' => $this->type,
|
||||
'Pan' => $this->card->number,
|
||||
'Cvv2' => $this->card->cvv,
|
||||
'Expiry' => $this->getCardExpDate(),
|
||||
'CardType' => $this->getCardCode(),
|
||||
'BonusAmount' => '',
|
||||
'Lang' => $this->order->lang
|
||||
];
|
||||
|
||||
if ($this->account->model == '3d_pay') {
|
||||
$inputs = array_merge($inputs, [
|
||||
'SecureType' => '3DPay',
|
||||
'InstallmentCount' => $this->order->installment,
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? '' : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
}elseif($this->card->type == '1' || $this->card->type == '2'){
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string) substr($this->card->year, 2,2);
|
||||
$month = (string) substr($this->card->month, 0,2);
|
||||
|
||||
return (string) $month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
689
app/Core/Payment/Pos/VkfPos.php
Normal file
689
app/Core/Payment/Pos/VkfPos.php
Normal file
@@ -0,0 +1,689 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class VkfPOS
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class VkfPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $client;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$client = new Client();
|
||||
$this->client = $client;
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
$hash_str = $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->merchant_pass;
|
||||
|
||||
return base64_encode(pack('H*', sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
$responseHash = $data['ResponseHash'];
|
||||
|
||||
//MerchantID + MerchantPass + OrderId + AuthCode + ProcReturnCode + 3DStatus + ResponseRnd + UserCode
|
||||
$generatedHash = $this->account->merchant_id . $this->account->merchant_pass . $data['OrderId'] . $data['AuthCode'] . $data['ProcReturnCode'] . $data['3DStatus'] . $data['ResponseRnd'] . $this->account->user_code;
|
||||
$generatedHash = base64_encode(pack('H*', sha1($generatedHash)));
|
||||
|
||||
if ($generatedHash == $responseHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
$requestAll = $this->request->request->all();
|
||||
$ipAddress = $this->request->getClientIp();
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r($this->order);
|
||||
die();*/
|
||||
|
||||
$paymentCheck = null;
|
||||
$status = 'declined';
|
||||
$transaction_security = 'MPI fallback';
|
||||
$errorMessage = null;
|
||||
|
||||
try {
|
||||
|
||||
$requestParam = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><VposRequest></VposRequest>');
|
||||
|
||||
$requestParam->addChild('MerchantId', $this->account->merchant_id);
|
||||
$requestParam->addChild('Password', $this->account->merchant_password);
|
||||
$requestParam->addChild('TerminalNo', $this->account->terminal_no);
|
||||
$requestParam->addChild('TransactionType', 'Sale');
|
||||
$requestParam->addChild('OrderId', $this->order->id);
|
||||
$requestParam->addChild('CurrencyAmount', number_format(($requestAll['PurchAmount'] / 100), 2, '.', ''));
|
||||
$requestParam->addChild('CurrencyCode', $requestAll['PurchCurrency']);
|
||||
$requestParam->addChild('Pan', $requestAll['Pan']);
|
||||
$requestParam->addChild('Expiry', $this->order->creditCardYear . $this->order->creditCardMonth);
|
||||
$requestParam->addChild('Cvv', $this->order->creditCardYearCvv);
|
||||
$requestParam->addChild('ECI', $requestAll['Eci']);
|
||||
$requestParam->addChild('CAVV', $requestAll['Cavv']);
|
||||
$requestParam->addChild('MpiTransactionId', $requestAll['VerifyEnrollmentRequestId']);
|
||||
$requestParam->addChild('ClientIp', $ipAddress);
|
||||
$requestParam->addChild('TransactionDeviceSource', 0);
|
||||
|
||||
if (!empty($requestAll['InstallmentCount'])) {
|
||||
$requestParam->addChild('NumberOfInstallments', $requestAll['InstallmentCount']);
|
||||
}
|
||||
|
||||
$payment = $this->client->request('POST', $this->url, [
|
||||
'form_params' => ['prmstr' => $requestParam->asXML()]
|
||||
]);
|
||||
|
||||
$paymentCheck = $this->XMLStringToObject($payment->getBody()->getContents());
|
||||
|
||||
if ($paymentCheck->ResultCode == '0000') {
|
||||
$status = 'approved';
|
||||
} else {
|
||||
$errorMessage = $paymentCheck->ResultDetail;
|
||||
}
|
||||
|
||||
if ($paymentCheck->ThreeDSecureType == '2') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif ($paymentCheck->ThreeDSecureType == '3') {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error($this->account->bank . ' Error!');
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'trans_id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'auth_code' => isset($paymentCheck->AuthCode) ? (string)$paymentCheck->AuthCode : null,
|
||||
'host_ref_num' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'order_id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'status' => $status,
|
||||
'response' => $paymentCheck,
|
||||
'transaction_security' => $transaction_security,
|
||||
'error_code' => isset($paymentCheck->ResultCode) ? (string)$paymentCheck->ResultCode : null,
|
||||
'error_message' => $errorMessage,
|
||||
'all' => $paymentCheck
|
||||
];
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r($this->response);
|
||||
die();*/
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$threeDFormData = [];
|
||||
|
||||
try {
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$threeDCheckParam = [
|
||||
'Pan' => $this->card->number,
|
||||
'ExpiryDate' => $this->getCardExpDate(),
|
||||
'PurchaseAmount' => number_format(($this->order->amount * 100 / 100), 2, '.', ''),
|
||||
'Currency' => $this->order->currency,
|
||||
'BrandName' => null,
|
||||
'VerifyEnrollmentRequestId' => $this->order->id,
|
||||
'MerchantId' => $this->account->merchant_id,
|
||||
'MerchantPassword' => $this->account->merchant_password,
|
||||
'SuccessUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->success_url,
|
||||
];
|
||||
|
||||
$response = $this->client->request('POST', $this->gateway, [
|
||||
'form_params' => $threeDCheckParam
|
||||
]);
|
||||
|
||||
$threeDCheck = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
if ($threeDCheck->MessageErrorCode != 200) {
|
||||
throw new Exception($threeDCheck->MessageErrorCode . ' - ' . $threeDCheck->ErrorMessage);
|
||||
}
|
||||
|
||||
$threeDFormData = [
|
||||
'status' => $threeDCheck->Message->VERes->Status,
|
||||
'gateway' => $threeDCheck->Message->VERes->ACSUrl,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->success_url,
|
||||
'inputs' => [
|
||||
'PaReq' => $threeDCheck->Message->VERes->PaReq,
|
||||
'TermUrl' => $threeDCheck->Message->VERes->TermUrl,
|
||||
'MD' => $threeDCheck->Message->VERes->MD
|
||||
]
|
||||
];
|
||||
|
||||
if ($threeDFormData['status'] != 'Y') {
|
||||
throw new Exception('3D Secure is not supported for this card.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error($this->account->bank . ' Error!');
|
||||
Log::error($e->getMessage());
|
||||
$threeDFormData = [];
|
||||
}
|
||||
|
||||
return $threeDFormData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$year . $month;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
202
app/Core/Payment/Pos/config/pos.php
Normal file
202
app/Core/Payment/Pos/config/pos.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Payment\Pos\EstPos;
|
||||
use App\Core\Payment\Pos\GarantiPos;
|
||||
use App\Core\Payment\Pos\PosNet;
|
||||
use App\Core\Payment\Pos\VPos;
|
||||
use App\Core\Payment\Pos\QPos;
|
||||
use App\Core\Payment\Pos\VkfPos;
|
||||
use App\Core\Payment\Pos\EstPosV3;
|
||||
use App\Core\Payment\Pos\AkPos;
|
||||
|
||||
return [
|
||||
|
||||
// Currencies
|
||||
'currencies' => [
|
||||
'TRY' => 949,
|
||||
'USD' => 840,
|
||||
'EUR' => 978,
|
||||
'GBP' => 826,
|
||||
'JPY' => 392,
|
||||
'RUB' => 643,
|
||||
],
|
||||
|
||||
// Banks
|
||||
'banks' => [
|
||||
'akbank' => [
|
||||
'name' => 'AKBANK T.A.S.', ////Test - 5571135571135575, 12, 2026, 000, a
|
||||
'class' => AkPos::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://api.akbank.com/api/v1/payment/virtualpos/transaction/process',
|
||||
'test' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
|
||||
'gateway' => [
|
||||
'production' => 'https://virtualpospaymentgateway.akbank.com/securepay',
|
||||
'test' => 'https://virtualpospaymentgatewaypre.akbank.com/securepay',
|
||||
],
|
||||
]
|
||||
],
|
||||
'denizbank' => [ //https://test.inter-vpos.com.tr, 3123, InterTest11, InterTest11
|
||||
'name' => 'DENIZ BANK', //Test - 4090700090840057, 11, 2022, 592, 123
|
||||
'class' => VPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://spos.denizbank.com/mpi/Default.aspx',
|
||||
'test' => 'https://sanaltest.denizbank.com/mpi/Default.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://spos.denizbank.com/mpi/Default.aspx',
|
||||
'test' => 'https://sanaltest.denizbank.com/mpi/Default.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'ziraat' => [
|
||||
'name' => 'Ziraat Bankası',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'finansbank' => [
|
||||
'name' => 'QNB Finansbank',
|
||||
'class' => QPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'vakifbank' => [
|
||||
'name' => 'Vakıfbank',
|
||||
'class' => VkfPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://onlineodeme.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
|
||||
'test' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://3dsecure.vakifbank.com.tr/MPIAPI/MPI_Enrollment.aspx',
|
||||
'test' => 'https://3dsecuretest.vakifbank.com.tr/MPIAPI/MPI_Enrollment.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'turkiyefinans' => [ //TODO: Check this infos
|
||||
'name' => 'Türkiye Finans',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://www.fbwebpos.com/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://www.fbwebpos.com/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'halkbank' => [
|
||||
'name' => 'Halkbank',
|
||||
'class' => EstPosV3::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.halkbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.halkbank.com.tr/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'teb' => [
|
||||
'name' => 'TEB',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.teb.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.teb.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'ingbank' => [
|
||||
'name' => 'ING Bank',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.ingbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.ingbank.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'isbank' => [
|
||||
'name' => 'İşbank',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.isbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.isbank.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'isbank-payflex' => [
|
||||
'name' => 'İşbank - PayFlex',
|
||||
'class' => Mews\Pos\PayFlex::class,
|
||||
'urls' => [
|
||||
'production' => 'https://trx.payflex.com.tr/VposWeb/v3/Vposreq.aspx',
|
||||
'test' => 'https://sanalpos.innova.com.tr/ISBANK_v4/VposWeb/v3/Vposreq.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://mpi.vpos.isbank.com.tr/MPIEnrollment.aspx',
|
||||
'test' => 'https://sanalpos.innova.com.tr/ISBANK/MpiWeb/Enrollment.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'yapikredi' => [
|
||||
'name' => 'Yapıkredi',
|
||||
'class' => PosNet::class,
|
||||
'urls' => [
|
||||
'production' => 'https://posnet.yapikredi.com.tr/PosnetWebService/XML',
|
||||
'test' => 'https://setmpos.ykb.com/PosnetWebService/XML',
|
||||
'gateway' => [
|
||||
'production' => 'https://posnet.yapikredi.com.tr/3DSWebService/YKBPaymentService',
|
||||
'test' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
|
||||
],
|
||||
],
|
||||
'order' => [
|
||||
'id_total_length' => 24,
|
||||
'id_length' => 20,
|
||||
'id_3d_prefix' => 'TDSC',
|
||||
'id_3d_pay_prefix' => '', //?
|
||||
'id_regular_prefix' => '' //?
|
||||
]
|
||||
],
|
||||
'garanti' => [
|
||||
'name' => 'Garanti',
|
||||
'class' => GarantiPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalposprov.garanti.com.tr/VPServlet',
|
||||
'test' => 'https://sanalposprovtest.garanti.com.tr/VPServlet',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalposprov.garanti.com.tr/servlet/gt3dengine',
|
||||
'test' => 'https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine',
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
//STRIPE
|
||||
//4000000000003063 3D required
|
||||
//4000000000003089 3D recommended
|
||||
//4000000000003055 3d optional
|
||||
//378282246310005 3d not_supported direct pay
|
||||
|
||||
//Vakıfbank
|
||||
//4938460158754205 2024/11 715 123456
|
||||
//4119790155203496 2024/04 579 123456
|
||||
//4119790166544284 2024/04 961 123456
|
||||
//6501700161161969 2024/11 390 123456
|
||||
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
composer.lock
|
||||
/vendor
|
||||
/.idea
|
||||
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
@@ -0,0 +1,3 @@
|
||||
© 2018 Muharrem ERİN (me@mewebstudio.com)
|
||||
|
||||
http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 MeWebStudio - Muharrem ERİN
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
190
app/Core/Payment/Pos/ex/README.md
Normal file
190
app/Core/Payment/Pos/ex/README.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Türk bankaları için sanal pos paketi (PHP)
|
||||
|
||||
Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal pos sistemlerinin kullanılabilmesidir.
|
||||
EST altyapısı tam olarak test edilmiş ve kullanıma hazırdır.
|
||||
Garanti Ödeme sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
YapıKredi Posnet sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
|
||||
> EST altyapısında olan Akbank ve Ziraat bankası test edilmiştir.
|
||||
|
||||
### Özellikler
|
||||
- Standart E-Commerce modeliyle ödeme (model => regular)
|
||||
- 3D modeliyle ödeme (model => 3d)
|
||||
- 3D Pay modeliyle ödeme (model => 3d_pay)
|
||||
- Sipariş/Ödeme sorgulama (query)
|
||||
- Sipariş/Ödeme geçmişi sorgulama (history)
|
||||
- Sipariş/Para iadesi yapma (refund)
|
||||
- Sipariş iptal etme (cancel)
|
||||
|
||||
### Minimum Gereksinimler
|
||||
- PHP >= 7.1.3
|
||||
- ext-dom
|
||||
- ext-json
|
||||
- ext-openssl
|
||||
- ext-SimpleXML
|
||||
|
||||
### Kurulum
|
||||
Test sunucunuz üzerinde;
|
||||
```sh
|
||||
$ mkdir pos-test && cd pos-test
|
||||
$ composer require mews/pos
|
||||
```
|
||||
|
||||
**config.php (Ayar dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require './vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos-test/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
// API kullanıcı bilgileri
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXXX',
|
||||
'username' => 'XXXXXXXX',
|
||||
'password' => 'XXXXXXXX',
|
||||
'env' => 'test', // test veya production. test ise; API Test Url, production ise; API Production URL kullanılır.
|
||||
];
|
||||
|
||||
// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
}
|
||||
```
|
||||
|
||||
**test.php (Test Dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
|
||||
// Sipariş bilgileri
|
||||
$order = [
|
||||
'id' => 'BENZERSIZ-SIPERIS-ID',
|
||||
'name' => 'John Doe', // zorunlu değil
|
||||
'email' => 'mail@customer.com', // zorunlu değil
|
||||
'user_id' => '12', // zorunlu değil
|
||||
'amount' => (double) 20, // Sipariş tutarı
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth (Direkt satış için pay, ön provizyon için pre)
|
||||
];
|
||||
|
||||
// Kredi kartı bilgieri
|
||||
$card = [
|
||||
'number' => 'XXXXXXXXXXXXXXXX', // Kredi kartı numarası
|
||||
'month' => 'XX', // SKT ay
|
||||
'year' => 'XX', // SKT yıl, son iki hane
|
||||
'cvv' => 'XXX', // Güvenlik kodu, son üç hane
|
||||
];
|
||||
|
||||
// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor
|
||||
$pos->prepare($order);
|
||||
|
||||
// Ödeme tamamlanıyor
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
// Ödeme başarılı mı?
|
||||
$payment->isSuccess();
|
||||
//veya
|
||||
$pos->isSuccess();
|
||||
|
||||
// Ödeme başarısız mı?
|
||||
$payment->isError();
|
||||
//veya
|
||||
$pos->isError();
|
||||
|
||||
// Sonuç çıktısı
|
||||
var_dump($payment->response);
|
||||
|
||||
````
|
||||
|
||||
### Farklı Banka Sanal Poslarını Eklemek
|
||||
Kendi projenizin dizinindeyken
|
||||
```sh
|
||||
$ cp ./vendor/mews/pos/config/pos.php ./pos_ayarlar.php
|
||||
```
|
||||
ya da;
|
||||
|
||||
Projenizde bir ayar dosyası oluşturup (pos_ayarlar.php gibi), paket içerisinde `./config/pos.php` dosyasının içeriğini buraya kopyalayın.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Para birimleri
|
||||
'currencies' => [
|
||||
'TRY' => 949,
|
||||
'USD' => 840,
|
||||
'EUR' => 978,
|
||||
'GBP' => 826,
|
||||
'JPY' => 392,
|
||||
'RUB' => 643,
|
||||
],
|
||||
|
||||
// Banka sanal pos tanımlamaları
|
||||
'banks' => [
|
||||
'akbank' => [
|
||||
'name' => 'AKBANK T.A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
// Yeni eklenen banka
|
||||
'isbank' => [
|
||||
'name' => 'İŞ BANKASI .A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class, // Altyapı sınıfı
|
||||
'urls' => [
|
||||
'production' => 'xxxx', // API Url
|
||||
'test' => 'xxxx', // API Test Url
|
||||
'gateway' => [
|
||||
'production' => 'xxxx', // 3d Kapı Url
|
||||
'test' => 'xxxx', // 3d Test Kapı Url
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:
|
||||
```php
|
||||
$yeni_ayarlar = require './pos_ayarlar.php';
|
||||
$pos = new \Mews\Pos\Pos($account, $yeni_ayarlar);
|
||||
```
|
||||
|
||||
### Örnek Kodlar
|
||||
`./pos/examples` dizini içerisinde.
|
||||
|
||||
### Yol Haritası
|
||||
- Dökümantasyon hazırlanacak
|
||||
- UnitTest yazılacak -> Bu hiçbir zaman olmayabilir, birisi el atarsa sevinirim :)
|
||||
|
||||
> Değerli yorum, öneri ve katkılarınızı bekliyorum.
|
||||
|
||||
License
|
||||
----
|
||||
|
||||
MIT
|
||||
31
app/Core/Payment/Pos/ex/composer.json
Normal file
31
app/Core/Payment/Pos/ex/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "mews/pos",
|
||||
"description": "Türk bankaları için sanal pos kütüphanesi",
|
||||
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank"],
|
||||
"homepage": "https://github.com/mewebstudio/pos",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Muharrem ERİN",
|
||||
"email": "me@mewebstudio.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-SimpleXML": "*",
|
||||
"guzzlehttp/guzzle": "^6.3.3",
|
||||
"symfony/http-foundation": "^5.0",
|
||||
"symfony/serializer": "^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mews\\Pos\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0"
|
||||
}
|
||||
}
|
||||
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181029A3C1',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4355084355084358',
|
||||
'month' => '12',
|
||||
'year' => '18',
|
||||
'cvv' => '000',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '201810297189',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card Holder Number</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card Holder Number">
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => '100100000',
|
||||
'username' => 'mewsapi',
|
||||
'password' => 'ME12345.',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810297189',
|
||||
'transaction' => 'post',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201810297E8B',
|
||||
'amount' => '100',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pre', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201810297189'
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$transaction = 'pay'; // pay => Auth, pre PreAuth
|
||||
$transaction_type = $pos->bank->types[$transaction];
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => $transaction,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<pre><?php print_r($form_data) ?></pre>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<pre><?php print_r($_POST) ?></pre>
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'refund_username' => 'PROVRFN',
|
||||
'refund_password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181114DF2C',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803579226',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4282209027132016',
|
||||
'month' => '05',
|
||||
'year' => '20',
|
||||
'cvv' => '165',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '2018111377EF',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691297',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810231553',
|
||||
'transaction' => 'post',
|
||||
'amount' => '1',
|
||||
'ref_ret_num' => '829603332856',
|
||||
'ip' => $ip,
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201811142A0A',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803586333',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 1;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '1',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => S, pre => preauth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">RetrefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->ret_ref_num ? $response->ret_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HashData:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash_data ? $response->hash_data : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201812195CF2',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
@@ -0,0 +1,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
var redirectForm = $('form.redirect-form')
|
||||
if (redirectForm.length) {
|
||||
redirectForm.submit()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $template_title; ?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<div class="container" style="max-width: 640px;">
|
||||
<h2 class="text-center"><?php echo $template_title; ?></h2>
|
||||
<hr>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user