Created
July 8, 2016 18:32
-
-
Save MrCoffey/f9d39ee08e363a05e303163694a78fb7 to your computer and use it in GitHub Desktop.
Ejemplo de como crear un reembolso con Tpaga
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Get cURL resource | |
| $ch = curl_init(); | |
| // Set url | |
| curl_setopt($ch, CURLOPT_URL, 'https://sandbox.tpaga.co/api/refund/credit_card'); | |
| // Set method | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | |
| // Set options | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| // Set headers | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, [ | |
| "Authorization: Basic privateKey", | |
| "Content-Type: application/json; charset=utf-8", | |
| ] | |
| ); | |
| // Create body | |
| $json_array = [ | |
| "id" => "token_id" | |
| ]; | |
| $body = json_encode($json_array); | |
| // Set body | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $body); | |
| // Send the request & save response to $resp | |
| $resp = curl_exec($ch); | |
| if(!$resp) { | |
| die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch)); | |
| } else { | |
| echo "Response HTTP Status Code : " . curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| echo "\nResponse HTTP Body : " . $resp; | |
| } | |
| // Close request to clear up some resources | |
| curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment