Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:36:47 +02:00
parent bfa3bb1df4
commit 9ae662f63e
243 changed files with 12580 additions and 12018 deletions

View file

@ -79,7 +79,48 @@ class PayoneController extends Controller
public function getShoppingPayment(){
return $this->shopping_payment;
}
public function setAboPayment($user_abo, $amount, $currency){
$this->reference = substr(uniqid('m', false), 0, 16);
$this->method = [
"clearingtype" => $user_abo->clearingtype,
"wallettype" => $user_abo->wallettype,
"pseudocardpan" => isset($user_abo->carddata['pseudocardpan']) ? $user_abo->carddata['pseudocardpan'] : '',
"cardexpiredate" => isset($user_abo->carddata['cardexpiredate']) ? $user_abo->carddata['cardexpiredate'] : '',
'userid' => $user_abo->payone_userid,
'onlinebanktransfertype' => '',
"request" => "authorization",
];
$this->aboInitPayment = [
'recurrence'=>'recurring',
'customer_is_present'=>'no',
'request' => 'authorization',
'amount' => $amount
];
$this->prepayment = [
"reference" => $this->reference, // a unique reference, e.g. order number
"amount" => $amount, // amount in smallest currency unit, i.e. cents
"currency" => $currency,
"param" => $this->shopping_order->id,
];
$this->shopping_payment = ShoppingPayment::create([
'shopping_order_id' => $this->shopping_order->id,
'clearingtype' => $this->method["clearingtype"],
'wallettype' => $this->method["wallettype"],
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
'carddata' => $user_abo->carddata,
'reference' => $this->reference,
'amount' => $amount,
'currency' => $currency,
'is_abo' => $this->shopping_order->is_abo,
'abo_interval' => 0,
'mode' => $this->shopping_order->mode,
]);
}
//make Payone payment
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
@ -87,7 +128,7 @@ class PayoneController extends Controller
$this->setMethod($payment_method, $ret);
$this->urls = [
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
'errorurl' => route('checkout.transaction_status', ['error', $this->reference]),
'backurl' => route('checkout.transaction_status', ['cancel', $this->reference]),
];
@ -100,10 +141,30 @@ class PayoneController extends Controller
];
//init Abo
if($this->shopping_order->is_abo){
$this->aboInitPayment = [
'recurrence'=>'recurring',
'customer_is_present'=>'yes'
];
if($this->method["clearingtype"] === "cc"){
$this->aboInitPayment = [
'recurrence'=>'recurring',
'customer_is_present'=>'yes',
'request' => 'authorization',
'amount' => $amount,
];
$this->method['request'] = 'authorization';
}
if($this->method["clearingtype"] === "wlt"){
//payment for Abo PayPal
$this->aboInitPayment = [
'recurrence'=>'recurring',
'customer_is_present'=>'yes',
'request' => 'authorization',
'amount' => $amount,
'add_paydata[redirection_mode]' => 'DIRECT_TO_MERCHANT',
];
$this->setDeliverylData($this->shopping_user);
$this->method['request'] = 'authorization';
}
}
$this->shopping_payment = ShoppingPayment::create([
@ -111,11 +172,13 @@ class PayoneController extends Controller
'clearingtype' => $this->method["clearingtype"],
'wallettype' => $this->method["wallettype"],
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
'carddata' => isset($ret['cc']) ? $ret['cc'] : null,
'reference' => $this->reference,
'amount' => $amount,
'currency' => $currency,
'is_abo' => $this->shopping_order->is_abo,
'abo_interval' => $this->shopping_order->abo_interval,
'identifier' => Util::getUserShopIdentifier(),
'mode' => $this->shopping_order->mode,
]);
@ -163,6 +226,8 @@ class PayoneController extends Controller
'onlinebanktransfertype' => "",
"request" => "authorization"
];
}
//Online-Überweisung
if($payment_method[0] === 'sb'){
@ -240,17 +305,17 @@ class PayoneController extends Controller
}
public function onlyPaymentResponse(){
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
$response = Payone::sendRequest($request);
return $response;
}
public function ResponseData(){
public function ResponseData($is_abo = false){
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
//dd($request);
//RECHNUNG MIV
if($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV'){
$payt = PaymentTransaction::create([
'shopping_payment_id' => $this->shopping_payment->id,
'request' => $this->method['request'],
@ -262,6 +327,9 @@ class PayoneController extends Controller
'mode' => $this->shopping_payment->mode,
]);
Util::setUserHistoryValue(['status'=>5]);
if($is_abo){
return $this->reference;
}
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
exit;
}
@ -271,6 +339,12 @@ class PayoneController extends Controller
* status APPROVED / REDIRECT / ERROR / PENDING
*/
if($response['status'] === 'ERROR'){
MyLog::writeLog(
'payone',
'error',
'PayPal Preauthorization Fehler: ' . $response['errormessage'],
$response
);
PaymentTransaction::create([
'shopping_payment_id' => $this->shopping_payment->id,
'request' => $this->method['request'],
@ -281,6 +355,9 @@ class PayoneController extends Controller
'mode' => $this->shopping_payment->mode,
]);
Util::setUserHistoryValue(['status'=>3]);
if($is_abo){
return $response;
}
\Session::flash('errormessage', $response['errormessage']);
\Session::flash('customermessage', $response['customermessage']);
return redirect(route('checkout.checkout_card'));
@ -298,6 +375,9 @@ class PayoneController extends Controller
]);
Util::setUserHistoryValue(['status'=>4]);
if($is_abo){
return $response;
}
return redirect()->away($response["redirecturl"]);
exit;
@ -316,6 +396,9 @@ class PayoneController extends Controller
]);
Util::setUserHistoryValue(['status'=>5]);
if($is_abo){
return $response;
}
if($payt->shopping_payment->clearingtype === "vor"){
//vorkasse
@ -335,7 +418,6 @@ class PayoneController extends Controller
exit;
}
var_dump($response);
die();
//txid
@ -407,6 +489,27 @@ class PayoneController extends Controller
return Payone::sendRequest($request);
}
public function setDeliverylData($shopping_user){
if($shopping_user->same_as_billing == true){
$this->deliveryData = [
'shipping_firstname' => $shopping_user->billing_firstname,
'shipping_lastname' => $shopping_user->billing_lastname,
'shipping_zip' => $shopping_user->billing_zipcode,
'shipping_city' => $shopping_user->billing_city,
'shipping_country' => $shopping_user->billing_country->code,
'shipping_street' => $shopping_user->billing_address,
];
}else{
$this->deliveryData = [
'shipping_firstname' => $shopping_user->shipping_firstname,
'shipping_lastname' => $shopping_user->shipping_lastname,
'shipping_zip' => $shopping_user->shipping_zipcode,
'shipping_city' => $shopping_user->shipping_city,
'shipping_country' => $shopping_user->shipping_country->code,
'shipping_street' => $shopping_user->shipping_address,
];
}
}
/* public function getPDFFile($mandateId)
{
@ -492,17 +595,7 @@ class PayoneController extends Controller
public function setDeliverylData($data){
$this->deliveryData = [
"shipping_company" => "Mr.",
"shipping_firstname" => "Henry",
"shipping_lastname" => "Tudor",
"shipping_street" => "Royal Street 1",
"shipping_zip" => "24118",
"shipping_city" => "Kiel",
"shipping_country" => "DE",
];
}
*/