-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment_batch_cancel.php
54 lines (36 loc) · 1.42 KB
/
payment_batch_cancel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// Include Guzzle Library
require 'vendor/autoload.php'; // Adjust the path based on your project structure.
require 'config.php'; // Include your configuration file
use GuzzleHttp\Client;
// Authenticate
$headers = [
'Authorization' => 'Bearer ' . $api_secret,
'Content-Type' => 'application/json',
];
// Set Payments IDs to Cancel
$payment_ids = ['PYjRwog4XERm'];
$client = new Client();
foreach ($payment_ids as $payment_id) {
echo "Cancel payment with ID: $payment_id? (Y/N): ";
$input = strtolower(trim(fgets(STDIN))); // Read input from console
if ($input === 'y') {
$cancel_endpoint = 'https://api.tucuota.com/v1/payments/' . $payment_id . '/actions/cancel';
try {
$response = $client->post($cancel_endpoint, [
'headers' => $headers,
]);
// Process the response for each payment ID
$response_code = $response->getStatusCode();
$response_body = $response->getBody()->getContents();
echo "Response Code: $response_code. Response Body $response_body\n";
// echo "Response Body: $response_body\n";
// Handle success or failure based on the response
} catch (Exception $ex) {
// Handle any exceptions or errors
$error_message = $ex->getMessage();
echo "Error: $error_message\n";
}
}
}
?>