Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_basedir restriction error in JsonMapper #87

Closed
teamayu opened this issue Jul 1, 2022 · 1 comment
Closed

open_basedir restriction error in JsonMapper #87

teamayu opened this issue Jul 1, 2022 · 1 comment

Comments

@teamayu
Copy link

teamayu commented Jul 1, 2022

I was using an older version of the Square API (12.0.0.20210616), which worked ok, but sent the wrong amount to the Square checkout page. For example, 1999 was being displayed as 19.98 on the checkout page. So, I upgraded to the newest version (19.1.1.20220616) to see if that would fix it, but now when I run it I'm getting:

parse_ini_file(): open_basedir restriction in effect. File(/opt/path/etc/php.ini) is not within the allowed path(s): (/home/users/username/www:/home/users/username/files:/home/users/username/tmp)

The error triggers on the line 119 in:
vendor/apimatic/jsonmapper/src/JsonMapper.php

This is the code I have to trigger the checkout page:

$client = new SquareClient([
'accessToken' => 'abc123',
'environment' => 'sandbox',
'numberOfRetries' => 5,
'timeout' => 120
]);
try {
// Call api
$api = $client->getCheckoutApi();
// Set money prefs
$mon = new Money();
$mon->setCurrency('GBP');
$mon->setAmount(1999);
// Item info
$item = new OrderLineItem(1);
$item->setName('Order Items');
$item->setBasePriceMoney($mon);
// Create order
$order = new Order(LOC_ID);
$order->setLineItems([$item]);
$order->setReferenceId($data['ref']);
// Create order request
$request = new CreateOrderRequest();
$request->setOrder($order);
// Set idempotency key
$checkout = new CreateCheckoutRequest(uniqid(), $request);
$checkout->setPrePopulateBuyerEmail('email@example.com');
$checkout->setRedirectUrl('https://www.page.com/');
// Fire it up
$response = $api->createCheckout(
LOC_ID,
$checkout
);
$response->getResult()->getCheckout()->getCheckoutPageUrl();
} catch (ApiException $e) {
// Catch error here
}

Any help would be appreciated, thank you. I understand why the error triggers, but not sure why it's trying to read the ini settings and reading them in an incorrect location?

@teamayu teamayu changed the title open_basedir restriction in JsonMapper open_basedir restriction error in JsonMapper Jul 1, 2022
@teamayu
Copy link
Author

teamayu commented Jul 10, 2022

I think for now we'll use Stripe which works fine. Happy to try Square again when the issues are fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant