Skip to content

Commit 24070b2

Browse files
masonmason
mason
authored and
mason
committed
Merge branch 'dev-v2.1-master' into v2.1-master
2 parents 2a573d7 + 38a32a9 commit 24070b2

File tree

6 files changed

+101
-14
lines changed

6 files changed

+101
-14
lines changed

Observer/PWObserver.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,25 @@ public function execute(\Magento\Framework\Event\Observer $observer)
2424
$order = $observer->getEvent()->getOrder();
2525
$paymentMethod = $order->getPayment()->getMethod();
2626
if (($paymentMethod == self::PWLOCAL_METHOD
27-
|| $paymentMethod == self::BRICK) && $order->getState() == 'complete') {
27+
|| $paymentMethod == self::BRICK) && ($order->getState() == 'complete')) {
2828
if (!$this->_helper->getConfig('delivery_confirmation_api', $paymentMethod)) {
2929
return;
3030
}
3131
$orderId = $order->getId();
3232

33+
$trackNumber = '';
34+
$carrierName = '';
3335
if ($order->hasShipments()) {
3436
$shipmentsCollection = $order->getShipmentsCollection();
3537
$shipments = $shipmentsCollection->getItems();
3638
$shipment = array_shift($shipments);
3739
$shipmentCreatedAt = $shipment->getCreatedAt();
40+
$tracksCollection = $shipment->getTracksCollection();
41+
42+
foreach ($tracksCollection->getItems() as $track) {
43+
$trackNumber = $track->getTrackNumber();
44+
$carrierName = $track->getTitle();
45+
}
3846
$shippingData = $shipment->getShippingAddress()->getData();
3947
$prodtype = 'physical';
4048
} else {
@@ -79,6 +87,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7987
'is_test' => $this->_helper->getConfig('test_mode', $paymentMethod)
8088
];
8189

90+
if ($prodtype == 'physical') {
91+
$params['carrier_tracking_id'] = $trackNumber;
92+
$params['carrier_type'] = $carrierName;
93+
}
94+
8295
$delivery = new \Paymentwall_GenerericApiObject('delivery');
8396
$response = $delivery->post($params);
8497
return $response;

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "paymentwall/module-magento2",
33
"description": "Offical Paymentwall module for Magento 2",
4-
"version": "2.3.1",
4+
"version": "2.3.2",
55
"type": "magento2-module",
66
"homepage": "https://www.paymentwall.com/?source=gh",
77
"keywords": [

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Paymentwall_Paymentwall" setup_version="2.3.1" schema_version="2.3.1">
3+
<module name="Paymentwall_Paymentwall" setup_version="2.3.2" schema_version="2.3.2">
44
<sequence>
55
<module name="Magento_Sales"/>
66
<module name="Magento_Payment"/>

view/frontend/templates/brick.phtml

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
<?php
23
echo $block->getContainer();
34
?>
@@ -32,6 +33,7 @@ echo $block->getContainer();
3233
values: setDefaultFormValues()
3334
}
3435
}, 'default');
36+
enableBrickPay()
3537
clearInterval(initBrick);
3638

3739
// only show form if option is checked and no brick form was rendered
@@ -42,6 +44,49 @@ echo $block->getContainer();
4244
}
4345
}, 500);
4446

47+
let modifyBrick = setInterval(() => {
48+
let brickControl = document.querySelector(".js-brick-step-form .brick-control")
49+
if (brickControl) {
50+
brickControl.style.position = "relative";
51+
const shield = document.createElement('div');
52+
shield.setAttribute("id", "brick-pay-shield")
53+
let btnHeight = brickControl.querySelector("button").offsetHeight
54+
let btnWidth = brickControl.querySelector("button").offsetWidth
55+
let shieldStyle = "position: absolute;top: 0;left:0;display: block;z-index: 10000;cursor: pointer;height: " + btnHeight + "px;" + "width:" + btnWidth + "px;";
56+
shield.setAttribute("style", shieldStyle)
57+
brickControl.appendChild(shield)
58+
document.getElementById("brick-pay-shield").addEventListener('click', function(e) {
59+
parent.preValidateBrickCheckout()
60+
});
61+
clearInterval(modifyBrick)
62+
}
63+
}, 300)
64+
65+
let enableBrickPay = () => {
66+
const btn = window.parent.document.getElementById('brick-place-order');
67+
const options = {
68+
attributes: true
69+
}
70+
71+
function callbackDisableBrickButton(mutationList, observer) {
72+
mutationList.forEach(function(mutation) {
73+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
74+
let shield = document.getElementById("brick-pay-shield");
75+
if (btn.classList.contains("disabled")) {
76+
shield.style.cursor = "not-allowed"
77+
shield.style.backgroundColor = "#ffffff87"
78+
} else {
79+
shield.style.cursor = "pointer"
80+
shield.style.backgroundColor = "transparent"
81+
}
82+
}
83+
})
84+
}
85+
86+
let placeOrderObserver = new MutationObserver(callbackDisableBrickButton)
87+
placeOrderObserver.observe(btn, options)
88+
}
89+
4590
function showBrickForm(brick) {
4691
brick.showPaymentForm((success) => {
4792
let result = {
@@ -55,7 +100,7 @@ echo $block->getContainer();
55100
parent.processBrickPlaceOrder(result)
56101

57102
}, (errors) => {
58-
// console.log(errors);
103+
59104
});
60105
}
61106

view/frontend/web/js/view/payment/brick_order.js

+7
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ window.processBrickPlaceOrder = function (paymentResult) {
33
document.getElementById('brick-place-order').click();
44
}
55

6+
window.preValidateBrickCheckout = function () {
7+
// if place Order button is not disabled:
8+
if (!document.getElementById('brick-place-order').classList.contains("disabled")) {
9+
document.getElementById('brick-place-order').click();
10+
}
11+
}
12+

view/frontend/web/js/view/payment/method-renderer/brick1.6.js

+32-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ define(
66
'jquery',
77
'Magento_Payment/js/view/payment/cc-form',
88
'Magento_Payment/js/model/credit-card-validation/validator',
9+
'Magento_Checkout/js/model/payment/additional-validators',
910
'Magento_Checkout/js/model/customer-email-validator',
1011
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator/credit-card-type',
1112
'Magento_Checkout/js/model/quote',
1213
'Magento_Checkout/js/model/shipping-service',
1314
'brickOrderjs'
1415
],
15-
function (ko, $, Component, ccvalidator, customerEmailValidator, creditCardTypes, quote, shippingService, brickOrderjs ) {
16+
function (ko, $, Component, ccvalidator, additionalValidators, customerEmailValidator, creditCardTypes, quote, shippingService, brickOrderjs ) {
1617

1718
return Component.extend({
1819
defaults: {
@@ -31,6 +32,10 @@ define(
3132
this.initBrick();
3233
},
3334

35+
validate: function () {
36+
return true;
37+
},
38+
3439
initBrick: function() {
3540
let initBrick = setInterval( () => {
3641
let doc = $('#iframe-brick-container');
@@ -41,20 +46,37 @@ define(
4146
clearInterval(initBrick);
4247
}
4348
}, 500);
49+
50+
quote.totals.subscribe(function (total) {
51+
$('#iframe-brick-container').attr('src', $('#iframe-brick-container').attr('src'));
52+
}, this);
4453
},
4554

4655
placeOrder: function (data, event) {
47-
let chargeResult = window.brickCheckout
56+
if (this.validate() &&
57+
additionalValidators.validate() &&
58+
ko.observable(quote.billingAddress()) != null
59+
) {
60+
let chargeResult = window.brickCheckout
4861

49-
this.card_type = chargeResult.card_type;
50-
this.card_last_four = chargeResult.card_last_four;
51-
this.brick_transaction_id = chargeResult.brick_transaction_id;
52-
this.brick_risk = chargeResult.brick_risk;
53-
this.is_under_review = chargeResult.is_under_review;
54-
this.is_captured = chargeResult.is_captured;
62+
if (chargeResult) {
63+
this.card_type = chargeResult.card_type;
64+
this.card_last_four = chargeResult.card_last_four;
65+
this.brick_transaction_id = chargeResult.brick_transaction_id;
66+
this.brick_risk = chargeResult.brick_risk;
67+
this.is_under_review = chargeResult.is_under_review;
68+
this.is_captured = chargeResult.is_captured;
69+
this._super();
70+
}
5571

56-
var self = this;
57-
this._super();
72+
if (chargeResult === undefined){
73+
let brickIframeContent = $("#iframe-brick-container").contents()
74+
brickIframeContent.find(".js-brick-submit").click()
75+
}
76+
77+
return false;
78+
}
79+
return false;
5880
},
5981

6082
styleTransactionSuccess()

0 commit comments

Comments
 (0)