This page looks best with JavaScript enabled

Opencart - Square Payment

 ·  ☕ 2 min read  ·  🐨 Puliyo

I was in the midst of setting up opencart.

I have hit a wall when trying to process the order with Square Payment.

The request sent after pressing “Confirm Order” button returned HTTP status code 500, and UI returned with empty warning box.

When I checked the log in Web Server, below message were logged:

2019/02/06 15:53:49 [error] 29847#29847: *5250 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Squareup\bcmul() in /srv/opencart/html/system/library/squareup/api.php:788
Stack trace:
#0 /srv/opencart/html/catalog/controller/extension/payment/squareup.php(201): Squareup\Api->lowestDenomination(2730, 'JPY')
#1 /srv/opencart/storage/modification/system/engine/action.php(79): ControllerExtensionPaymentSquareup->checkout()
#2 /srv/opencart/html/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#3 /srv/opencart/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index()
#4 /srv/opencart/html/system/engine/router.php(67): Action->execute(Object(Registry))
#5 /srv/opencart/html/system/engine/router.php(56): Router->execute(Object(Action))
#6 /srv/opencart/html/system/framework.php(165): Router->dispatch(Object(Action), Object(Action))
#7 /srv/opencart/html/vqmod/vqcache/vq2-system_startup.php(104): require_once('/srv/opencart/h...')
#8 /srv/opencart/html/index.php(23): start('catalog" while reading response header from upstream, client: <IP>, server: store.puliyo.com, request: "POST /index.php?route=extension/payment/squareup/checkout HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "store.puliyo.com", referrer: "https://store.puliyo.com/index.php?route=checkout/checkout"
2019/02/06 15:57:21 [error] 29848#29848: *5285 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Squareup\bcmul() in /srv/opencart/html/system/library/squareup/api.php:788

The error is very clear. I was able to track the root cause in first search in google.

The cause of issue is due to missing bcmul() function in your PHP.

bcmul() is part of bcmath library.

Essentially, to resolve this issue, you will have to install the bcmath library to your php.

sudo apt install php-bcmath

Try restarting servers and remove cache if it does not help.

Share on