question

sweetshopperobin avatar image
sweetshopperobin asked craigreilly commented

Hosted Checkout PHP question

Still having trouble with our payment gateway since the migration from Payeezy to Clover. Could someone post their (redacted) php code that works? Like below:


Endpoint URL: https://api.clover.com//v3/merchants/

Page/Merchant ID: 123456790 (Clover Merchant ID??)

Token/API Key: Which key from clover- API key or Ecommerce API token??


Incredibly frustrated with how bad this migration has been and Clover support does not call back on our escalated case like they said they would, so my webhost and I are still fumbling trying to get it to work correctly.


Thanks!

e-commerce api
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
directional avatar image
directional answered craigreilly commented

We have experienced the same with our Payeezy integration. We partially migrated our code to Clover but that platform is having issues as well. The webhook does not work in the sandbox environment and neither the webhook or the redirect urls work in production.

You want to create an Ecommerce API token for Hosted Checkout.

Here is the snippet you asked for to retrieve a Clover hosted checkout URL, you will want to redirect the user to that URL to complete the payment.

$url = 'https://www.clover.com/invoicingcheckoutservice/v1/checkouts';
$data = [
    "customer" => [
        "email" => "jane@doe.com",
    ],
    "shoppingCart" => [
        "lineItems" => [
            [
                "name" => "ACME Widgets",
                "unitQty" => 1,
                // this is $10.00
                "price" => 1000
            ]
        ]
    ],
];
$headers = [
    'X-Clover-Merchant-Id: XXXXXXXXXXXXXXXXXXXXXX',
    'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXX',
    'Accept: application/json',
    'Content-Type: application/json',
];

$opts = [
    'http' => [
        'method' => 'POST',
        'header' => implode("\r\n", $headers),
        "ignore_errors" => true,
        'content' => json_encode($data),
    ]
];
$context = stream_context_create($opts);
$response = file_get_contents($url, false, $context);
echo json_decode($response);

You can also use curl as well if you prefer.

Good luck.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

craigreilly avatar image craigreilly commented ·
Does the Redirect URL for success send any POST DATA?

We'd like to show the user their payment ID...

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community