-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathAuthorizationwithToken.php
70 lines (60 loc) · 2.1 KB
/
AuthorizationwithToken.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
//echo "Inside php functionality"
error_reporting(E_ALL);
require_once __DIR__. DIRECTORY_SEPARATOR .'../../../vendor/autoload.php';
require_once __DIR__. DIRECTORY_SEPARATOR .'../../../Resources/ExternalConfiguration.php';
function CreatePaymentsInstruments()
{
$commonElement = new CyberSource\ExternalConfiguration();
$config = $commonElement->ConnectionHost();
$apiclient = new CyberSource\ApiClient($config);
$api_instance = new CyberSource\Api\PaymentInstrumentsApi($apiclient);
$tmsCardInfo = [
"expirationMonth" => "09",
"expirationYear" => "2022",
"type" => "visa"
];
$card = new CyberSource\Model\Tmsv1paymentinstrumentsCard($tmsCardInfo);
$tmsBillToArr = [
"firstName" => "John",
"lastName" => "Deo",
"company" => "CyberSource",
"address1" => "12 Main Street",
"address2" => "20 My Street",
"locality" => "Foster City",
"administrativeArea" => "CA",
"postalCode" => "90200",
"country" => "US",
"email" => "[email protected]",
"phoneNumber" => "555123456"
];
$tmsBillTo = new CyberSource\Model\Tmsv1paymentinstrumentsBillTo($tmsBillToArr);
$cardArr = [
"number" => "4111111111111111"
];
$instrumentidentifiersCard = new CyberSource\Model\Tmsv1instrumentidentifiersCard($cardArr);
$instrumentidentifiersArr = [
"card" => $instrumentidentifiersCard
];
$instrumentidentifier = new CyberSource\Model\Tmsv1paymentinstrumentsInstrumentIdentifier($instrumentidentifiersArr);
$tmsRequestArr = [
"card" => $card,
"billTo" => $tmsBillTo,
"instrumentIdentifier" => $instrumentidentifier
];
$tmsRequest = new CyberSource\Model\Body2($tmsRequestArr);
$profileId = '93B32398-AD51-4CC2-A682-EA3E93614EB1';
$api_response = list($response,$statusCode,$httpHeader)=null;
try {
$api_response = $api_instance->tmsV1PaymentinstrumentsPost($profileId, $tmsRequest);
echo "<pre>";print_r($api_response);
} catch (Cybersource\ApiException $e) {
print_r($e->getMessage());
}
}
// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "Samplecode is Running..";
CreatePaymentsInstruments();
}
?>