Commit 982c7a10 authored by Andy J's avatar Andy J

Merge branch 'master' of gitlab.jtl-software.de:jtlshop/paypal

Conflicts:
	version/109/adminmenu/infos.php
	version/109/adminmenu/templates/infos.tpl
	version/109/frontend/css/style.css
	version/109/frontend/notify.php
	version/109/paymentmethod/class/PayPal.helper.class.php
	version/109/paymentmethod/class/PayPalBasic.class.php
	version/109/paymentmethod/class/PayPalExpress.class.php
	version/109/paymentmethod/class/PayPalFinance.class.php
parents 662cd782 fb04d5d9
# JTL-Shop PayPal Plugin Changelog
## [1.08]
**Ratenzahlung Powered by PayPal: Testphase erfolgreich abgeschlossen**
* TrustedShops Excellence-Integration in PayPal PLUS
* Sandbox-Bestellungen werden nun gesondert markiert (Anmerkung "SANDBOX-BESTELLUNG")
* Unterstützung des verkürzten Checkouts (JTL-Shop 4.06)
* Weitere Anzeigemöglichkeiten der Finanzierungsbox (Ratenzahlung Powered by PayPal)
* PayPal Express übernimmt Käufer-Telefonnummer
* Bugfix: Fehlerhafte Umlaute in Adressdaten (PayPal PLUS)
* Bugfix: Payment Wall wird nur in Sprache Deutsch dargestellt
* Bugfix: PayPal Express bei Einstellung (Warenkorb-Weiterleitung) ohne Funktion
* Bugfix: Aufpreise/Rabatte zuvor gewählter Zahlungsarten werden nicht entfernt
## [1.07]
* Zahlart "Rechnung (PayPal PLUS)" umbenannt in "Kauf auf Rechnung (PayPal PLUS)". Bitte in JTL-Wawi eine Zahlart mit identischer Bezeichnung hinterlegen, damit eine Zuordnung möglich ist.
......
......@@ -36,6 +36,9 @@
<Version nr="108">
<CreateDate>2017-05-05</CreateDate>
</Version>
<Version nr="109">
<CreateDate>2017-10-20</CreateDate>
</Version>
<Hooks>
<Hook id="6">6_7_jtl_paypal.php</Hook>
<Hook id="7">6_7_jtl_paypal.php</Hook>
......@@ -584,7 +587,7 @@ Best Regards
<ValueName>jtl_paypal_wk_headline</ValueName>
</Setting>
<Setting type="selectbox" initialValue="N" sort="2" conf="Y">
<Name>PayPal-Express-Button auf Warenkorbseite aktivieren?</Name>
<Name>Im Warenkorbseite aktivieren?</Name>
<Description>Kunde gelangt von Warenkorb-Seite direkt zu PayPal.</Description>
<ValueName>jtl_paypal_express_cart_button</ValueName>
<SelectboxOptions>
......@@ -633,7 +636,7 @@ Best Regards
<ValueName>jtl_paypal_article_headline</ValueName>
</Setting>
<Setting type="selectbox" initialValue="N" sort="11" conf="Y">
<Name>PayPal Express Button auf Artikeldetailseite aktivieren?</Name>
<Name>Button auf Artikeldetailseite aktivieren?</Name>
<Description>Kunde gelangt von Artikeldetailseite direkt zu PayPal.</Description>
<ValueName>jtl_paypal_express_article</ValueName>
<SelectboxOptions>
......@@ -650,6 +653,16 @@ Best Regards
<Option value="gold" sort="2">gold</Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="medium" sort="13" conf="Y">
<Name>Gre des Buttons</Name>
<Description />
<ValueName>jtl_paypal_express_article_button_size</ValueName>
<SelectboxOptions>
<Option value="small" sort="1">klein</Option>
<Option value="medium" sort="2">mittel</Option>
<Option value="large" sort="3">gro</Option>
</SelectboxOptions>
</Setting>
<Setting type="text" initialValue="#add-to-cart .form-inline, #article_buyfield" sort="13" conf="Y">
<Name>PHPQuery Selector</Name>
<Description />
......@@ -667,20 +680,103 @@ Best Regards
</SelectboxOptions>
</Setting>
<Setting type="text" initialValue="Y" sort="20" conf="N">
<Name>Sonstige Einstellungen</Name>
<Name>Einstellungen fr PayPal Button im Mini-Warenkorb</Name>
<Description />
<ValueName>jtl_paypal_sonstige_headline</ValueName>
<ValueName>jtl_paypal_cart_popup_headline</ValueName>
</Setting>
<Setting type="selectbox" initialValue="Y" sort="24" conf="Y">
<Name>Checkboxen aus Registrierungsseite auf Bestellbersichtsseite anzeigen</Name>
<Description>Sollen die Checkboxen aus der Registrierungsseite auf der Bestellbersichtsseite
angezeigt werden?</Description>
<ValueName>jtl_paypal_set_checkboxes</ValueName>
<Setting type="selectbox" initialValue="N" sort="21" conf="Y">
<Name>Button im Mini-Warenkorb aktivieren?</Name>
<Description>Kunde gelangt von Mini-Warenkorb direkt zu PayPal.</Description>
<ValueName>jtl_paypal_express_cart_popup</ValueName>
<SelectboxOptions>
<Option value="Y" sort="1">Ja</Option>
<Option value="N" sort="2">Nein</Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="silver" sort="22" conf="Y">
<Name>Art des Buttons</Name>
<Description />
<ValueName>jtl_paypal_express_cart_popup_button_type</ValueName>
<SelectboxOptions>
<Option value="silver" sort="1">silber</Option>
<Option value="gold" sort="2">gold</Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="medium" sort="23" conf="Y">
<Name>Gre des Buttons</Name>
<Description />
<ValueName>jtl_paypal_express_cart_popup_size</ValueName>
<SelectboxOptions>
<Option value="small" sort="1">klein</Option>
<Option value="medium" sort="2">mittel</Option>
<Option value="large" sort="3">gro</Option>
</SelectboxOptions>
</Setting>
<Setting type="text" initialValue=".cart-dropdown" sort="24" conf="Y">
<Name>PHPQuery Selector</Name>
<Description />
<ValueName>jtl_paypal_express_cart_popup_selector</ValueName>
</Setting>
<Setting type="selectbox" initialValue="after" sort="25" conf="Y">
<Name>PHPQuery Methode</Name>
<Description />
<ValueName>jtl_paypal_express_cart_popup_method</ValueName>
<SelectboxOptions>
<Option value="after" sort="1">after</Option>
<Option value="before" sort="2">before</Option>
<Option value="prepend" sort="3">prepend</Option>
<Option value="append" sort="4">append</Option>
</SelectboxOptions>
</Setting>
<Setting type="text" initialValue="Y" sort="30" conf="N">
<Name>Einstellungen fr PayPal Button im Bestellvorgang</Name>
<Description />
<ValueName>jtl_paypal_express_checkout_headline</ValueName>
</Setting>
<Setting type="selectbox" initialValue="N" sort="31" conf="Y">
<Name>Button auf Auswahlseite anzeigen?</Name>
<Description>(Ich bin bereits Kunde, als Neukunde fortfahren)</Description>
<ValueName>jtl_paypal_express_checkout</ValueName>
<SelectboxOptions>
<Option value="Y" sort="1">Ja</Option>
<Option value="N" sort="2">Nein</Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="silver" sort="32" conf="Y">
<Name>Art des Buttons</Name>
<Description />
<ValueName>jtl_paypal_express_checkout_button_type</ValueName>
<SelectboxOptions>
<Option value="silver" sort="1">silber</Option>
<Option value="gold" sort="2">gold</Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="medium" sort="33" conf="Y">
<Name>Gre des Buttons</Name>
<Description />
<ValueName>jtl_paypal_express_checkout_button_size</ValueName>
<SelectboxOptions>
<Option value="small" sort="1">klein</Option>
<Option value="medium" sort="2">mittel</Option>
<Option value="large" sort="3">gro</Option>
</SelectboxOptions>
</Setting>
<Setting type="text" initialValue="#order_register_or_login" sort="34" conf="Y">
<Name>PHPQuery Selector</Name>
<Description />
<ValueName>jtl_paypal_express_checkout_selector</ValueName>
</Setting>
<Setting type="selectbox" initialValue="after" sort="34" conf="Y">
<Name>PHPQuery Methode</Name>
<Description />
<ValueName>jtl_paypal_express_checkout_method</ValueName>
<SelectboxOptions>
<Option value="after" sort="1">after</Option>
<Option value="before" sort="2">before</Option>
<Option value="prepend" sort="3">prepend</Option>
<Option value="append" sort="4">append</Option>
</SelectboxOptions>
</Setting>
</Settingslink>
<Settingslink sort="3">
<Name>PayPal Ratenzahlung</Name>
......@@ -747,7 +843,7 @@ Best Regards
<Description />
<ValueName>jtl_paypal_finance_article_selector</ValueName>
</Setting>
<Setting type="selectbox" initialValue="after" sort="14" conf="Y">
<Setting type="selectbox" initialValue="prepend" sort="14" conf="Y">
<Name>PHPQuery Methode</Name>
<Description />
<ValueName>jtl_paypal_finance_article_method</ValueName>
......
......@@ -584,7 +584,7 @@ class PayPalFinance extends PaymentMethod
$payment = Payment::get($paymentId, $apiContext);
if ($payment->getState() != 'created') {
throw new Exception('Unhandled payment state', $payment->getState());
throw new Exception(sprintf('Unhandled payment state %s', $payment->getState()));
}
/*
......
......@@ -566,7 +566,7 @@ class PayPalPlus extends PaymentMethod
$payment = Payment::get($paymentId, $apiContext);
if ($payment->getState() != 'created') {
throw new Exception('Unhandled payment state', $payment->getState());
throw new Exception(sprintf('Unhandled payment state %s', $payment->getState()));
}
/*
......
......@@ -606,7 +606,7 @@ class PayPalFinance extends PaymentMethod
$payment = Payment::get($paymentId, $apiContext);
if ($payment->getState() != 'created') {
throw new Exception('Unhandled payment state', $payment->getState());
throw new Exception(sprintf('Unhandled payment state %s', $payment->getState()));
}
$this->patch($payment, $orderNumber, $_SESSION['Lieferadresse']);
......
......@@ -504,7 +504,7 @@ class PayPalPlus extends PaymentMethod
$payment = Payment::get($paymentId, $apiContext);
if ($payment->getState() != 'created') {
throw new Exception('Unhandled payment state', $payment->getState());
throw new Exception(sprintf('Unhandled payment state %s', $payment->getState()));
}
/*
......
......@@ -8,6 +8,32 @@
$tpls = ['checkout/step4_payment_options.tpl', 'tpl_inc/bestellvorgang_zahlung.tpl'];
if (in_array($args_arr['original'], $tpls) && Shop::Smarty()->get_template_vars('payPalPlus') === true) {
$args_arr['out'] = PFAD_ROOT . PFAD_PLUGIN . $oPlugin->cVerzeichnis . '/' . PFAD_PLUGIN_VERSION . $oPlugin->nVersion . '/' . PFAD_PLUGIN_FRONTEND . 'template/paypalplus.tpl';
}
\ No newline at end of file
if (in_array($args_arr['original'], $tpls, true) && Shop::Smarty()->getTemplateVars('payPalPlus') === true) {
// identify the template
//
$szTemplatePathParent = '';
$oTemplate = Template::getInstance();
$szParentName = $oTemplate->getParent();
if (null !== $szParentName || '' !== $szParentName) {
$szTemplatePathParent = PFAD_TEMPLATES . $szParentName . '/checkout/';
}
$szTemplatePathCurrent = PFAD_TEMPLATES . $oTemplate->getDir() . '/checkout/' ;
// try to find the trustedshops-snippet
//
$szPluginTemplatePath = PFAD_ROOT . PFAD_PLUGIN . $oPlugin->cVerzeichnis . '/' . PFAD_PLUGIN_VERSION . $oPlugin->nVersion . '/' . PFAD_PLUGIN_FRONTEND . 'template/';
$szTrustedShopsTplSnippet = 'inc_payment_trustedshops.tpl';
$ts_tpl = null;
if (file_exists(PFAD_ROOT . $szTemplatePathCurrent . $szTrustedShopsTplSnippet)) {
$ts_tpl = $szTemplatePathCurrent . $szTrustedShopsTplSnippet;
} elseif (file_exists(PFAD_ROOT . $szTemplatePathParent . $szTrustedShopsTplSnippet)) {
$ts_tpl = $szTemplatePathParent . $szTrustedShopsTplSnippet;
} elseif (file_exists($szPluginTemplatePath . $szTrustedShopsTplSnippet)) {
$ts_tpl = $szTrustedShopsTplSnippet;
}
Shop::Smarty()->assign('ts_tpl', $ts_tpl);
$args_arr['out'] = $szPluginTemplatePath . 'paypalplus.tpl';
}
......@@ -27,7 +27,7 @@
width: 100%;
position: absolute;
z-index: 10;
background-color: rgba(255,255,255,0.5);
background-color: rgba(255,255,255,0.5);
}
#pp-plus .spinner .spinWrap {
......@@ -50,8 +50,8 @@
}
#pp-plus {
/*min-height: 248px;*/
position: relative;
/*min-height: 248px;*/
position: relative;
}
#pp-loading-body {
......@@ -63,8 +63,8 @@
* paypal express
*/
button.paypalexpress {
padding: 0;
margin-top: 15px;
padding: 0;
margin-top: 15px;
background: none;
border: 0;
}
......@@ -84,7 +84,7 @@ a.paypalexpress {
.ppf-container {
color: #333;
border: 2px solid rgb(0,156,222);
border: 1px solid #d1d1d1;
display: block;
padding: 10px;
......@@ -102,16 +102,11 @@ a.paypalexpress {
font-family: "Merriweather", Georgia, "Times New Roman", Times, serif;
}
.ppf-container p {
margin-bottom: 0px;
}
.ppf-container a.show-details {
font-size: 95%;
color: rgb(0,156,222);
font-size: 100%;
margin: 2px 0 0 0;
display: block;
text-align: center;
display: block;
text-align: center;
}
.ppf-container a.show-details:hover {
......@@ -123,18 +118,19 @@ a.paypalexpress {
margin-top: 10px;
}
.legal-info {
opacity: 0.9;
font-size: 85%;
.ppf-container .lender,
.ppf-container .legal-info {
opacity: 0.9;
font-size: 85%;
}
.table-financing-option {
margin: 10px 0;
font-size: 90%;
font-size: 90%;
}
.ppf-details .table-financing-option {
font-size: 100%;
font-size: 100%;
}
.table-financing-option:hover,
......
......@@ -11,11 +11,31 @@
};
PayPal.prototype = {
ppplus: 'https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js',
constructor: PayPal,
init: function (options) {
this.options = $.extend({}, { selector: '' }, options);
this.options = $.extend({}, { selector: '' }, options || {});
},
loadPaymentWall: function(loaded) {
if (typeof PAYPAL != 'undefined') {
return (typeof loaded == 'function') ? loaded() : true;
}
this.getScript(this.ppplus).done(function() {
var validate = function() {
if (typeof PAYPAL == 'undefined') {
window.setTimeout(function() {
validate();
}, 100);
}
else if (typeof loaded == 'function') {
loaded();
}
}
validate();
});
},
getInstallments: function (amount, currency) {
......@@ -24,6 +44,14 @@
$(data.options.selector)
.replaceWith(data.response);
});
},
getScript: function (url, options) {
return jQuery.ajax($.extend(options || {}, {
dataType: "script",
cache: true,
url: url
}));
}
};
......@@ -35,8 +63,7 @@
window.paypal = jtl_paypal;
}
$(document).on("evo:changed.price.article", function(e, result) {
var price = result.fGesamtpreis[result.nNettoPreise];
$(document).on("evo:changed.price.article", function(e, price) {
paypal({ selector: '.ppf-loader' }).getInstallments(price);
});
})(jQuery);
{if !empty($hinweis)}
<div class="alert alert-danger">{$hinweis}</div>
{/if}
{assign var="ts_tpl" value=""}
{assign var="plugin_tpl" value=$smarty.current_dir|cat:"/inc_payment_trustedshops.tpl"}
{if file_exists("templates/Evo/checkout/inc_payment_trustedshops.tpl")}
{* exists only since shop 4.06 in the Evo-template *}
{assign var="ts_tpl" value="templates/Evo/checkout/inc_payment_trustedshops.tpl"}
{elseif file_exists($plugin_tpl)}
{assign var="ts_tpl" value=$plugin_tpl}
{/if}
<div class="row">
<div class="col-xs-12">
<div class="panel-wrap">
......@@ -22,7 +13,7 @@
</div>
</fieldset>
{if $embedded}
{if $ts_tpl !== ""}
{if not empty($ts_tpl)}
{include file=$ts_tpl}
{/if}
<input id="ppp-submit" type="submit" value="{lang key="continueOrder" section="account data"}" class="btn btn-primary submit btn-lg pull-right" />
......@@ -61,7 +52,7 @@
{/foreach}
</ul>
{if $ts_tpl !== ""}
{if not empty($ts_tpl)}
{include file=$ts_tpl}
{/if}
......@@ -87,11 +78,14 @@
</div>
<script type="text/javascript">
jtl.load('https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js');
var submit = '#ppp-submit';
var payments = 'input[name="Zahlungsart"]';
var tsProduct = null;
{if isset($oTrustedShops) && isset($oTrustedShops->oKaeuferschutzProdukte)}
tsProduct = '{$oTrustedShops->oKaeuferschutzProdukte->item[0]->tsProductID}';
{/if}
var ppConfig = {ldelim}
approvalUrl: "{$approvalUrl}",
placeholder: "ppp-container",
......@@ -114,7 +108,6 @@ var ppConfig = {ldelim}
showLoadingIndicator: true,
language: "{$language}",
country: "{$country}",
surcharging: true,
onContinue: function() {ldelim}
if (ppIsThirdParty()) {ldelim}
if (paymentMethod = ppGetThirdPartyMethod(ppp.getPaymentMethod())) {ldelim}
......@@ -167,13 +160,14 @@ var ppGetTrustedShops = function() {ldelim}
if ($('input[name="bTS"]:checked').length > 0) {ldelim}
return $('[name="cKaeuferschutzProdukt"]').val()
? $('[name="cKaeuferschutzProdukt"]').val()
: '{$oTrustedShops->oKaeuferschutzProdukte->item[0]->tsProductID}';
: tsProduct;
{rdelim}
return null;
{rdelim};
var ppGetThirdPartyMethod = function(name) {ldelim}
for (var payment of ppConfig.thirdPartyPaymentMethods) {ldelim}
for (var p in ppConfig.thirdPartyPaymentMethods) {ldelim}
var payment = ppConfig.thirdPartyPaymentMethods[p];
if (payment.methodName === name)
return payment;
{rdelim}
......@@ -187,25 +181,27 @@ var ppActive = function() {ldelim}
var ppp = null;
$(document).ready(function() {ldelim}
try {ldelim}
ppp = PAYPAL.apps.PPP(ppConfig);
$(submit).click(function() {ldelim}
if (!ppActive()) {ldelim}
return true;
}
ppp.doContinue();
return false;
{rdelim});
$(payments).change(function() {ldelim}
ppp.deselectPaymentMethod();
{rdelim});
{rdelim}
catch (e) {ldelim}
if (console) {ldelim}
console.error(e.message);
paypal().loadPaymentWall(function() {ldelim}
try {ldelim}
ppp = PAYPAL.apps.PPP(ppConfig);
$(submit).click(function() {ldelim}
if (!ppActive()) {ldelim}
return true;
}
ppp.doContinue();
return false;
{rdelim});
$(payments).change(function() {ldelim}
ppp.deselectPaymentMethod();
{rdelim});
{rdelim}
catch (e) {ldelim}
if (console) {ldelim}
console.error(e.message);
{rdelim}
{rdelim}
{rdelim}
{rdelim});
{rdelim});
</script>
......@@ -6,14 +6,12 @@
{*if $bcf->getApr() > 0 jtl_paypal_finance_box_details *}
{if isset($plugin->oPluginEinstellungAssoc_arr['jtl_paypal_finance_box_details']) && $plugin->oPluginEinstellungAssoc_arr['jtl_paypal_finance_box_details'] === 'Y'}
<div class="ppf-container">
<div class="ppf-container hidden-sm">
<p class="rate-info">
Finanzierung ab <span class="price">{gibPreisStringLocalized($bmp->getValue())}</span> in {$bcf->getTerm()} monatlichen Raten
mit Ratenzahlung Powered by PayPal.
</p>
<p class="legal-info">Repr&auml;sentatives Beispiel gem. � 6a PAngV</p>
<p class="legal-info">Repr&auml;sentatives Beispiel gem. &sect; 6a PAngV</p>
<table class="table table-condensed table-financing-option">
<tbody>
<tr>
......@@ -40,13 +38,15 @@
</tr>
</tfoot>
</table>
{if $company}
<p class="lender">Darlehensgeber: {$company->cName}, {$company->cStrasse}, {$company->cPLZ} {$company->cOrt}</p>
{/if}
<a href="#ppf-modal-{$modal}" data-toggle="modal" data-target="#ppf-modal-{$modal}" class="show-details">
<i class="fa fa-exclamation-circle" aria-hidden="true"></i> Informationen zu m&ouml;glichen Raten
</a>
</div>
{else}
<div class="ppf-container">
<div class="ppf-container hidden-sm">
<p class="rate-info text-center">Finanzierung ab <span class="price">{gibPreisStringLocalized($bmp->getValue())}</span> im Monat.</p>
<a href="#ppf-modal-{$modal}" data-toggle="modal" data-target="#ppf-modal-{$modal}" class="show-details">
......
<div class="ppf-details">
<div class="legal text-center">
<div class="sample">
<i class="ppf-star"></i> Zugleich repr&auml;sentatives Beispiel gem. 6a PAngV
<div>
{if $company}
<div class="loan">Darlehensgeber: {$company->cName}, {$company->cStrasse}, {$company->cPLZ} {$company->cOrt}</div>
{/if}
</div>
<div class="ppf-details">
<div class="legal text-center">
<div class="sample">
<i class="ppf-star"></i> Zugleich repr&auml;sentatives Beispiel gem. &sect; 6a PAngV
<div>
{if $company}
<div class="lender">Darlehensgeber: {$company->cName}, {$company->cStrasse}, {$company->cPLZ} {$company->cOrt}</div>
{/if}
</div>
</div>
\ No newline at end of file
<div class="ppf-details">
<div class="info">
<p class="title">Zahlen Sie bequem und einfach in monatlichen Raten</p>
<p class="desc">
Ihre Ratenzahlung und den passenden Finzanzierungsplan k&ouml;nnen Sie im Rahmen des Bestellprozesses ausw&auml;hlen.<br/>
Ihre Anfrage erfolgt komplett online und wird in wenigen Schritten hier im Shop abgeschlossen.
</p>
<p class="loan">Nettodarlehensbetrag: <span class="price">{gibPreisStringLocalized($transactionAmount->getValue())}</span></p>
</div>
{$col = 12}
{if count($financingOptions) > 1}
{$col = 6}
{/if}
<div class="row row-eq-height">
{foreach $financingOptions as $fo}
<div class="col-md-{$col}">
<div class="table-responsive">
{include file="{$plugin->cFrontendPfad}template/presentment-table.tpl" financingOption=$fo}
</div>
</div>
{/foreach}
</div>
<div class="ppf-details">
<div class="info">
<p class="title">Zahlen Sie bequem und einfach in monatlichen Raten</p>
<p class="desc">
Ihre Ratenzahlung und den passenden Finzanzierungsplan k&ouml;nnen Sie im Rahmen des Bestellprozesses ausw&auml;hlen.<br/>
Ihre Anfrage erfolgt komplett online und wird in wenigen Schritten hier im Shop abgeschlossen.
</p>
<p class="loan">Nettodarlehensbetrag: <span class="price">{gibPreisStringLocalized($transactionAmount->getValue())}</span></p>
</div>
{$col = 12}
{if count($financingOptions) > 1}
{$col = 6}
{/if}
<div class="row row-eq-height">
{foreach $financingOptions as $fo}
<div class="col-md-{$col}">
<div class="table-responsive">
{include file="{$plugin->cFrontendPfad}template/presentment-table.tpl" financingOption=$fo}
</div>
</div>
{/foreach}
</div>
</div>
\ No newline at end of file
......@@ -199,7 +199,7 @@ class PayPalBasic extends PaymentMethod
return $this;
}
public function setExpressCheckout($helper)
public function setExpressCheckout($helper, $return = false)
{
$order = $helper->getObject();
$basket = PayPalHelper::getBasket($helper);
......@@ -257,7 +257,7 @@ class PayPalBasic extends PaymentMethod
} else {
$hash = $this->generateHash($order);
$setExpressCheckoutRequestDetails->ReturnURL = $this->getNotificationURL($hash);
$setExpressCheckoutRequestDetails->CancelURL = $this->getReturnURL($order);
$setExpressCheckoutRequestDetails->CancelURL = $order->BestellstatusURL;
}
$setExpressCheckoutRequestDetails->BrandName = $brandName;
......@@ -292,7 +292,15 @@ class PayPalBasic extends PaymentMethod
if (isset($response->Ack) && $response->Ack === 'Success') {
$redirect = $this->getApiUrl($response->Token);
$this->addCache('token', $response->Token);
if ($return) {
return $redirect;
}
} else {
if ($return) {
return null;
}
$r = $exception !== null ? $exception->getMessage() : print_r($response, true);
$this->doLog("Error: SetExpressCheckout:\n\n<pre>{$r}</pre>", LOGLEVEL_ERROR);
......@@ -400,6 +408,7 @@ class PayPalBasic extends PaymentMethod
'cHinweis' => $paymentInfo->TransactionID,
]);
$this->setOrderStatusToPaid($pseudo);
$this->sendConfirmationMail($order);
}
if ($this->duringCheckout() === false) {
......@@ -453,7 +462,8 @@ class PayPalBasic extends PaymentMethod
$helper = new BestellungHelper($order);
if ($this->duringCheckout() === false) {
$this->setExpressCheckout($helper);
$redirect = $this->setExpressCheckout($helper, true);
Shop::Smarty()->assign('redirect', $redirect);
} else {
$this->doExpressCheckoutPayment($helper);
}
......
......@@ -732,7 +732,7 @@ class PayPalFinance extends PaymentMethod
$this->logResult('ExecutePayment', $execution, $payment);
if ($payment->getState() !== 'approved') {
throw new Exception('Unhandled payment state', $payment->getState());
throw new Exception(sprintf('Unhandled payment state %s', $payment->getState()));
}
$sale = $payment->getTransactions()[0]
......
{*
<div id="paypal-basic-redirect">
<h3 class="no-margin">{lang key='paypalBtn' section='checkout'}</h3>
<p class="text-muted">{lang key='redirect'}</p>
</div>
*}
\ No newline at end of file
{if $redirect}
<div id="paypal-basic-redirect">
<p class="text-muted">{lang key='redirect'}</p>
<script type="text/javascript">
$(function() {
window.location.href = {$redirect|json_encode};
});
</script>
</div>