Skip to content

Commit

Permalink
load project
Browse files Browse the repository at this point in the history
  • Loading branch information
sportakal committed May 28, 2022
1 parent e0723f3 commit 055f6a7
Show file tree
Hide file tree
Showing 30 changed files with 748 additions and 290 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $error_message = $result->getErrorMessage()); //string
3D Secure işlemlerde mdStatusCode ve mdErrorMessage değerleri de döner.

3D Secure işlemi sonucunda veriler, **successUrl** veya **errorUrl** olarak belirlediğiniz adrese post edilir. Bu
adreste aşağıdaki methodla bu verileri yakalayabilirsiniz. Ve mdStatus değerlerini kontrol edebilirsiniz.
adreste aşağıdaki methodla bu verileri yakalayabilirsiniz ve mdStatus değerlerini kontrol edebilirsiniz.

```php
$result = new \Sportakal\Garantipos\Results\ThreeDSecurePayResult($options);
Expand All @@ -152,6 +152,13 @@ $md_response_message = $result->getResponseMessage();
$md_error_message = $result->getErrorMessage()
```

İşlemlerin sonucunda **Order** ve **Transaction** nesneleri de döner.

```php
$order = $result->getOrder();
$transaction = $result->getTransaction();
```

***/samples*** klasöründe daha fazla örnek bulabilirsiniz.

## Development
Expand Down
20 changes: 14 additions & 6 deletions samples/pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Sportakal\Garantipos\Models\Address;
use Sportakal\Garantipos\Models\Card;
use Sportakal\Garantipos\Models\Customer;
use Sportakal\Garantipos\Models\RequestModel;
use Sportakal\Garantipos\Models\GVPSRequestModel;
use Sportakal\Garantipos\Models\Item;
use Sportakal\Garantipos\Models\Options;
use Sportakal\Garantipos\Models\Order;
use Sportakal\Garantipos\Models\Terminal;
Expand All @@ -30,21 +31,28 @@
$customer->setIpAddress('159.146.45.34');
$customer->setEmailAddress('portakalsinan@gmail.com');

$order = new Order();
$order->setOrderID('sportakal_garantipos_' . time());

$address= new Address();
$address->setType('B'); // B for 'billing' or S for 'shipping'
$address->setName('Sinan');
$address->setLastName('Portakal');
$address->setPhoneNumber('+90(532)876-23-23');
$address->setPhoneNumber('+90 532 876 23 23');
$address->setText('Kınıklı Mah.');
$address->setDistrict('Pamukkale');
$address->setCity('Denizli');
$address->setCountry('Turkey');

$order = new Order();
$order->setOrderID('sportakal_garantipos_' . time());
$order->addAddress($address);

$item = new Item();
$item->setProductCode('123456789');
$item->setProductID('234234');
$item->setQuantity('1');
$item->setPrice('1');
$item->setTotalAmount('1');
$order->addItem($item);

$transaction = new Transaction();
$transaction->setInstallmentCnt("");
$transaction->setAmount(1000);
Expand All @@ -53,7 +61,7 @@
$transaction->setMotoInd('N');
$transaction->setDescription('test payment');

$request = new RequestModel();
$request = new GVPSRequestModel();
$request->setOptions($options);
$request->setCard($card);
$request->setCustomer($customer);
Expand Down
4 changes: 2 additions & 2 deletions samples/refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Sportakal\Garantipos\Models\Address;
use Sportakal\Garantipos\Models\Card;
use Sportakal\Garantipos\Models\Customer;
use Sportakal\Garantipos\Models\RequestModel;
use Sportakal\Garantipos\Models\GVPSRequestModel;
use Sportakal\Garantipos\Models\Options;
use Sportakal\Garantipos\Models\Order;
use Sportakal\Garantipos\Models\Terminal;
Expand Down Expand Up @@ -34,7 +34,7 @@
$transaction->setCurrencyCode('TRY');
$transaction->setOriginalRetrefNum('214707386684');

$request = new RequestModel();
$request = new GVPSRequestModel();
$request->setOptions($options);
$request->setCustomer($customer);
$request->setOrder($order);
Expand Down
30 changes: 25 additions & 5 deletions samples/threeDModelPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
use Sportakal\Garantipos\Models\Address;
use Sportakal\Garantipos\Models\Card;
use Sportakal\Garantipos\Models\Customer;
use Sportakal\Garantipos\Models\RequestModel;
use Sportakal\Garantipos\Models\GVPSRequestModel;
use Sportakal\Garantipos\Models\Item;
use Sportakal\Garantipos\Models\Options;
use Sportakal\Garantipos\Models\Order;
use Sportakal\Garantipos\Models\PostRequestModel;
use Sportakal\Garantipos\Models\Terminal;
use Sportakal\Garantipos\Models\Transaction;
use Sportakal\Garantipos\Requests\InitializeThreeDSecure;
Expand Down Expand Up @@ -36,7 +38,25 @@

$order = new Order();
$order->setOrderID('sportakal_garantipos_' . time());
$order->addAddress(new Address());

$address= new Address();
$address->setType('B'); // B for 'billing' or S for 'shipping'
$address->setName('Sinan');
$address->setLastName('Portakal');
$address->setPhoneNumber('+90 532 876 23 23');
$address->setText('Kınıklı Mah.');
$address->setDistrict('Pamukkale');
$address->setCity('Denizli');
$address->setCountry('Turkey');
$order->addAddress($address);

$item = new Item();
$item->setProductCode('123456789');
$item->setProductID('234234');
$item->setQuantity('1');
$item->setPrice('1');
$item->setTotalAmount('1');
$order->addItem($item);

$transaction = new Transaction();
$transaction->setType('sales');
Expand All @@ -47,14 +67,14 @@
$transaction->setMotoInd('N');
$transaction->setDescription('test payment');

$request = new RequestModel();
$request = new PostRequestModel();
$request->setOptions($options);
$request->setCard($card);
$request->setCustomer($customer);
$request->setOrder($order);
$request->setTransaction($transaction);
$request->setSuccessURL((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]/garantipos/samples/threeDModelResult.php");
$request->setErrorURL((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]/garantipos/samples/threeDModelResult.php");
$request->setSuccessurl((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]/garantipos/samples/threeDModelResult.php");
$request->setErrorurl((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]/garantipos/samples/threeDModelResult.php");

$response = new InitializeThreeDSecure($request);
$response = $response->getResult();
Expand Down
6 changes: 5 additions & 1 deletion samples/threeDModelResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
ddd($md_result->getMdStatus(), $md_result->getResponseMessage(), $md_result->getMdErrorMessage());
}

$response = new \Sportakal\Garantipos\Requests\CompleteThreeDSecure($_ENV['TERMINAL_PROV_USER_PASSWORD']);
$request = $md_result->getGVPSRequest();

$response = new \Sportakal\Garantipos\Requests\CompleteThreeDSecure($request);
try {
$result = $response->getResult();
// ddd($result->getOrder(), $result->getTransaction());

ddd($result->getStatus(), $result->getStatusMessage(), $result->getErrorMessage());
} catch (Exception $e) {
ddd($e->getMessage());
Expand Down
30 changes: 24 additions & 6 deletions samples/threeDPay.php → samples/threeDSecurePay.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
use Sportakal\Garantipos\Models\Address;
use Sportakal\Garantipos\Models\Card;
use Sportakal\Garantipos\Models\Customer;
use Sportakal\Garantipos\Models\RequestModel;
use Sportakal\Garantipos\Models\GVPSRequestModel;
use Sportakal\Garantipos\Models\Item;
use Sportakal\Garantipos\Models\Options;
use Sportakal\Garantipos\Models\Order;
use Sportakal\Garantipos\Models\PostRequestModel;
use Sportakal\Garantipos\Models\Transaction;
use Sportakal\Garantipos\Requests\ThreeDSecurePay;

Expand All @@ -25,6 +27,7 @@
if ($_POST) {
try {
$result = new \Sportakal\Garantipos\Results\ThreeDSecurePayResult($options);
// ddd($result->getOrder(), $result->getTransaction());
ddd($result->getMdStatus(), $result->getResponseMessage(), $result->getErrorMessage());
} catch (Exception $e) {
ddd($e->getMessage());
Expand All @@ -43,8 +46,23 @@


$order = new Order();
$order->setOrderID(time() . "DENEME" . date("ymd"));
$order->addAddress(new Address());
$order->setOrderID('sportakal_garantipos_' . time());

$address = new Address();
$address->setCity('İstanbul');
$address->setCompany('Garanti');
$address->setCountry('Türkiye');
$address->setDistrict('Kadıköy');
$address->setFaxNumber('123456789');
$order->addAddress($address);

$item = new Item();
$item->setProductCode('123456789');
$item->setProductID('234234');
$item->setQuantity('1');
$item->setPrice('1');
$item->setTotalAmount('1');
$order->addItem($item);

$transaction = new Transaction();
$transaction->setType('sales');
Expand All @@ -55,14 +73,14 @@
$transaction->setMotoInd('N');
$transaction->setDescription('test payment');

$request = new RequestModel();
$request = new PostRequestModel();
$request->setOptions($options);
$request->setCard($card);
$request->setCustomer($customer);
$request->setOrder($order);
$request->setTransaction($transaction);
$request->setSuccessURL((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$request->setErrorURL((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$request->setSuccessurl((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$request->setErrorurl((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");

$response = new ThreeDSecurePay($request);
$response = $response->getResult();
Expand Down
46 changes: 23 additions & 23 deletions src/Models/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ class Address extends BaseModel
{
protected string $_parent_key = 'Address';
protected string $Type = 'B'; // B for 'billing' or S for 'shipping'
protected string $Name='';
protected string $LastName='';
protected string $Company='';
protected string $Text='';
protected string $District='';
protected string $City='';
protected string $Country='';
protected string $PostalCode='';
protected string $PhoneNumber='';
protected string $GsmNumber='';
protected string $FaxNumber='';
protected string $Name = '';
protected string $LastName = '';
protected string $Company = '';
protected string $Text = '';
protected string $District = '';
protected string $City = '';
protected string $Country = '';
protected string $PostalCode = '';
protected string $PhoneNumber = '';
protected string $GsmNumber = '';
protected string $FaxNumber = '';

/**
* @return string
*/
public function getType(): string
{
return $this->Type;
return $this->Type ?? '';
}

/**
Expand All @@ -39,7 +39,7 @@ public function setType(string $Type): void
*/
public function getName(): string
{
return $this->Name;
return $this->Name ?? '';
}

/**
Expand All @@ -55,7 +55,7 @@ public function setName(string $Name): void
*/
public function getLastName(): string
{
return $this->LastName;
return $this->LastName ?? '';
}

/**
Expand All @@ -71,7 +71,7 @@ public function setLastName(string $LastName): void
*/
public function getCompany(): string
{
return $this->Company;
return $this->Company ?? '';
}

/**
Expand All @@ -87,7 +87,7 @@ public function setCompany(string $Company): void
*/
public function getText(): string
{
return $this->Text;
return $this->Text ?? '';
}

/**
Expand All @@ -103,7 +103,7 @@ public function setText(string $Text): void
*/
public function getDistrict(): string
{
return $this->District;
return $this->District ?? '';
}

/**
Expand All @@ -119,7 +119,7 @@ public function setDistrict(string $District): void
*/
public function getCity(): string
{
return $this->City;
return $this->City ?? '';
}

/**
Expand All @@ -135,7 +135,7 @@ public function setCity(string $City): void
*/
public function getCountry(): string
{
return $this->Country;
return $this->Country ?? '';
}

/**
Expand All @@ -151,7 +151,7 @@ public function setCountry(string $Country): void
*/
public function getPostalCode(): string
{
return $this->PostalCode;
return $this->PostalCode ?? '';
}

/**
Expand All @@ -167,7 +167,7 @@ public function setPostalCode(string $PostalCode): void
*/
public function getPhoneNumber(): string
{
return $this->PhoneNumber;
return $this->PhoneNumber ?? '';
}

/**
Expand All @@ -183,7 +183,7 @@ public function setPhoneNumber(string $PhoneNumber): void
*/
public function getGsmNumber(): string
{
return $this->GsmNumber;
return $this->GsmNumber ?? '';
}

/**
Expand All @@ -199,7 +199,7 @@ public function setGsmNumber(string $GsmNumber): void
*/
public function getFaxNumber(): string
{
return $this->FaxNumber;
return $this->FaxNumber ?? '';
}

/**
Expand Down
Loading

0 comments on commit 055f6a7

Please sign in to comment.