Skip to content

Commit

Permalink
pushed from bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
1jenkins committed Jun 13, 2021
1 parent 39a5e99 commit d963c23
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
14 changes: 12 additions & 2 deletions Block/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ protected function _prepareLayout()
{
try {
$orderId = $this->checkoutSession->getLastOrderId();
$queries = [];
parse_str($_SERVER['QUERY_STRING'], $queries);
if ((getenv('RAPYD_QA_AUTO')==1 || getenv('RAPYD_QA_AUTO')=='1') && !empty($queries['order_id'])) {
$orderId = $queries['order_id'];
}

$order = $this->orderFactory->create()->load($orderId);
if ($order) {
$billing = $order->getBillingAddress();
Expand Down Expand Up @@ -106,6 +112,9 @@ protected function _prepareLayout()
$rapyd_data['status'] = 'success';
$rapyd_data['token'] = $response['token'];
$rapyd_data['success_url'] = $base_url . 'rapyd/success/';
if (getenv('RAPYD_QA_AUTO')==1 || getenv('RAPYD_QA_AUTO')=='1') {
$rapyd_data['success_url'] = $base_url . 'rapyd/success?order_id=' . $orderId;
}
}
if (strpos($base_url, '127.0.0.1') !== false) {
$this->toolkit_url = $this->getViewFileUrl('Rapyd_Rapydmagento2::js/toolkit.js');
Expand All @@ -125,8 +134,9 @@ protected function _prepareLayout()
}
}

public function getShippingDetails($shipping){
if($shipping){
public function getShippingDetails($shipping)
{
if ($shipping) {
return [
'line1' => $this->encode_string($shipping->getStreet()[0]),
'line2' => $this->getLine2($shipping),
Expand Down
5 changes: 5 additions & 0 deletions Block/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function _prepareLayout()
{
try {
$orderId = $this->checkoutSession->getLastOrderId();
$queries = [];
parse_str($_SERVER['QUERY_STRING'], $queries);
if ((getenv('RAPYD_QA_AUTO')==1 || getenv('RAPYD_QA_AUTO')=='1') && !empty($queries['order_id'])) {
$orderId = $queries['order_id'];
}
$order = $this->orderFactory->create()->load($orderId);
if (!$order) {
return;//hacking attempt
Expand Down
6 changes: 6 additions & 0 deletions Model/Api/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public function getPost($rapyd_data)
$this->addTransactionToOrder($order, $body['payment_token'], 1, $order_note);
}
}
if ($orderState==Order::STATE_PROCESSING) {
# send new email
$order->setCanSendNewEmailFlag(true);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objectManager->create('Magento\Sales\Model\OrderNotifier')->notify($order);
}
$order->save();
return "webhook success";
} catch (\Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rapyd/rapydmagento2",
"description": "Rapyd Payments Plugin for Magento",
"type": "magento2-module",
"version": "1.0.6",
"version": "1.0.7",
"license": [
"Apache-2.0"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<system>
<section id="payment">
<group id="rapyd" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Rapyd Payments Settings (v1.0.6)</label>
<label>Rapyd Payments Settings (v1.0.7)</label>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down
2 changes: 2 additions & 0 deletions view/frontend/templates/success.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
echo $block->getViewFileUrl('Rapyd_Rapydmagento2::js/success.js');
} ?>"></script>

<div id="rapyd_div">
<h1 id="title"></h1>
<h2 id="message"></h2>
<h3 id="order_id"></h3>
<button id="shopping" class="primary">Continue Shopping</button>
</div>
2 changes: 1 addition & 1 deletion view/frontend/web/js/success.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require(['jquery','domReady!'], function ($) {
document.getElementById("title").innerHTML=rapyd_data['title'];
document.getElementById("message").innerHTML=rapyd_data['message'];
document.getElementById("order_id").innerHTML='Your order id: ###########' +rapyd_data['order_id'];
document.getElementById("order_id").innerHTML='Your order id: ' +rapyd_data['order_id'];
var button = document.getElementById("shopping");
button.onclick = function(event) {
location.href = rapyd_data["shopping_url"];
Expand Down

0 comments on commit d963c23

Please sign in to comment.