|
@@ -112,11 +112,13 @@ class SquarepayExtension extends SimpleExtension
|
|
|
}
|
|
|
|
|
|
protected function registerTwigFunctions() {
|
|
|
- $getCatalog = [Twig\SquareTwigRuntime::class, 'getCatalog'];
|
|
|
- $getBasket = [Twig\SquareTwigRuntime::class, 'getBasket'];
|
|
|
- $cardform = [Twig\SquareTwigRuntime::class, 'displayCCForm'];
|
|
|
+ $getCatalog = [Twig\SquareTwigRuntime::class, 'getCatalog'];
|
|
|
+ $getCatalogItem = [Twig\SquareTwigRuntime::class, 'getCatalogItem'];
|
|
|
+ $getBasket = [Twig\SquareTwigRuntime::class, 'getBasket'];
|
|
|
+ $cardform = [Twig\SquareTwigRuntime::class, 'displayCCForm'];
|
|
|
return [
|
|
|
'getcatalog' => [ $getCatalog ],
|
|
|
+ 'getcatitem' => [ $getCatalogItem ],
|
|
|
'getbasket' => [ $getBasket, ['is_safe' => ['html']] ],
|
|
|
'cardform' => [ $cardform, ['is_safe' => ['html']] ]
|
|
|
];
|
|
@@ -238,7 +240,7 @@ class SquarepayExtension extends SimpleExtension
|
|
|
exit;
|
|
|
}
|
|
|
$orderId = $response['order']['id'];
|
|
|
- dump($orderId);
|
|
|
+ // dump($orderId);
|
|
|
|
|
|
// Build transaction request
|
|
|
$buyerInfo = [
|
|
@@ -271,16 +273,14 @@ class SquarepayExtension extends SimpleExtension
|
|
|
$transactionsApi = new \SquareConnect\Api\TransactionsApi($apiClient);
|
|
|
try {
|
|
|
$response = $transactionsApi->charge($locationId, $tranactionRequest);
|
|
|
- dump($response);
|
|
|
} catch (\SquareConnect\ApiException $e) {
|
|
|
- echo "<hr>" .
|
|
|
- "The SquareConnect\Api\TransactionsApi object threw an exception.<br>" .
|
|
|
- "API call: <code>TransactionsApi->charge</code>" .
|
|
|
- "<pre>" . var_dump($e) . "</pre>";
|
|
|
- throw $e;
|
|
|
+ return new RedirectResponse('/order-problem');
|
|
|
}
|
|
|
|
|
|
- return new RedirectResponse('/basket');
|
|
|
+ // Order succeeded
|
|
|
+ // dump($response);
|
|
|
+ // exit;
|
|
|
+ return new RedirectResponse('/order-complete');
|
|
|
}
|
|
|
|
|
|
}
|