Skip to content

Commit 1c87d72

Browse files
committed
feat: add callback
1 parent f5d44ca commit 1c87d72

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

Model/Api/Resolver/Store/Checkout.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public function confirmOrder()
529529
array(
530530
'paymentMethod' => $paymentMethod,
531531
'total' => floatval($total),
532-
'callback' => ''//$this->url->link('extension/d_vuefront/store/checkout/callback', 'order_id='.$orderId, true)
532+
'callback' => $this->storeManager->getStore()->getBaseUrl(). "rest/V1/vuefront/callback?order_id=".$orderId
533533
)
534534
);
535535

@@ -541,6 +541,10 @@ public function confirmOrder()
541541
];
542542
}
543543

544+
public function callback() {
545+
546+
}
547+
544548
public function totals()
545549
{
546550
$totals = $this->checkoutSession->getQuote()->getTotals();

Model/Api/System/Startup.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,15 @@ public function start($body, $driver)
3838

3939
return $this->registry->get('response')->getOutput();
4040
}
41+
42+
/**
43+
* @param $body
44+
* @param $driver \Magento\Framework\Filesystem\Driver\File
45+
*/
46+
public function callback($body, $driver)
47+
{
48+
$this->loader->resolver('store/checkout/callback', $body);
49+
50+
return $this->registry->get('response')->getOutput();
51+
}
4152
}

Model/GraphqlModel.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,22 @@ public function graphql()
7979
return;
8080
}
8181
}
82+
83+
public function callback()
84+
{
85+
$this->checkCors();
86+
87+
$enable = $this->scopeConfig
88+
->getValue('vuefront/general/enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
89+
90+
if ($enable) {
91+
$output = $this->startup->start($this->request->getBodyParams(), $this->driver);
92+
93+
return $output;
94+
} else {
95+
$norouteUrl = $this->url->getUrl('noroute');
96+
$this->response->setRedirect($norouteUrl);
97+
return;
98+
}
99+
}
82100
}

etc/webapi.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<resource ref="anonymous"/>
88
</resources>
99
</route>
10+
<route url="/V1/vuefront/callback" method="POST">
11+
<service class="Vuefront\Vuefront\Api\GraphqlInterface" method="callback"/>
12+
<resources>
13+
<resource ref="anonymous"/>
14+
</resources>
15+
</route>
1016
<route url="/V1/vuefront/information/:id" method="POST">
1117
<service class="Vuefront\Vuefront\Api\InformationInterface" method="info"/>
1218
<resources>

0 commit comments

Comments
 (0)