Accepting payments from own built website

Hello I am from Fitness Mechanics, Reddeer Canada, I am looking for accepting payment after estimate/ invoice is generated on our portal. Could you please suggest square solution for payments. I have created an account on squareup and researched payment API’s, I came across card api and checkout API. How to integrate and register after sandbox development.

Hi @greensport_data, With the Payments API and Cards API you can save a credit or debit card for a customer. Your application can then charge the card when the customer makes purchases in the future.

After you’ve finished developing in sandbox you’ll need to complete the last step, which includes a basic identity verification. To complete the activation process to accept credit cards in production:

  1. Sign in to your Square Dashboard > click Setup Guide .
  2. Select Get Paid > Verify Your Identity .

If you have any trouble entering your information, keep these tips in mind:

  • Enter your legal first and last name. If you recently changed your name, enter your previous name. (e.g. If you recently married, try entering your maiden name.)
  • Use your current home address. If this is the address you initially entered or if you’ve moved within the last 6 months, try using your previous home address.

Hello Bryan, Thanks for the reply, I got your emails, Thank you very much for prompt reply. I have created account, sandbox development I am doing, my application name ‘Fitness Mechanics’,
Onclick of square payments button
it is showing screen like this

I am using PHP. Please send the link for step by step development process. I will check what I am missing, for the 404 error I am getting.
Thank you,
Raja
Thank you

That looks like it printed the ListLocation information on page but the the payment request didn’t take place. Is this with our PHP example or the SDK?

Hello Bryan,

Good morning!

Sorry for delayed reply.
Actually I have run this command on terminal

composer require square/square

after that I have created two files square.php which have the following code

Pay $1.00

and then I have created squarePayments.php another file which contains code:

require_once (“plugins/vendor/autoload.php”);

// require_once(‘plugins/vendor/square/src/Apis/CardsApi.php’);

use Square\SquareClient;

use Square\LocationsApi;

use Square\Exceptions\ApiException;

use Square\Http\ApiResponse;

use Square\Models\ListLocationsResponse;

use Square\Environment;

$client = new SquareClient([

‘accessToken’ => ‘ACCESS_TOKEN’,

‘environment’ => Environment::SANDBOX,

]);

try {

$locationsApi = $client->getLocationsApi();

$apiResponse = $locationsApi->listLocations();

if ($apiResponse->isSuccess()) {

$listLocationsResponse = $apiResponse->getResult();

$locationsList = $listLocationsResponse->getLocations();

foreach ($locationsList as $location) {

print_r($location);

}

} else {

print_r($apiResponse->getErrors());

}

} catch (ApiException $e) {

print_r("Recieved error while calling Square: " . $e->getMessage());

}

$amount_money = new \Square\Models\Money();

$amount_money->setAmount(200);

$amount_money->setCurrency(‘CAD’);

$app_fee_money = new \Square\Models\Money();

$app_fee_money->setAmount(50);

$app_fee_money->setCurrency(‘CAD’);

$body = new \Square\Models\CreatePaymentRequest(

‘cnon:card-nonce-ok’,

‘00b80499-f0c2-4474-8ace-bd2d1213b385’,

$amount_money

);

$body->setAppFeeMoney($app_fee_money);

$body->setLocationId(‘L543SN6JVH1X9’);

$api_response = $client->getPaymentsApi()->createPayment($body);

if ($api_response->isSuccess()) {

$result = $api_response->getResult();

} else {

$errors = $api_response->getErrors();

}

?>

Could you please suggest where I am missing.

Thank You, Raja Gudipati Andrew Cooper Incorporated Home of Fitness Mechanics, Greensport, & SkyLabs Solutions [email protected] Association of Professional Engineers and Geoscientists of Alberta permit to practice #P14138 Fitness Mechanics: www.FitnessMechanics.ca #8, 6150 46a Ave Red Deer, AB T4N 7A3 Toll Free: 1-855-348-4487

Looking at what you provided it looks like you have it set to print the location with print_r($location); and then process the payment. I see from your logs that you are successfully processing payments with the API so it is working as expected. Were you expecting a different result?

Hello Bryan,

Thanks for your reply. After I click on pay button, it is not displaying success message. it is showing error like the below:

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Could you please suggest for this error.

Thank You, Raja Gudipati Andrew Cooper Incorporated Home of Fitness Mechanics, Greensport, & SkyLabs Solutions [email protected] Association of Professional Engineers and Geoscientists of Alberta permit to practice #P14138 Fitness Mechanics: www.FitnessMechanics.ca #8, 6150 46a Ave Red Deer, AB T4N 7A3 Toll Free: 1-855-348-4487

Hello Bryan,

For moving to production, do I have to develop payment response page to view the response after payment is made? Please suggest what other things to consider for whole payment processing.

Thank You, Raja Gudipati Andrew Cooper Incorporated Home of Fitness Mechanics, Greensport, & SkyLabs Solutions [email protected] Association of Professional Engineers and Geoscientists of Alberta permit to practice #P14138 Fitness Mechanics: www.FitnessMechanics.ca #8, 6150 46a Ave Red Deer, AB T4N 7A3 Toll Free: 1-855-348-4487