-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathApi3DPaymentRequest.php
More file actions
123 lines (111 loc) · 5.49 KB
/
Api3DPaymentRequest.php
File metadata and controls
123 lines (111 loc) · 5.49 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
class Api3DPaymentRequest extends ApiPaymentRequest
{
public $SuccessUrl;
public $FailUrl;
public $transactionDate;
private $deviceUUID;
public $Token;
public $Language = "tr-TR";
//3D Secure İle Ödeme Servis çağrısını temsil eder.
public function execute3D(Settings $settings)
{
$settings->transactionDate = Helper::GetTransactionDateString();
$settings->HashString = $settings->PrivateKey . $this->OrderId . $this->Amount . $this->Mode . $this->CardOwnerName . $this->CardNumber . $this->CardExpireMonth . $this->CardExpireYear . $this->Cvc . $this->UserId . $this->CardId. $this->Purchaser->Name . $this->Purchaser->SurName . $this->Purchaser->Email . $settings->transactionDate;
$this->Token = Helper::CreateToken($settings->PublicKey, $settings->HashString);
$parameters = $this->toJsonString($settings);
$url = $settings->BaseUrl . 'rest/payment/threed';
return $this->toHtmlString($parameters, $url);
}
public function toJsonString(Settings $settings)
{
$purchaser = [
"name" => $this->Purchaser->Name,
"surname" => $this->Purchaser->SurName,
"email" => $this->Purchaser->Email,
"clientIp" => $this->Purchaser->ClientIp,
"birthDate" => $this->Purchaser->BirthDate,
"gsmNumber" => $this->Purchaser->GsmPhone,
"tcCertificate" => $this->Purchaser->IdentityNumber,
"invoiceAddress" => [
"name" => $this->Purchaser->InvoiceAddress->Name,
"surname" => $this->Purchaser->InvoiceAddress->SurName,
"address" => $this->Purchaser->InvoiceAddress->Address,
"zipcode" => $this->Purchaser->InvoiceAddress->ZipCode,
"city" => $this->Purchaser->InvoiceAddress->CityCode,
"country" => $this->Purchaser->InvoiceAddress->CountryCode,
"tcCertificate" => $this->Purchaser->InvoiceAddress->IdentityNumber,
"taxNumber" => $this->Purchaser->InvoiceAddress->TaxNumber,
"taxOffice" => $this->Purchaser->InvoiceAddress->TaxOffice,
"companyName" => $this->Purchaser->InvoiceAddress->CompanyName,
"phoneNumber" => $this->Purchaser->InvoiceAddress->PhoneNumber
],
"shippingAddress" => [
"name" => $this->Purchaser->ShippingAddress->Name,
"surname" => $this->Purchaser->ShippingAddress->SurName,
"address" => $this->Purchaser->ShippingAddress->Address,
"zipcode" => $this->Purchaser->ShippingAddress->ZipCode,
"city" => $this->Purchaser->ShippingAddress->CityCode,
"country" => $this->Purchaser->ShippingAddress->CountryCode,
"tcCertificate" => $this->Purchaser->ShippingAddress->IdentityNumber,
"phoneNumber" => $this->Purchaser->ShippingAddress->PhoneNumber
]
];
$products = [];
foreach($this->Products as $product) {
$tmp['productCode'] = $product->Code;
$tmp['productName'] = $product->Title;
$tmp['quantity'] = $product->Quantity;
$tmp['price'] = $product->Price;
$products[] = $tmp;
}
$paymentRequest = [
"mode" => $settings->Mode,
"orderId" => $this->OrderId,
"cardOwnerName" => $this->CardOwnerName,
"cardNumber" => $this->CardNumber,
"cardExpireMonth" => $this->CardExpireMonth,
"cardExpireYear" => $this->CardExpireYear,
"cardCvc" => $this->Cvc,
"userId" => $this->UserId,
"cardId" => $this->CardId,
"installment" => $this->Installment,
"amount" => $this->Amount,
"echo" => $this->Echo,
"vendorId" => $this->VendorId,
"successUrl" => $this->SuccessUrl,
"failureUrl" => $this->FailUrl,
"transactionDate" => $settings->transactionDate,
"version" => $settings->Version,
"token" => $this->Token,
"language" => $this->Language,
"purchaser" => $purchaser,
"products" => $products
];
return json_encode($paymentRequest);
}
public function toHtmlString($parameters, $url) {
$builder = "";
$builder .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
$builder .= "<html>";
$builder .= "<body>";
$builder .= "<form action=\"" . $url . "\" method=\"post\" id=\"three_d_form\" >";
$builder .= "<input type=\"hidden\" name=\"parameters\" value=\"" . htmlspecialchars($parameters) . "\"/>";
$builder .= "<input type=\"submit\" value=\"Öde\" style=\"display:none;\"/>";
$builder .= "<noscript>";
$builder .= "<br/>";
$builder .= "<br/>";
$builder .= "<center>";
$builder .= "<h1>3D Secure Yönlendirme İşlemi</h1>";
$builder .= "<h2>Javascript internet tarayıcınızda kapatılmış veya desteklenmiyor.<br/></h2>";
$builder .= "<h3>Lütfen banka 3D Secure sayfasına yönlenmek için tıklayınız.</h3>";
$builder .= "<input type=\"submit\" value=\"3D Secure Sayfasına Yönlen\">";
$builder .= "</center>";
$builder .= "</noscript>";
$builder .= "</form>";
$builder .= "</body>";
$builder .= "<script>document.getElementById(\"three_d_form\").submit();</script>";
$builder .= "</html>";
return $builder;
}
}