Skip to content

Commit

Permalink
Merge pull request #494 from BoulangerV/MAGE-536-Release_Fix_AmzPay
Browse files Browse the repository at this point in the history
MAGE-536: Fix AmzPay button event
  • Loading branch information
janteuber authored Jun 6, 2024
2 parents f9388a6 + ada8fbe commit 7934441
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function getResultLifetime()
*/
public function getResultLifetimeInSeconds()
{
return $this->result_lifetime * 24 * 3600;
return (is_int($this->result_lifetime) ? $this->result_lifetime : 0) * 24 * 3600;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function _construct()
public function getByOrder(Mage_Sales_Model_Order $order)
{
$this->addFieldToFilter('order_id', $order->getId());
if ($order->getData('increment_id') != 0) {
$this->addFilter('reference', $order->getData('increment_id'), 'or');
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function confirmSelection($params)
$this->quote->getPayment()->importData([
'method' => $paymentMethodCode,
'payone_config_payment_method_id' => $this->config->getId(),
'checks' => [],
'checks' => 0,
]);

$this->quote->setTotalsCollectedFlag(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function savePayment($data)
// | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
// | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;

$data['checks'] = array();
$data['checks'] = 0;

$payment = $this->_quote->getPayment();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ public function indexAction()
// Handle Request:
$response = $service->handleByPost();

/**
* MAGE-536 : Fix missing OrderId and StoreId in TxStatus when reference exists
*/
if ($response->getStatus() == 'TSOK') {
/** @var $transactionStatusCollection Payone_Core_Model_Domain_Resource_Protocol_TransactionStatus_Collection */
$transactionStatusCollection = Mage::getModel('payone_core/domain_protocol_transactionStatus')
->getCollection();
$transactionStatusCollection->getItemsByColumnValue('reference', $reference);

/** @var Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus */
foreach ($transactionStatusCollection as $transactionStatus) {
if (empty($transactionStatus->getOrderId())) {
$transactionStatus->setOrderId($order->getId());
}
if (empty($transactionStatus->getStoreId())) {
$transactionStatus->setStoreId($order->getStoreId());
}
$transactionStatus->save();
}
}

// NEW forwarding handling
$this->_forwardStatus($order);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ $getOnlineBankTransferType = $this->onlineBankTransferTypeMapping();

<input type="hidden" id="<?php echo $code ?>_obt_type" name="payment[payone_onlinebanktransfer_type]"
value="<?php echo $getOnlineBankTransferType[$code]; ?>" class=""/>
<input type="hidden" name="payment[payone_config_payment_method_id]"
id="<?php echo $code ?>_config_id" value="<?php echo $paymentConfigId; ?>"/>
<input type="hidden" id="<?php echo $code ?>_config_id" name="payment[payone_config_payment_method_id]"
value="<?php echo $paymentConfigId; ?>"/>
<input type="hidden" id="<?php echo $code ?>_pnt_show_iban"
value="<?php echo $this->showSofortUeberweisungBankDataFields(); ?>"/>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,16 @@ if ($paymentConfigId == 0) {
<?php endif; ?>
<li>
<input type="hidden" name="payment[payone_config_payment_method_id]"
value="<?php echo $paymentConfigId; ?>" />
<input type="hidden" name="payment[payone_onlinebanktransfer_type]"
id="<?php echo $code ?>_config_id" value="<?php echo $paymentConfigId; ?>" />
<input type="hidden" id="<?php echo $code ?>_obt_type" name="payment[payone_onlinebanktransfer_type]"
value="<?php echo $onlineBankTransferType ?>" />
</li>
<script type="text/javascript">
let trlPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_trustly") || $('p_method_payone_online_bank_transfer_trustly');
trlPaymentMethodContainer.on("click", function (event) {
onlineBankTransferTypeSwitch('<?php echo $code ?>');
});
</script>
</ul>
</fieldset>

Expand Down
13 changes: 11 additions & 2 deletions js/payone/core/amazonpay.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,24 @@ window.onDocumentReady = function () {

$('confirmSelection').onclick = function (event) {
event.preventDefault();
window.onCheckoutProgress(event.currentTarget);
if (event.currentTarget != null) {
window.onCheckoutProgress(event.currentTarget);
} else {
window.onCheckoutProgress(event.target);
}
};
$('placeOrder').onclick = function (event) {
event.preventDefault();
OffAmazonPayments.initConfirmationFlow(
PayoneCheckout.amazonSellerId,
PayoneCheckout.amazonOrderReferenceId,
function(confirmationFlow) {
placeOrder(event.currentTarget, confirmationFlow);
if (event.currentTarget != null) {
placeOrder(event.currentTarget, confirmationFlow);
} else {
placeOrder(event.target, confirmationFlow);
}

}
);
};
Expand Down
55 changes: 53 additions & 2 deletions js/payone/core/onlinebanktransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
var giropayPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_giropay") || $('p_method_payone_online_bank_transfer_giropay');
var pffPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_pff") || $('p_method_payone_online_bank_transfer_pff');
var sofortPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_sofortueberweisung") || $('p_method_payone_online_bank_transfer_sofortueberweisung');

var p24PaymentMethodContainer = $("dt_method_payone_online_bank_transfer_p24") || $('p_method_payone_online_bank_transfer_p24');
var pfcPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_pfc") || $('p_method_payone_online_bank_transfer_pfc');
var bctPaymentMethodContainer = $("dt_method_payone_online_bank_transfer_bct") || $('p_method_payone_online_bank_transfer_bct');


function enableBankGroupNl() {
Expand Down Expand Up @@ -100,6 +102,7 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
if(epsPaymentMethodContainer) {
epsPaymentMethodContainer.on("click", function (event) {
disableAll();
onlineBankTransferTypeSwitch(methodCode);
enableBankGroupAt();
});
}
Expand All @@ -108,6 +111,7 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
if (idlPaymentMethodContainer) {
idlPaymentMethodContainer.on("click", function (event) {
disableAll();
onlineBankTransferTypeSwitch(methodCode);
enableBankGroupNl();
});
}
Expand All @@ -116,6 +120,7 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
if (giropayPaymentMethodContainer) {
giropayPaymentMethodContainer.on("click", function (event) {
disableAll();
onlineBankTransferTypeSwitch(methodCode);
enableSepaIban();
enableSepaBic();
});
Expand All @@ -127,6 +132,7 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
if(pffPaymentMethodContainer){
pffPaymentMethodContainer.on("click", function (event) {
disableAll();
onlineBankTransferTypeSwitch(methodCode);
});
}
}
Expand All @@ -135,6 +141,7 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
if(sofortPaymentMethodContainer){
sofortPaymentMethodContainer.on("click", function (event) {
disableAll();
onlineBankTransferTypeSwitch(methodCode);
if (sofortueberweisungShowIban.value == 1) {
enableSepaIban();
enableSepaBic();
Expand All @@ -148,8 +155,31 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,
}
}

if (typeCode === 'PFC' || typeCode === 'P24' || typeCode === 'BCT') {
if (typeCode == 'P24') {
disableAll();
if(p24PaymentMethodContainer) {
p24PaymentMethodContainer.on("click", function (event) {
onlineBankTransferTypeSwitch(methodCode);
});
}
}

if (typeCode == 'PFC') {
disableAll();
if(pfcPaymentMethodContainer) {
pfcPaymentMethodContainer.on("click", function (event) {
onlineBankTransferTypeSwitch(methodCode);
});
}
}

if (typeCode == 'BCT') {
disableAll();
if(bctPaymentMethodContainer) {
bctPaymentMethodContainer.on("click", function (event) {
onlineBankTransferTypeSwitch(methodCode);
});
}
}

function disableAll() {
Expand Down Expand Up @@ -181,6 +211,27 @@ function payoneSwitchOnlineBankTransfer(typeCode, methodCode, element, country,

}

function onlineBankTransferTypeSwitch(methodCode) {
let btTypeInputs = document.getElementsByName('payment[payone_onlinebanktransfer_type]');
let btMethodInputs = document.getElementsByName('payment[payone_config_payment_method_id]');

btTypeInputs.forEach(function (element) {
if (element.id === methodCode + '_obt_type') {
element.removeAttribute("disabled");
} else {
element.setAttribute("disabled", "disabled");
}
});

btMethodInputs.forEach(function (element) {
if (element.id === methodCode + '_config_id') {
element.removeAttribute("disabled");
} else {
element.setAttribute("disabled", "disabled");
}
});
}

function copyOnlineBankTransferSepaIban(code) {
var input_sepa_iban_xxx_el = $(code + '_sepa_iban_xxx');
var input_sepa_iban_el = $(code + '_sepa_iban');
Expand Down
12 changes: 12 additions & 0 deletions js/payone/core/opcheckoutmod.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ if (Review) {
return superMethod(transport);
});
}

if (Payment) {
Payment.prototype.addAfterInitFunction('fcpoVisibleSelectedMethod', function() {
let methodsSelectors = document.getElementsByName('payment[method]');

methodsSelectors.forEach(function(input){
if (input.checked) {
input.click();
}
});
});
}
12 changes: 12 additions & 0 deletions js/payone/core/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,16 @@ function changeSubmitButtonStatus(checkboxEl)
$$('.btn-checkout')[0].setAttribute("disabled", "disabled");
$$('.btn-checkout')[0].hide();
}
}

/**
* @param elem
*/
function enableElement(elem) {
if (elem == undefined) {
return;
}

elem.disabled = false;
elem.removeClassName('disabled');
}

0 comments on commit 7934441

Please sign in to comment.