Skip to content

Commit

Permalink
repair GooglePay
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Jan 7, 2025
1 parent 72d1209 commit f2a82f4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 298 deletions.
2 changes: 1 addition & 1 deletion out/src/js/paypal-frontend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions resources/build/js/paypal-frontend-googlepay.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ window.OxidPayPalGooglePay = {

processPayment: async function (paymentData) {
try {
const createOrderUrl = this.selfLink + '&cl=oscpaypalproxy&fnc=createGooglepayOrder&paymentid=oscpaypal_googlepay&context=continue&stoken=' + this.token;
const createOrderUrl = this.selfLink + '&cl=oscpaypalproxy&fnc=createGooglePayOrder&paymentid=oscpaypal_googlepay&context=continue&stoken=' + this.token;

const {id: orderId, status, links} = await fetch(createOrderUrl, {
method: "POST",
Expand Down Expand Up @@ -200,12 +200,12 @@ window.OxidPayPalGooglePay = {
.initiatePayerAction({ orderId: orderId })
.then(async () => {
console.log("===== Payer Action Completed =====");
await this.executeOxidOrder(orderId);
await this.captureOrder(orderId);
await this.createOxidOrder(orderId);
});
},
createOxidOrder: async function (orderId) {
const url = this.selfLink + '&cl=order&fnc=createGooglePayOrder&context=continue&stoken=' + this.token + '&sDeliveryAddressMD5=' + this.deliveryAddressMD5;
executeOxidOrder: async function (orderId) {
const url = this.selfLink + '&cl=order&fnc=executeGooglePayOrder&context=continue&stoken=' + this.token + '&sDeliveryAddressMD5=' + this.deliveryAddressMD5;
createData = new FormData();
createData.append('orderID', orderId);
fetch(url, {
Expand All @@ -214,6 +214,8 @@ window.OxidPayPalGooglePay = {
}).then(function (res) {
return res.json();
}).then(function (data) {
console.log("==== Create OXID Order Completed ====");

if (data.status === "ERROR") {
location.reload();
}
Expand All @@ -230,8 +232,8 @@ window.OxidPayPalGooglePay = {
}).then(function (data) {
console.log("==== Capture Order Completed ====");
var goNext = Array.isArray(data.location) && data.location[0];
window.location.href = this.selfLink + goNext + '&stoken=' + this.token;

window.location.href = this.selfLink + goNext;
if (data.status === "ERROR") {
location.reload();
}
Expand Down
10 changes: 3 additions & 7 deletions src/Controller/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ public function createAcdcOrder(): void
/**
* @throws Exception
*/
public function createGooglePayOrder(): void
public function executeGooglePayOrder(): void
{
try {
$paymentService = $this->getServiceFromContainer(PaymentService::class);
$paymentService->removeTemporaryOrder();
Registry::getSession()->setVariable('sess_challenge', $this->getUtilsObjectInstance()->generateUID());

/** @var Logger $logger */
$logger = $this->getServiceFromContainer(Logger::class);
Expand Down Expand Up @@ -287,7 +285,7 @@ public function captureGooglePayOrder(): void
}
$result = [
'location' => [
'cl=order&fnc=finalizeGooglePay'
'cl=order&fnc=finalizeGooglePay&token=' . $orderId
]
];

Expand Down Expand Up @@ -563,10 +561,8 @@ public function finalizeGooglePay(): string
$paypalOrderId = (string) Registry::getRequest()->getRequestParameter('token');
$forceFetchDetails = (bool) Registry::getRequest()->getRequestParameter('fallbackfinalize');

$this->createGooglePayOrder();
$this->captureGooglePayOrder();

$oxidOrderId = Registry::getSession()->getBasket()->getOrderId();
$oxidOrderId = $oxidOrderId ?: Registry::getSession()->getVariable('sess_challenge');

/** @var GooglePayPayPalService $googlePayPayPalService */
$googlePayPayPalService = $this->getServiceFromContainer(GooglePayPayPalService::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function getGooglepayBasket()
/**
* @throws JsonException
*/
public function createGooglepayOrder()
public function createGooglePayOrder()
{
$data = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR);

Expand Down
Loading

0 comments on commit f2a82f4

Please sign in to comment.