I have come up against this error in after completing a sandbox transaction using Merx. Does anyone know what to look for to debug this?
Array
(
[message] => {"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"ORDER_ALREADY_CAPTURED","description":"Order already captured.If 'intent=CAPTURE' only one capture per order is allowed."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"a171055e12616","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_ALREADY_CAPTURED","rel":"information_link","method":"GET"}]}
[code] => 0
[file] => /Volumes/Apollo/Sites/studio_hetain_patel/site/plugins/merx/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php
[line] => 222
)
I do actually get a successful payment with PayPal but it returns as failed and the order isn’t published in the panel.
return [
'cache' => [
'pages' => [
'active' => false
]
],
'debug' => true,
'ww.merx.production' => false,
'ww.merx.license' => 'XXXX',
'ww.merx.currency' => 'GBP',
'ww.merx.currencySymbol' => '£',
'ww.merx.successPage' => 'success',
'ww.merx.paypal.sandbox.clientID' => 'XXXX',
'ww.merx.paypal.sandbox.secret' => 'XXXX',
'ww.merx.paypal.live.clientID' => 'XXXX',
'ww.merx.paypal.live.secret' => 'XXXX',
'routes' => [
[
'pattern' => 'add',
'method' => 'post|get',
'action' => function () {
$id = get('id');
$stock = get('stock');
$quantity = get('quantity');
$name = get('name');
$variant = get('variant');
$image = get('image');
try {
cart()->add([
'id' => $id,
'quantity' => $quantity,
'stock' => $stock,
'name' => $name,
'variant' => $variant,
'image' => $image,
]);
go('/checkout');
} catch (Kirby\Exception\Exception $ex) {
return $ex->getMessage();
}
},
],
[
'pattern' => 'update',
'method' => 'post|get',
'action' => function () {
try {
$id = get('id');
$quantity = get('quantity');
cart()->updateItem([
'id' => $id,
'quantity' => $quantity,
]);
go('/checkout');
} catch (Kirby\Exception\Exception $ex) {
return $ex->getMessage();
}
}
],
[
'pattern' => 'remove',
'method' => 'post|get',
'action' => function () {
$id = get('id');
try {
cart()->remove($id);
go('/checkout');
} catch (Kirby\Exception\Exception $ex) {
return $ex->getMessage();
}
},
],
],
'hooks' => [
//'ww.merx.cart' => function ($cart) {
// Add shipping
// if ($cart->count() > 0) {
// $cart->remove('shipping');
// if ($cart->getSum() > 2) {
// $cart->add([
// 'id' => 'shipping',
// ]);
// }
// }
//},
'ww.merx.completePayment:after' => function ($orderPage) {
orderConfirmationUser($orderPage);
orderConfirmationOffice($orderPage);
foreach($orderPage->cart() as $cartItem) {
$cartItemPage = page($cartItem['id']);
$newStock = $cartItemPage->stock()->toInt() - (int)$cartItem['quantity'];
$cartItemPage->update([
'stock' => (int)$newStock,
]);
}
},
'file.create:after' => function ($file) {
autoresize($file);
},
'file.replace:after' => function ($newFile, $oldFile) {
autoresize($newFile);
},
'page.changeStatus:after' => function ($newPage, $oldPage) {
if ($newPage->status() === 'listed') {
foreach ($newPage->childrenAndDrafts() as $item) {
$item->changeStatus('listed');
}
}
}
],
];