diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7227b21..79a77cb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,32 +2,14 @@ - - - - - - - - - - - - - - - - - + + + - - - - - - - + + + + @@ -335,6 +318,9 @@ + + + @@ -364,18 +350,22 @@ + + + + - + - - + + - + diff --git a/app/Http/Controllers/Pay/PayoneController.php b/app/Http/Controllers/Pay/PayoneController.php index b14447f..09b0691 100644 --- a/app/Http/Controllers/Pay/PayoneController.php +++ b/app/Http/Controllers/Pay/PayoneController.php @@ -79,10 +79,10 @@ class PayoneController extends Controller } //make Payone payment - public function setPrePayment($payment_method, $amount, $currency, $cc_ret = []){ + public function setPrePayment($payment_method, $amount, $currency, $ret = []){ $this->reference = substr(uniqid(true), 0, 16); - $this->setMethod($payment_method, $cc_ret); + $this->setMethod($payment_method, $ret); $this->urls = [ 'successurl' => route('checkout.transaction_status', ['success', $this->reference]), @@ -138,13 +138,13 @@ class PayoneController extends Controller } - private function setMethod($payment_method, $cc_ret = []){ + private function setMethod($payment_method, $ret = []){ if($payment_method){ if(strpos($payment_method, '#')){ $payment_method = explode('#', $payment_method); //wallet Paypal - if($payment_method[0] == 'wlt'){ + if($payment_method[0] === 'wlt'){ $this->method = [ "clearingtype" => "wlt", "wallettype" => $payment_method[1], @@ -153,7 +153,7 @@ class PayoneController extends Controller ]; } //Online-Überweisung - if($payment_method[0] == 'sb'){ + if($payment_method[0] === 'sb'){ $this->method = [ "clearingtype" => "sb", "wallettype" => "", @@ -164,7 +164,7 @@ class PayoneController extends Controller } //Rechnungskauf - /* if($payment_method[0]== 'fnc'){ + /* if($payment_method[0]=== 'fnc'){ $this->method = [ "clearingtype" => "fnc", "wallettype" => "", @@ -178,7 +178,22 @@ class PayoneController extends Controller */ } //vorkasse - if($payment_method == 'vor'){ + if($payment_method === 'elv'){ + $this->method = [ + "clearingtype" => "elv", + "wallettype" => "", + 'onlinebanktransfertype' => "", + "request" => "authorization", + "mandate_identification" => $ret['elv']['mandate_identification'], + "iban" => $ret['elv']['iban'], + "bic" => $ret['elv']['bic'], + "bankaccountholder" =>$ret['elv']['bankaccountholder'], + // "bankcountry" => "DE", + ]; + } + + //vorkasse + if($payment_method === 'vor'){ $this->method = [ "clearingtype" => "vor", "wallettype" => "", @@ -186,22 +201,19 @@ class PayoneController extends Controller "request" => "authorization", ]; } + //CreditCard - if($payment_method == 'cc'){ + if($payment_method === 'cc'){ //need the $cc_ret $this->method = [ "clearingtype" => "cc", "wallettype" => "", 'onlinebanktransfertype' => "", "request" => "authorization", - "pseudocardpan" => $cc_ret['pseudocardpan'] + "pseudocardpan" => $ret['cc']['pseudocardpan'] //"xid" => "3-D Secure transaction ID" ]; - } - - - } } @@ -209,14 +221,11 @@ class PayoneController extends Controller $request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls); - - - $response = Payone::sendRequest($request); /* * status APPROVED / REDIRECT / ERROR / PENDING */ - if($response['status'] == 'ERROR'){ + if($response['status'] === 'ERROR'){ PaymentTransaction::create([ 'shopping_payment_id' => $this->shopping_payment->id, 'request' => $this->method['request'], @@ -231,7 +240,7 @@ class PayoneController extends Controller } - if($response['status'] == 'REDIRECT'){ + if($response['status'] === 'REDIRECT'){ PaymentTransaction::create([ 'shopping_payment_id' => $this->shopping_payment->id, 'request' => $this->method['request'], @@ -244,7 +253,7 @@ class PayoneController extends Controller } - if($response['status'] == 'APPROVED'){ + if($response['status'] === 'APPROVED'){ // header("Location: " . $response["redirecturl"]); // or other redirect method $payt = PaymentTransaction::create([ 'shopping_payment_id' => $this->shopping_payment->id, @@ -255,18 +264,25 @@ class PayoneController extends Controller 'transmitted_data' => $response, ]); - if($payt->shopping_payment->clearingtype == "vor"){ + if($payt->shopping_payment->clearingtype === "vor"){ //vorkasse return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference])); exit; } - if($payt->shopping_payment->clearingtype == "cc"){ + if($payt->shopping_payment->clearingtype === "cc"){ //creditcard return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference])); exit; } + if($payt->shopping_payment->clearingtype === "elv"){ + //sepa + return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference])); + exit; + } + + var_dump($response); die(); //txid @@ -276,7 +292,7 @@ class PayoneController extends Controller } - if($response['status'] == 'PENDING'){ + if($response['status'] === 'PENDING'){ var_dump($response); die(); //txid @@ -308,6 +324,46 @@ class PayoneController extends Controller } + public function checkBankAccount($data, $amount, $currency, $shopping_user) + { + $this->shopping_user = $shopping_user; + $this->setPersonalData(); + + $this->prepayment = [ + "clearingtype" => "elv", + "amount" => $amount, // amount in smallest currency unit, i.e. cents + "currency" => $currency, + "request" => "managemandate", // create account receivable and instantly book the amount + "bankaccountholder" => $data['elv_bankaccountholder'], + "iban" => $data['elv_iban'], + "bic" => $data['elv_bic'], + + // "language" => 'de', + ]; + $request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls); + + + // dd($request); + return Payone::sendRequest($request); + + } + + + /* public function getPDFFile($mandateId) + { + + $params['file_reference'] = $mandateId;//"XX-T0000000"; + $params['file_type'] = 'SEPA_MANDATE'; + $params['file_format'] = 'PDF'; + $request = array_merge($this->default, $params); + + return Payone::sendRequest($request); + } + */ + + + + /* public function checkStatus(){ // again, the default values will be needed $capture = array( @@ -327,6 +383,20 @@ class PayoneController extends Controller //debit payment /* * + * + * $params['bankaccountholder'] = $paymentData['mopt_payone__debit_bankaccountholder']; + $params['iban'] = $this->removeWhitespaces($paymentData['mopt_payone__debit_iban']); + $params['bic'] = $this->removeWhitespaces($paymentData['mopt_payone__debit_bic']); + + * $params['bankcountry'] = $paymentData['mopt_payone__debit_bankcountry']; + $params['bankaccount'] = $this->removeWhitespaces($paymentData['mopt_payone__debit_bankaccount']); + $params['bankcode'] = $this->removeWhitespaces($paymentData['mopt_payone__debit_bankcode']); + + + if (Shopware()->Session()->moptMandateData) { + $params['mandate_identification'] = Shopware()->Session()->moptMandateData['mopt_payone__mandateIdentification']; + } + * * ["clearing_bankaccount"]=> string(10) "2599100003" ["clearing_bankcode"]=> string(8) "12345678" ["clearing_bankcountry"]=> string(2) "DE" diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php index ea0c6ff..4ce826c 100755 --- a/app/Http/Controllers/Web/CheckoutController.php +++ b/app/Http/Controllers/Web/CheckoutController.php @@ -129,27 +129,26 @@ class CheckoutController extends Controller //check credit Card if(Input::get('payment_method')){ - $cc_ret = []; + $ret = []; //need precheck the card - if(Input::get('payment_method') == 'cc'){ + if(Input::get('payment_method') === 'cc'){ $pay = new PayoneController(); - $cc_ret = $pay->checkCreditCard($data); - if($cc_ret['status'] == 'ERROR' || $cc_ret['status'] == 'INVALID'){ + $ret['cc'] = $pay->checkCreditCard($data); + if($ret['cc']['status'] === 'ERROR' || $ret['cc']['status'] === 'INVALID'){ /* PaymentTransaction::create([ 'shopping_payment_id' => //is no shopping_payment_id at this moment, 'request' => 'creditcardcheck, - 'errorcode' => $cc_ret['errorcode'], - 'errormessage' => $cc_ret['errormessage'], - 'customermessage' => $cc_ret['customermessage'], + 'errorcode' => $ret['cc']['errorcode'], + 'errormessage' => $ret['cc']['errormessage'], + 'customermessage' => $ret['cc']['customermessage'], 'status' => $response['status'], ]);*/ \Session::flash('cc-error', 1); - \Session::flash('errormessage', $cc_ret['errormessage']); - \Session::flash('customermessage', $cc_ret['customermessage']); + \Session::flash('errormessage', $ret['cc']['errormessage']); + \Session::flash('customermessage', $ret['cc']['customermessage']); return redirect(route('checkout.checkout_card'))->withInput(Input::all()); - exit; } - if($cc_ret['status'] == 'VALID'){ + if($ret['cc']['status'] === 'VALID'){ /* * array(4) { ["status"]=> string(5) "VALID" ["pseudocardpan"]=> string(19) "9410010000169020567" ["cardtype"]=> string(1) "V" ["truncatedcardpan"]=> string(16) "411111XXXXXX1111" } * application through http post @@ -158,11 +157,56 @@ class CheckoutController extends Controller } } + //need precheck the card + if(Input::get('payment_method') === 'elv' && is_null(Input::get('mandate_identification'))){ + $pay = new PayoneController(); + $amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100; + $ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user); + + if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){ + /* PaymentTransaction::create([ + 'shopping_payment_id' => //is no shopping_payment_id at this moment, + 'request' => 'creditcardcheck, + 'errorcode' => $ret['cc']['errorcode'], + 'errormessage' => $ret['cc']['errormessage'], + 'customermessage' => $ret['cc']['customermessage'], + 'status' => $response['status'], + ]);*/ + \Session::flash('elv-error', 1); + \Session::flash('errormessage', $ret['elv']['errormessage']); + \Session::flash('customermessage', $ret['elv']['customermessage']); + return redirect(route('checkout.checkout_card'))->withInput(Input::all()); + } + if($ret['elv']['status'] === 'APPROVED' && $ret['elv']['mandate_status'] !== "active"){ + dd($ret); + \Session::flash('elv-managemandate', 1); + \Session::flash('elv-mandate_identification', $ret['elv']['mandate_identification']); + \Session::flash('elv-mandate_text', $ret['elv']['mandate_text']); + \Session::flash('elv-creditor_identifier', $ret['elv']['creditor_identifier']); + return redirect(route('checkout.checkout_card'))->withInput(Input::all()); + + + /* + * array(4) { ["status"]=> string(5) "VALID" ["pseudocardpan"]=> string(19) "9410010000169020567" ["cardtype"]=> string(1) "V" ["truncatedcardpan"]=> string(16) "411111XXXXXX1111" } + * application through http post + * get this to the prepayment + * */ + } + $ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder']; + + } + if(Input::get('payment_method') === 'elv' && Input::get('mandate_identification')) { + $ret['elv']['mandate_identification'] = Input::get('mandate_identification'); + $ret['elv']['creditor_identifier'] = Input::get('creditor_identifier'); + $ret['elv']['iban'] = $data['iban']; + $ret['elv']['bic'] = $data['elv_bic']; + $ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder']; + } //other $pay = new PayoneController(); $pay->init($shopping_user, $shopping_order); - $amount = intval(floatval(Yard::instance('shopping')->totalWithShipping(2, '.', ',')) *100); - $reference = $pay->setPrePayment(Input::get('payment_method'), $amount, 'EUR', $cc_ret); + $amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100; + $reference = $pay->setPrePayment(Input::get('payment_method'), $amount, 'EUR', $ret); $this->putPayments('payment_reference', $reference); $pay->setPersonalData(); return $pay->ResponseData(); @@ -185,7 +229,7 @@ class CheckoutController extends Controller $ShoppingPayment->status = $status; $ShoppingPayment->save(); - if($status == "success"){ + if($status === "success"){ Yard::instance('shopping')->destroy(); $this->destroy(); @@ -199,12 +243,12 @@ class CheckoutController extends Controller ]; return view('web.templates.checkout-final', $data); } - if($status == "cancel"){ + if($status === "cancel"){ \Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.'); return redirect(route('checkout.checkout_card')); } - if($status == "error"){ + if($status === "error"){ \Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.'); return redirect(route('checkout.checkout_card')); diff --git a/public/images/payments-assets/sepa.png b/public/images/payments-assets/sepa.png new file mode 100644 index 0000000..cfb7e34 Binary files /dev/null and b/public/images/payments-assets/sepa.png differ diff --git a/public/images/payments-assets/sofort.png b/public/images/payments-assets/sofort.png index b07acd2..ec60c6f 100644 Binary files a/public/images/payments-assets/sofort.png and b/public/images/payments-assets/sofort.png differ diff --git a/resources/views/admin/lead/edit.blade.php b/resources/views/admin/lead/edit.blade.php index 8ee6688..0776a9c 100644 --- a/resources/views/admin/lead/edit.blade.php +++ b/resources/views/admin/lead/edit.blade.php @@ -59,7 +59,7 @@