Created
March 18, 2020 16:33
-
-
Save thlinux1107/298c94f917ce54f8bf37d4e7ab10cf46 to your computer and use it in GitHub Desktop.
Paya Connect - Accountvaults Sample - Production API URL
This file contains 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 | |
/*---------------------------------------------- | |
Author: SDK Support Group | |
Company: Paya | |
Contact: sdksupport@paya.com | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
!!! Samples intended for educational use only!!! | |
!!! Not intended for production !!! | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
-----------------------------------------------*/ | |
// Location Variables | |
$locationID = "[Location ID]"; | |
// Developer Variables | |
$developerID = "[Developer ID]"; | |
// Connection Variables | |
$host = "https://api.payaconnect.com"; | |
$endpoint = "/v2/accountvaults"; | |
// User Variables | |
$userID = "[User ID]"; | |
$userAPIKey = "[User API Key]"; | |
// Transaction Variables | |
$verb = "POST"; | |
$timestamp = time(); | |
// Build the request | |
$req = [ | |
"accountvault"=> [ | |
"title"=> "SDK TEST VAULT", | |
"payment_method"=> "cc", | |
"location_id"=> $locationID, | |
"account_holder_name"=> "SDK Test", | |
"account_number"=> "5454545454545454", | |
"exp_date"=> "1230", | |
] | |
]; | |
$payload = json_encode($req); | |
// file_get_contents to submit the POST. cURL may be used as well. | |
$url = $host . $endpoint; | |
$config = [ | |
"http" => [ | |
"header" => [ | |
"developer-id: " . $developerID, | |
"user-api-key: " . $userAPIKey, | |
"user-id: " . $userID, | |
"content-type: application/json", | |
], | |
"method" => $verb, | |
"content" => $payload, | |
"ignore_errors" => true // exposes response body on 4XX errors | |
] | |
]; | |
$context = stream_context_create($config); | |
$result = file_get_contents($url, false, $context); | |
$response = json_decode($result); | |
$httpcode = http_response_code(); | |
echo '<pre>'; | |
print_r('HTTP Code: ' . $httpcode); | |
echo '</pre>'; | |
echo '<pre>'; | |
print_r('API Response:'); | |
echo '</pre>'; | |
echo '<pre>'; | |
print_r($response); | |
echo '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment