Commit afe7608d authored by Andy J's avatar Andy J

p2

parent 9c139a1f
......@@ -190,3 +190,8 @@ if ($oPlugin->oPluginEinstellungAssoc_arr['jtl_paypal_express_cart_popup'] === '
}
}
}
if ($pageType === PAGE_BESTELLVORGANG && $GLOBALS['step'] === 'Bestaetigung') {
$tpl = $smarty->fetch($oPlugin->cFrontendPfad . 'template/inc_order_confirmation.tpl');
pq('body')->append($tpl);
}
\ No newline at end of file
......@@ -24,6 +24,8 @@ if (isset($_GET['return']) && $_GET['return'] === '1') {
$conf = Shop::getConfig([CONF_KUNDEN]);
$response = $paypal->GetExpressCheckoutDetails($_SESSION['reshash']['Token']);
unset($_SESSION['Versandart'], $_SESSION['AktiveVersandart']);
$_SESSION['reshash']['Token'] = $response->Token;
$_SESSION['reshash']['Payer'] = $response->PayerInfo->Payer;
$_SESSION['reshash']['PayerID'] = $response->PayerInfo->PayerID;
......
......@@ -8,6 +8,7 @@ error_reporting(0);
ini_set('display_errors', 0);
require_once realpath(dirname(__FILE__) . '/../paymentmethod/class') . '/PayPalPlus.class.php';
require_once PFAD_ROOT.PFAD_INCLUDES.'bestellabschluss_inc.php';
use PayPal\Api\Error;
use PayPal\Api\Payment;
......@@ -136,8 +137,19 @@ switch ($action) {
$payment = Payment::get($_GET['id'], $apiContext);
$patchRequest = new \PayPal\Api\PatchRequest();
$orderNumber = baueBestellnummer();
$api->addCache('orderNumber', $orderNumber);
/*
$patchOrderNumber = new \PayPal\Api\Patch();
$patchOrderNumber->setOp('add')
->setPath('(/transactions/0/invoice_number')
->setValue($orderNumber);
$patchRequest->addPatch($patchOrderNumber);
*/
$patchBilling = new \PayPal\Api\Patch();
$patchBilling->setOp('add')
->setPath('(/potential_payer_info/billing_address')
->setPath('/potential_payer_info/billing_address')
->setValue($billingAddress);
$patchRequest->addPatch($patchBilling);
......@@ -201,7 +213,7 @@ switch ($action) {
$success = isset($_GET['r']) && $_GET['r'] === 'true';
if (!$success) {
$this->doLog("PayPal redirect (user Canceled)", LOGLEVEL_NOTICE);
$api->doLog("PayPal redirect (user canceled)", LOGLEVEL_NOTICE);
_redirect('bestellvorgang.php?editZahlungsart=1');
}
......@@ -215,8 +227,7 @@ switch ($action) {
$validArgs = array_filter($args);
if (count($args) !== count($validArgs)) {
$argStr = $this->formatObject((object)$args);
$this->doLog("PayPal redirect (missing arguments)\n{$argStr}", LOGLEVEL_ERROR);
$api->logResult("PayPal redirect (missing arguments)", (object)$args);
_redirect('bestellvorgang.php?editZahlungsart=1');
}
......@@ -227,6 +238,8 @@ switch ($action) {
try {
$payment = Payment::get($validArgs['paymentId'], $apiContext);
$api->addCache('payment', $payment->toJson());
$api->createPaymentSession();
_redirect('bestellvorgang.php');
......
<div class="modal modal-center fade" id="ppp-modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-body">
<h2 id="pp-loading-body"><i class="fa fa-spinner fa-spin fa-fw"></i> Ihre Bestellung wird abgeschlossen</h2>
</div>
</div>
</div>
</div>
<script>
$(function() {
var submitted = false;
// $(window).bind('unload', function (e) { console.log('unload'); return false; });
//$(window).bind('beforeunload', function (e) { console.log('beforeunload', submitted); return submitted; });
$('#complete_order').on('submit', function() {
submitted = true;
$(this).find('input[type="submit"]')
.addClass('disabled')
.attr('disabled', true);
$('#ppp-modal').modal({
backdrop: 'static'
});
$('#ppp-modal').modal('show');
return true;
});
});
</script>
\ No newline at end of file
......@@ -733,7 +733,7 @@ class PayPalHelper
* @param $szPaymentDesc string to shorten
* @return string string of length 'nLimit'
*/
function shortenPaymentName($szPaymentDesc) {
public static function shortenPaymentName($szPaymentDesc) {
$nLimit = 25; // hard limit of the payment-wall (should not be altered)
$nLastShownChars = 0; // (maybe 3 looks good)
$szPlaceHolder = '...';
......
......@@ -326,6 +326,7 @@ class PayPalExpress extends PaymentMethod
public function preparePaymentProcess($order)
{
$basket = PayPalHelper::getBasket();
$helper = new WarenkorbHelper();
$doExpressCheckoutPaymentReq = new PayPalAPI\DoExpressCheckoutPaymentReq();
$doExpressCheckoutPaymentRequestDetails = new \PayPal\EBLBaseComponents\DoExpressCheckoutPaymentRequestDetailsType();
......@@ -346,6 +347,19 @@ class PayPalExpress extends PaymentMethod
$paymentDetails->Custom = $order->kBestellung;
$paymentDetails->NotifyURL = $this->oPlugin->cFrontendPfadURLSSL . 'notify.php?type=express';
$sAddress = $helper->getShippingAddress();
$shippingAddress = new \PayPal\EBLBaseComponents\AddressType();
$shippingAddress->Name = "{$sAddress->cVorname} {$sAddress->cNachname}";
$shippingAddress->Street1 = "{$sAddress->cStrasse} {$sAddress->cHausnummer}";
$shippingAddress->Street2 = @$sAddress->cAdressZusatz;
$shippingAddress->CityName = $sAddress->cOrt;
$shippingAddress->StateOrProvince = PayPalHelper::getState($sAddress);
$shippingAddress->Country = $sAddress->cLand;
$shippingAddress->PostalCode = $sAddress->cPLZ;
$paymentDetails->ShipToAddress = utf8_convert_recursive($shippingAddress);
$doExpressCheckoutPaymentRequestDetails->PaymentDetails = [$paymentDetails];
$doExpressCheckoutPaymentRequest = new PayPalAPI\DoExpressCheckoutPaymentRequestType($doExpressCheckoutPaymentRequestDetails);
$doExpressCheckoutPaymentReq->DoExpressCheckoutPaymentRequest = $doExpressCheckoutPaymentRequest;
......
......@@ -540,15 +540,15 @@ class PayPalPlus extends PaymentMethod
public function preparePaymentProcess($order)
{
try {
$lastOrderId = $this->getCache('lastOrderId');
$orderNumber = (int)$this->getCache('orderNumber');
$paymentId = $this->getCache('paymentId');
$paymentData = $this->getCache('payment');
$payerId = $this->getCache('payerId');
if (empty($paymentId) || empty($payerId)) {
// payment related information already deleted (multiply order submission)
// order already saved?
$payment = new Payment($paymentData);
// order exists in database?
if (intval($lastOrderId) > 0) {
$lastOrder = new Bestellung($lastOrderId);
$lastOrder->fuelleBestellung(false);
......@@ -558,9 +558,10 @@ class PayPalPlus extends PaymentMethod
header("location: {$returnUrl}");
}
}
// payment related information already deleted (multiply order submission)
if (empty($paymentId) || empty($payerId)) {
$str = json_encode($this->getCache());
throw new Exception(sprintf('Missing payment/payer id, %s (%s)', $str, $this->moduleID));
}
......@@ -569,15 +570,14 @@ class PayPalPlus extends PaymentMethod
$basket = PayPalHelper::getBasket($helper);
$apiContext = $this->getContext();
$payment = Payment::get($paymentId, $apiContext);
// $payment = Payment::get($paymentId, $apiContext);
if ($payment->getState() != 'created') {
if (!in_array($payment->getState(), ['created', 'approved'])) {
throw new Exception(sprintf('Unhandled payment state "%s"', $payment->getState()));
}
$orderNumber = baueBestellnummer();
$this->patch($payment, $orderNumber);
// Create payment request
if ($payment->getState() == 'created') {
$execution = new PaymentExecution();
$execution->setPayerId($payerId);
......@@ -595,12 +595,12 @@ class PayPalPlus extends PaymentMethod
$transaction = new Transaction();
$transaction->setAmount($amount);
//->setInvoiceNumber($orderNumber) // #437
$execution->addTransaction($transaction);
$payment->execute($execution, $apiContext);
$this->logResult('ExecutePayment', $execution, $payment);
}
$order = finalisiereBestellung($orderNumber, true);
$order->cSession = $paymentId;
......@@ -648,8 +648,7 @@ class PayPalPlus extends PaymentMethod
$order->updateInDB();
if ($payment->getState() === 'approved')
{
if ($payment->getState() === 'approved') {
try {
$state = $payment->getTransactions()[0]
->getRelatedResources()[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment