first commit
This commit is contained in:
701
app/Core/Payment/Pos/AkPos.php
Normal file
701
app/Core/Payment/Pos/AkPos.php
Normal file
@@ -0,0 +1,701 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GPBMetadata\Google\Api\Log;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class AkPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'AkPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $mbrId = 5;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getRandomNumberBase16()
|
||||
{
|
||||
$n = 128;
|
||||
|
||||
$characters = '0123456789ABCDEF';
|
||||
$randomString = '';
|
||||
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$index = rand(0, strlen($characters) - 1);
|
||||
$randomString .= $characters[$index];
|
||||
}
|
||||
|
||||
return strtoupper($randomString);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hashItems = [];
|
||||
|
||||
$hashItems[] = mb_strtoupper($this->account->model);
|
||||
$hashItems[] = $this->txnCode;
|
||||
$hashItems[] = $this->account->merchant_safe_id;
|
||||
$hashItems[] = $this->account->terminal_safe_id;
|
||||
$hashItems[] = $this->order->id;
|
||||
$hashItems[] = mb_strtoupper($this->order->lang);
|
||||
$hashItems[] = $this->order->amount;
|
||||
//$hashItems[] = $this->order->ccbRewardAmount;
|
||||
//$hashItems[] = $this->order->pcbRewardAmount;
|
||||
//$hashItems[] = $this->order->xcbRewardAmount;
|
||||
$hashItems[] = $this->order->currency;
|
||||
$hashItems[] = $this->order->installment;
|
||||
$hashItems[] = $this->order->success_url;
|
||||
$hashItems[] = $this->order->fail_url;
|
||||
//$hashItems[] = $this->order->emailAddress;
|
||||
//$hashItems[] = $this->order->subMerchantId;
|
||||
$hashItems[] = $this->card->number;
|
||||
$hashItems[] = $this->getCardExpDate();
|
||||
$hashItems[] = $this->card->cvv;
|
||||
$hashItems[] = $this->order->rand;
|
||||
$hashItems[] = $this->order->requestDateTime;
|
||||
//$hashItems[] = $this->order->b2bIdentityNumber;
|
||||
|
||||
$hashItemsString = implode('', $hashItems);
|
||||
|
||||
$hashItemsStringHashed = hash_hmac('sha512', $hashItemsString, $this->account->secret_key, true);
|
||||
|
||||
return base64_encode($hashItemsStringHashed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
|
||||
$params = explode('+', $data['hashParams']);
|
||||
|
||||
$builder = '';
|
||||
foreach ($params as $param) {
|
||||
$builder .= $data[$param];
|
||||
}
|
||||
|
||||
$hashItemsStringHashed = hash_hmac('sha512', $builder, $this->account->secret_key, true);
|
||||
$hashItemsStringHashed = base64_encode($hashItemsStringHashed);
|
||||
|
||||
if ($data['hash'] == $hashItemsStringHashed) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('responseCode') == 'VPS-0000') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
//if ($this->request->get('3DStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
// } elseif (in_array($this->request->get('3DStatus'), [2, 3, 4])) {
|
||||
//$transaction_security = 'Half 3D Secure';
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('authCode'),
|
||||
'order_id' => (string)$this->request->get('orderId'),
|
||||
'trans_id' => (string)$this->request->get('rrn'),
|
||||
'response' => (string)$this->request->get('responseCode'),
|
||||
'merchantSafeId' => (string)$this->request->get('merchantSafeId'),
|
||||
'terminalSafeId' => (string)$this->request->get('terminalSafeId'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => (string)$this->request->get('rrn'),
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => (string)$this->request->get('authCode'),
|
||||
'host_ref_num' => (string)$this->request->get('rrn'),
|
||||
'proc_return_code' => (string)$this->request->get('hostResponseCode'),
|
||||
'code' => (string)$this->request->get('responseCode'),
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseCode') : null,
|
||||
'error_message' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseMessage') : null,
|
||||
'md_status' => (string)$this->request->get('md_status'),
|
||||
'hash' => (string)$this->request->get('hash'),
|
||||
'rand' => null,
|
||||
'hash_params' => (string)$this->request->get('hashParams'),
|
||||
'hash_params_val' => (string)$this->request->get('hash'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'md_error_message' => (string)$this->request->get('responseCode') != 'VPS-0000' ? (string)$this->request->get('responseMessage') : null,
|
||||
'all' => $this->request->request->all()
|
||||
];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$this->order->amount = number_format($this->order->amount, 2, '.', '');
|
||||
$this->order->rand = $this->getRandomNumberBase16();
|
||||
$this->order->requestDateTime = mb_substr(Carbon::now()->toISOString(), 0, 23);
|
||||
$this->order->installment = $this->order->installment == 0 ? 1 : $this->order->installment;
|
||||
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'paymentModel' => mb_strtoupper($this->account->model),
|
||||
'txnCode' => $this->txnCode,
|
||||
'merchantSafeId' => $this->account->merchant_safe_id,
|
||||
'terminalSafeId' => $this->account->terminal_safe_id,
|
||||
'orderId' => $this->order->id,
|
||||
'lang' => mb_strtoupper($this->order->lang),
|
||||
'amount' => $this->order->amount,
|
||||
'currencyCode' => $this->order->currency,
|
||||
'installCount' => $this->order->installment,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'creditCard' => $this->card->number,
|
||||
'expiredDate' => $this->getCardExpDate(),
|
||||
'cvv' => $this->card->cvv,
|
||||
'randomNumber' => $this->order->rand,
|
||||
'requestDateTime' => $this->order->requestDateTime,
|
||||
'hash' => $this->order->hash,
|
||||
];
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
|
||||
//$formData = $data;
|
||||
//echo view('threeDSecureForm', compact('formData'));die();
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
$this->txnCode = 3000;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
881
app/Core/Payment/Pos/EstPos.php
Normal file
881
app/Core/Payment/Pos/EstPos.php
Normal file
@@ -0,0 +1,881 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class EstPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'EstPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
|
||||
if ($this->account->model == '3d') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->order->rand . $this->account->store_key;
|
||||
} elseif ($this->account->model == '3d_pay') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->store_key;
|
||||
}
|
||||
|
||||
return base64_encode(sha1($hash_str, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$hash_params = $data['HASHPARAMS'];
|
||||
$hash_params_val = $data['HASHPARAMSVAL'];
|
||||
$hash_param = $data['HASH'];
|
||||
$params_val = '';
|
||||
|
||||
$hashparams_arr = explode(':', $hash_params);
|
||||
foreach ($hashparams_arr as $value) {
|
||||
if(!empty($value) && isset($data[$value])){
|
||||
$params_val = $params_val . $data[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$hash_val = $params_val . $this->account->store_key;
|
||||
$hash = base64_encode(sha1($hash_val, true));
|
||||
|
||||
$return = false;
|
||||
if ($hash_params && !($params_val != $hash_params_val || $hash_param != $hash)) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
$contents = '';
|
||||
if (in_array($this->order->transaction, ['pay', 'pre'])) {
|
||||
$contents = $this->createRegularPaymentXML();
|
||||
} elseif ($this->order->transaction == 'post') {
|
||||
$contents = $this->createRegularPostXML();
|
||||
}
|
||||
|
||||
$this->send($contents);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'campaign_url' => null,
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'original' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->check3DHash($this->request->request->all())) {
|
||||
$contents = $this->create3DPaymentXML();
|
||||
$this->send($contents);
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'campaign_url' => null,
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'3d_all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'campaign_url' => null,
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hash' => $this->order->hash,
|
||||
'cardType' => $this->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
'firmaadi' => $this->order->name,
|
||||
'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
];
|
||||
|
||||
if ($this->account->model == '3d_pay') {
|
||||
$inputs = array_merge($inputs, [
|
||||
'islemtipi' => $this->type,
|
||||
'taksit' => $this->order->installment,
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Credit',
|
||||
]
|
||||
];
|
||||
|
||||
if ($meta['amount']) $nodes['Total'] = $meta['amount'];
|
||||
|
||||
$xml = $this->createXML($nodes, 'ISO-8859-9');
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Void',
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERSTATUS' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$first_amount = isset($this->data->Extra->ORIG_TRANS_AMT) ? $this->printData($this->data->Extra->ORIG_TRANS_AMT) : null;
|
||||
$capture_amount = isset($this->data->Extra->CAPTURE_AMT) ? $this->printData($this->data->Extra->CAPTURE_AMT) : null;
|
||||
$capture = $first_amount == $capture_amount ? true : false;
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'host_ref_num' => isset($this->data->Extra->HOST_REF_NUM) ? $this->printData($this->data->Extra->HOST_REF_NUM) : null,
|
||||
'order_status' => isset($this->data->Extra->ORDERSTATUS) ? $this->printData($this->data->Extra->ORDERSTATUS) : null,
|
||||
'process_type' => isset($this->data->Extra->CHARGE_TYPE_CD) ? $this->printData($this->data->Extra->CHARGE_TYPE_CD) : null,
|
||||
'pan' => isset($this->data->Extra->PAN) ? $this->printData($this->data->Extra->PAN) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'first_amount' => $first_amount,
|
||||
'capture_amount' => $capture_amount,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'capture' => $capture,
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERHISTORY' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'trans_count' => isset($this->data->Extra->TRXCOUNT) ? $this->printData($this->data->Extra->TRXCOUNT) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '2';
|
||||
}elseif($this->card->type == '1' || $this->card->type == '2'){
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
}
|
||||
913
app/Core/Payment/Pos/EstPosV3.php
Normal file
913
app/Core/Payment/Pos/EstPosV3.php
Normal file
@@ -0,0 +1,913 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class EstPosV3 implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'EstPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash($inputs)
|
||||
{
|
||||
|
||||
$hash3D = null;
|
||||
$postParams = [];
|
||||
foreach ($inputs as $key => $value){
|
||||
array_push($postParams, $key);
|
||||
}
|
||||
|
||||
natcasesort($postParams);
|
||||
|
||||
$hashval = "";
|
||||
foreach ($postParams as $param){
|
||||
$paramValue = $inputs[$param];
|
||||
$escapedParamValue = str_replace("|", "\\|", str_replace("\\", "\\\\", $paramValue));
|
||||
|
||||
$lowerParam = strtolower($param);
|
||||
if($lowerParam != "hash" && $lowerParam != "encoding" ) {
|
||||
$hashval = $hashval . $escapedParamValue . "|";
|
||||
}
|
||||
}
|
||||
|
||||
$storeKey = $this->account->store_key;
|
||||
$escapedStoreKey = str_replace("|", "\\|", str_replace("\\", "\\\\", $storeKey));
|
||||
$hashval = $hashval . $escapedStoreKey;
|
||||
|
||||
$calculatedHashValue = hash('sha512', $hashval);
|
||||
$hash3D = base64_encode (pack('H*',$calculatedHashValue));
|
||||
|
||||
return $hash3D;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
|
||||
$return = false;
|
||||
|
||||
Log::debug('LOG - 1');
|
||||
Log::debug($data);
|
||||
|
||||
$postParams = [];
|
||||
foreach ($data as $key => $value) {
|
||||
array_push($postParams, $key);
|
||||
}
|
||||
|
||||
natcasesort($postParams);
|
||||
|
||||
$hashval = "";
|
||||
foreach ($postParams as $param) {
|
||||
$paramValue = $data[$param];
|
||||
$escapedParamValue = str_replace("|", "\\|", str_replace("\\", "\\\\", $paramValue));
|
||||
|
||||
$lowerParam = strtolower($param);
|
||||
if ($lowerParam != "hash" && $lowerParam != "encoding") {
|
||||
$hashval = $hashval . $escapedParamValue . "|";
|
||||
}
|
||||
}
|
||||
|
||||
$storeKey = $this->account->store_key;
|
||||
$escapedStoreKey = str_replace("|", "\\|", str_replace("\\", "\\\\", $storeKey));
|
||||
$hashval = $hashval . $escapedStoreKey;
|
||||
|
||||
$calculatedHashValue = hash('sha512', $hashval);
|
||||
$actualHash = base64_encode(pack('H*', $calculatedHashValue));
|
||||
|
||||
$retrievedHash = fillOnUndefined($data,'HASH');
|
||||
|
||||
Log::debug('LOG - 2');
|
||||
Log::debug($data);
|
||||
|
||||
if ($retrievedHash == $actualHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
$contents = '';
|
||||
if (in_array($this->order->transaction, ['pay', 'pre'])) {
|
||||
$contents = $this->createRegularPaymentXML();
|
||||
} elseif ($this->order->transaction == 'post') {
|
||||
$contents = $this->createRegularPostXML();
|
||||
}
|
||||
|
||||
$this->send($contents);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'campaign_url' => null,
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'original' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->check3DHash($this->request->request->all())) {
|
||||
$contents = $this->create3DPaymentXML();
|
||||
$this->send($contents);
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->printData($this->data->GroupId) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->printData($this->data->AuthCode) : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->printData($this->data->HostRefNum) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->Extra->ERRORCODE) : null,
|
||||
'error_message' => isset($this->data->Extra->ERRORCODE) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'campaign_url' => null,
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'extra' => isset($this->data->Extra) ? $this->data->Extra : null,
|
||||
'all' => $this->data,
|
||||
'3d_all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'hashAlgorithm' => (string)$this->request->get('hashAlgorithm'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => ($status != 'approved' && empty((string)$this->request->get('ErrMsg'))) ? (string)$this->request->get('mdErrorMsg') : (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'merchantName' => (string)$this->request->get('merchantName'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$inputs = [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hashAlgorithm' => 'ver3',
|
||||
'cardType' => $this->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
//'firmaadi' => $this->order->name,
|
||||
//'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'callbackUrl' => null,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
'TranType' => 'Auth',
|
||||
'Instalment' => $this->order->installment,
|
||||
];
|
||||
|
||||
$inputs['HASH'] = $this->create3DHash($inputs);
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
//'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Credit',
|
||||
]
|
||||
];
|
||||
|
||||
if ($meta['amount']) $nodes['Total'] = $meta['amount'];
|
||||
|
||||
$xml = $this->createXML($nodes, 'ISO-8859-9');
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Type' => 'Void',
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->data->OrderId : null,
|
||||
'group_id' => isset($this->data->GroupId) ? $this->data->GroupId : null,
|
||||
'response' => isset($this->data->Response) ? $this->data->Response : null,
|
||||
'auth_code' => isset($this->data->AuthCode) ? $this->data->AuthCode : null,
|
||||
'host_ref_num' => isset($this->data->HostRefNum) ? $this->data->HostRefNum : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->data->ProcReturnCode : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->data->TransId : null,
|
||||
'error_code' => isset($this->data->Extra->ERRORCODE) ? $this->data->Extra->ERRORCODE : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->data->ErrMsg : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERSTATUS' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$first_amount = isset($this->data->Extra->ORIG_TRANS_AMT) ? $this->printData($this->data->Extra->ORIG_TRANS_AMT) : null;
|
||||
$capture_amount = isset($this->data->Extra->CAPTURE_AMT) ? $this->printData($this->data->Extra->CAPTURE_AMT) : null;
|
||||
$capture = $first_amount == $capture_amount ? true : false;
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'trans_id' => isset($this->data->TransId) ? $this->printData($this->data->TransId) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'host_ref_num' => isset($this->data->Extra->HOST_REF_NUM) ? $this->printData($this->data->Extra->HOST_REF_NUM) : null,
|
||||
'order_status' => isset($this->data->Extra->ORDERSTATUS) ? $this->printData($this->data->Extra->ORDERSTATUS) : null,
|
||||
'process_type' => isset($this->data->Extra->CHARGE_TYPE_CD) ? $this->printData($this->data->Extra->CHARGE_TYPE_CD) : null,
|
||||
'pan' => isset($this->data->Extra->PAN) ? $this->printData($this->data->Extra->PAN) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'first_amount' => $first_amount,
|
||||
'capture_amount' => $capture_amount,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'capture' => $capture,
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
$xml = $this->createXML([
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'OrderId' => $meta['order_id'],
|
||||
'Extra' => [
|
||||
'ORDERHISTORY' => 'QUERY',
|
||||
],
|
||||
]
|
||||
], 'ISO-8859-9');
|
||||
|
||||
$this->send($xml);
|
||||
|
||||
$status = 'declined';
|
||||
if ($this->getProcReturnCode() == '00') {
|
||||
$status = 'approved';
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'order_id' => isset($this->data->OrderId) ? $this->printData($this->data->OrderId) : null,
|
||||
'response' => isset($this->data->Response) ? $this->printData($this->data->Response) : null,
|
||||
'proc_return_code' => isset($this->data->ProcReturnCode) ? $this->printData($this->data->ProcReturnCode) : null,
|
||||
'error_message' => isset($this->data->ErrMsg) ? $this->printData($this->data->ErrMsg) : null,
|
||||
'num_code' => isset($this->data->Extra->NUMCODE) ? $this->printData($this->data->Extra->NUMCODE) : null,
|
||||
'trans_count' => isset($this->data->Extra->TRXCOUNT) ? $this->printData($this->data->Extra->TRXCOUNT) : null,
|
||||
'status' => $status,
|
||||
'status_detail' => $this->getStatusDetail(),
|
||||
'all' => $this->data,
|
||||
'xml' => $xml,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '2';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
}
|
||||
25
app/Core/Payment/Pos/Exceptions/BankClassNullException.php
Normal file
25
app/Core/Payment/Pos/Exceptions/BankClassNullException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BankClassNullException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class BankClassNullException extends Exception
|
||||
{
|
||||
/**
|
||||
* BankClassNullException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Class must be specified!', $code = 331, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
25
app/Core/Payment/Pos/Exceptions/BankNotFoundException.php
Normal file
25
app/Core/Payment/Pos/Exceptions/BankNotFoundException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BankNotFoundException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class BankNotFoundException extends Exception
|
||||
{
|
||||
/**
|
||||
* BankNotFoundException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Bank not found!', $code = 330, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class UnsupportedPaymentModelException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class UnsupportedPaymentModelException extends Exception
|
||||
{
|
||||
/**
|
||||
* UnsupportedPaymentModelException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Unsupported payment model!', $code = 333, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class UnsupportedTransactionTypeException
|
||||
* @package Mews\Pos\Exceptions
|
||||
*/
|
||||
class UnsupportedTransactionTypeException extends Exception
|
||||
{
|
||||
/**
|
||||
* UnsupportedTransactionTypeException constructor.
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct($message = 'Unsupported transaction type!', $code = 332, Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
1059
app/Core/Payment/Pos/GarantiPos.php
Normal file
1059
app/Core/Payment/Pos/GarantiPos.php
Normal file
File diff suppressed because it is too large
Load Diff
230
app/Core/Payment/Pos/Pos.php
Normal file
230
app/Core/Payment/Pos/Pos.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Exception;
|
||||
use Exceptions\BankClassNullException;
|
||||
use Exceptions\BankNotFoundException;
|
||||
|
||||
/**
|
||||
* Class Pos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class Pos
|
||||
{
|
||||
/**
|
||||
* Global Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $config = [];
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* Order
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Bank Class
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $bank;
|
||||
|
||||
/**
|
||||
* Pos constructor.
|
||||
*
|
||||
* @param array $account
|
||||
* @param array null $config
|
||||
* @throws BankNotFoundException
|
||||
* @throws BankClassNullException
|
||||
*/
|
||||
public function __construct(array $account, array $config = null)
|
||||
{
|
||||
|
||||
// Get Global Configuration
|
||||
$this->config = $config ? $config : require __DIR__ . '/config/pos.php';
|
||||
|
||||
// API Account
|
||||
$this->account = (object) $account;
|
||||
|
||||
// Bank API Exist
|
||||
if ( ! array_key_exists($this->account->bank, $this->config['banks'])) {
|
||||
throw new BankNotFoundException();
|
||||
}
|
||||
|
||||
// Instance Bank Class
|
||||
$this->instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance Bank Class
|
||||
*
|
||||
* @throws BankClassNullException
|
||||
*/
|
||||
public function instance()
|
||||
{
|
||||
// Bank Class
|
||||
$class = $this->config['banks'][$this->account->bank]['class'];
|
||||
|
||||
if ( ! $class) throw new BankClassNullException();
|
||||
|
||||
// Create Bank Class Object
|
||||
$this->bank = new $class($this->config['banks'][$this->account->bank], $this->account, $this->config['currencies']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param array $order
|
||||
* @param array [] $card
|
||||
* @return Pos
|
||||
*/
|
||||
public function prepare(array $order, array $card = [])
|
||||
{
|
||||
// Installment
|
||||
$installment = 0;
|
||||
if (isset($order['installment'])) {
|
||||
$installment = $order['installment'] ? (int) $order['installment'] : 0;
|
||||
}
|
||||
|
||||
// Currency
|
||||
$currency = null;
|
||||
if (isset($order['currency'])) {
|
||||
$currency = (int) $this->config['currencies'][$order['currency']];
|
||||
}
|
||||
|
||||
// Order
|
||||
$this->order = (object) array_merge($order, [
|
||||
'installment' => $installment,
|
||||
'currency' => $currency,
|
||||
]);
|
||||
|
||||
// Card
|
||||
$this->card = $card ? (object) $card : null;
|
||||
|
||||
// Prepare Order
|
||||
$this->bank->prepare($this->order, $this->card);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param array [] $card
|
||||
* @return mixed
|
||||
*/
|
||||
public function payment(array $card = [])
|
||||
{
|
||||
// Credit Card
|
||||
if ($card) {
|
||||
$card = array_merge($card, [
|
||||
'month' => str_pad((int) $card['month'], 2, 0, STR_PAD_LEFT),
|
||||
'year' => str_pad((int) $card['year'], 2, 0, STR_PAD_LEFT),
|
||||
]);
|
||||
}
|
||||
|
||||
$this->card = (object) $card;
|
||||
|
||||
// Make Payment
|
||||
return $this->bank->payment($this->card);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gateway URL
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGatewayUrl()
|
||||
{
|
||||
return isset($this->bank->gateway) ? $this->bank->gateway : 'null';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig(){
|
||||
return $this->bank->getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount(){
|
||||
return $this->bank->getAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies(){
|
||||
return $this->bank->getCurrencies();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder(){
|
||||
return $this->bank->getOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard(){
|
||||
return $this->bank->getCard();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3dFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
try {
|
||||
$data = $this->bank->get3dFormData();
|
||||
} catch (Exception $e) {}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return $this->bank->isSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return $this->bank->isError();
|
||||
}
|
||||
}
|
||||
99
app/Core/Payment/Pos/PosHelpersTrait.php
Normal file
99
app/Core/Payment/Pos/PosHelpersTrait.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use SimpleXMLElement;
|
||||
|
||||
/**
|
||||
* Trait PosHelpersTrait
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
trait PosHelpersTrait
|
||||
{
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Create XML DOM Document
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param string $encoding
|
||||
* @return string the XML, or false if an error occurred.
|
||||
*/
|
||||
public function createXML(array $nodes, $encoding = 'UTF-8')
|
||||
{
|
||||
$rootNodeName = array_keys($nodes)[0];
|
||||
$encoder = new XmlEncoder();
|
||||
|
||||
$xml = $encoder->encode($nodes[$rootNodeName], 'xml', [
|
||||
XmlEncoder::ROOT_NODE_NAME => $rootNodeName,
|
||||
XmlEncoder::ENCODING => $encoding
|
||||
]);
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print Data
|
||||
*
|
||||
* @param $data
|
||||
* @return null|string
|
||||
*/
|
||||
public function printData($data)
|
||||
{
|
||||
if ((is_object($data) || is_array($data)) && !count((array)$data)) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
return (string)$data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
$success = false;
|
||||
if (isset($this->response) && $this->response->status == 'approved') {
|
||||
$success = true;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError()
|
||||
{
|
||||
return !$this->isSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts XML string to object
|
||||
*
|
||||
* @param string data
|
||||
* @return object
|
||||
*/
|
||||
public function XMLStringToObject($data)
|
||||
{
|
||||
$encoder = new XmlEncoder();
|
||||
$xml = $encoder->decode($data, 'xml');
|
||||
return (object)json_decode(json_encode($xml));
|
||||
}
|
||||
}
|
||||
141
app/Core/Payment/Pos/PosInterface.php
Normal file
141
app/Core/Payment/Pos/PosInterface.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Mews\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
|
||||
/**
|
||||
* Interface PosInterface
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
interface PosInterface
|
||||
{
|
||||
/**
|
||||
* PosInterface constructor.
|
||||
*
|
||||
* @param object $config
|
||||
* @param object $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies);
|
||||
|
||||
/**
|
||||
* Create XML DOM Document
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param string $encoding
|
||||
* @return string the XML, or false if an error occurred.
|
||||
*/
|
||||
public function createXML(array $nodes, $encoding = 'UTF-8');
|
||||
|
||||
/**
|
||||
* Print Data
|
||||
*
|
||||
* @param $data
|
||||
* @return null|string
|
||||
*/
|
||||
public function printData($data);
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment();
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment();
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment();
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents);
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order);
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card);
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta);
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta);
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta);
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta);
|
||||
|
||||
/**
|
||||
* Is success
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSuccess();
|
||||
|
||||
/**
|
||||
* Is error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isError();
|
||||
}
|
||||
1106
app/Core/Payment/Pos/PosNet.php
Normal file
1106
app/Core/Payment/Pos/PosNet.php
Normal file
File diff suppressed because it is too large
Load Diff
170
app/Core/Payment/Pos/PosNetCrypt.php
Normal file
170
app/Core/Payment/Pos/PosNetCrypt.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
/**
|
||||
* Class PosNetCrypt
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class PosNetCrypt
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $algo;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $ks;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $block;
|
||||
|
||||
/**
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
* PosNetCrypt constructor.
|
||||
*/
|
||||
public function __construct ()
|
||||
{
|
||||
srand((double) microtime() * 10000000);
|
||||
$this->algo = 'des-ede3-cbc';
|
||||
$this->block = 8;
|
||||
$this->ks = 24;
|
||||
$this->error = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to get encryption errors.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastError ()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function createIV ()
|
||||
{
|
||||
$temp = sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
$temp .= sprintf("%05d", rand());
|
||||
|
||||
return pack("H*", substr($temp, 0, 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $key
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($data, $key)
|
||||
{
|
||||
// Create IV
|
||||
$iv = $this->createIV();
|
||||
|
||||
// Encrypt Data
|
||||
$encrypted_data = openssl_encrypt($data, $this->algo, $this->detKey($key), OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
// Add IV and Convert to HEX
|
||||
$hex_encrypted_data = strtoupper(bin2hex($iv)).strtoupper(bin2hex($encrypted_data));
|
||||
|
||||
// Add CRC
|
||||
$hex_encrypted_data = $this->addCrc($hex_encrypted_data);
|
||||
|
||||
return $hex_encrypted_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $key
|
||||
* @return bool|string
|
||||
*/
|
||||
public function decrypt($data, $key) {
|
||||
|
||||
$parsed_data = $this->parseEncryptedData($data);
|
||||
|
||||
if (!$parsed_data) return false;
|
||||
|
||||
// Check CRC
|
||||
if (!$this->checkCrc($parsed_data['crc_data'], $parsed_data['crc'])) {
|
||||
$this->error = "CRC is not valid! (" . $parsed_data['crc'] . ")";
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get IV
|
||||
$iv = pack("H*", $parsed_data['iv']);
|
||||
|
||||
// Get Encrypted Data
|
||||
$encrypted_data = pack("H*", $parsed_data['payload']);
|
||||
|
||||
// Decrypt Data
|
||||
$decrypted_data = openssl_decrypt($encrypted_data, $this->algo, $this->detKey($key), OPENSSL_RAW_DATA, $iv);
|
||||
|
||||
return $decrypted_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return bool|string
|
||||
*/
|
||||
public function detKey($key)
|
||||
{
|
||||
$deskey = substr(strtoupper(md5($key)), 0, $this->ks);
|
||||
return $deskey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return string
|
||||
*/
|
||||
public function addCrc($data)
|
||||
{
|
||||
$crc = crc32($data);
|
||||
$hex_crc = sprintf("%08x", $crc);
|
||||
$data .= strtoupper($hex_crc);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $crc
|
||||
* @return bool
|
||||
*/
|
||||
public function checkCrc($data, $crc)
|
||||
{
|
||||
$crc_calc = crc32($data);
|
||||
$hex_crc = sprintf("%08x", $crc_calc);
|
||||
$crc_calc = strtoupper($hex_crc);
|
||||
|
||||
return strcmp($crc_calc, $crc) == 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @return array|bool
|
||||
*/
|
||||
private function parseEncryptedData(string $data){
|
||||
|
||||
if (strlen($data) < 16 + 8) return false;
|
||||
|
||||
return [
|
||||
'crc' => substr($data, -8),
|
||||
'crc_data' => substr($data, 0, strlen($data)-8),
|
||||
'iv' => substr($data, 0, 16),
|
||||
'payload' => substr($data, 16, strlen($data)-16-8)
|
||||
];
|
||||
}
|
||||
}
|
||||
644
app/Core/Payment/Pos/QPos.php
Normal file
644
app/Core/Payment/Pos/QPos.php
Normal file
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class QPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $mbrId = 5;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
$hash_str = $this->mbrId . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->merchant_pass;
|
||||
|
||||
return base64_encode(pack('H*', sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
$responseHash = $data['ResponseHash'];
|
||||
|
||||
//MerchantID + MerchantPass + OrderId + AuthCode + ProcReturnCode + 3DStatus + ResponseRnd + UserCode
|
||||
$generatedHash = $this->account->merchant_id . $this->account->merchant_pass . $data['OrderId'] . $data['AuthCode'] . $data['ProcReturnCode'] . $data['3DStatus'] . $data['ResponseRnd'] . $this->account->user_code;
|
||||
$generatedHash = base64_encode(pack('H*', sha1($generatedHash)));
|
||||
|
||||
if ($generatedHash == $responseHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('3DStatus'), [1])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('3DStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('3DStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('RequestGuid'),
|
||||
'trans_id' => (string)$this->request->get('HostRefNum'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
//'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('OrderId'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('3DStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('ResponseHash'),
|
||||
'rand' => (string)$this->request->get('Rnd'),
|
||||
//'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
//'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('CardMask'),
|
||||
//'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
//'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('PurchAmount'),
|
||||
'currency' => (string)$this->request->get('Currency'),
|
||||
'tx_status' => (string)$this->request->get('TxnStatus'),
|
||||
'eci' => (string)$this->request->get('Eci'),
|
||||
'cavv' => (string)$this->request->get('CavvResult'),
|
||||
//'xid' => (string)$this->request->get('xid'),
|
||||
//'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
//'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('MrcName'),
|
||||
//'email' => (string)$this->request->get('Email'),
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'response_rnd' => $this->request->get('ResponseRnd'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'MbrId' => $this->mbrId,
|
||||
'MerchantID' => $this->account->merchant_id,
|
||||
'UserCode' => $this->account->user_code,
|
||||
'UserPass' => $this->account->user_pass,
|
||||
'SecureType' => $this->account->model == '3d_pay' ? '3DPay' : '3D',
|
||||
'TxnType' => $this->type,
|
||||
'InstallmentCount' => $this->order->installment,
|
||||
'Currency' => $this->order->currency,
|
||||
'OkUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->fail_url,
|
||||
'OrderId' => $this->order->id,
|
||||
'PurchAmount' => $this->order->amount,
|
||||
'Lang' => $this->order->lang,
|
||||
'Rnd' => $this->order->rand,
|
||||
'Hash' => $this->order->hash,
|
||||
'Pan' => $this->card->number,
|
||||
'Cvv2' => $this->card->cvv,
|
||||
'Expiry' => $this->getCardExpDate(),
|
||||
];
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
656
app/Core/Payment/Pos/VPos.php
Normal file
656
app/Core/Payment/Pos/VPos.php
Normal file
@@ -0,0 +1,656 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Class EstPos
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class VPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
|
||||
if ($this->account->model == '3d') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->order->rand . $this->account->store_key;
|
||||
} elseif ($this->account->model == '3d_pay') {
|
||||
$hash_str = $this->account->client_id . $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->store_key;
|
||||
}
|
||||
|
||||
return base64_encode(pack('H*',sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$hash_params = $data['HASHPARAMS'];
|
||||
$hash_params_val = $data['HASHPARAMSVAL'];
|
||||
$hash_param = $data['HASH'];
|
||||
$params_val = '';
|
||||
|
||||
$hashparams_arr = explode(':', $hash_params);
|
||||
foreach ($hashparams_arr as $value) {
|
||||
if(!empty($value) && isset($data[$value])){
|
||||
$params_val = $params_val . $data[$value];
|
||||
}
|
||||
}
|
||||
|
||||
$hash_val = $params_val . $this->account->store_key;
|
||||
$hash = base64_encode(sha1($hash_val, true));
|
||||
|
||||
$return = false;
|
||||
if ($hash_params && !($params_val != $hash_params_val || $hash_param != $hash)) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
|
||||
$status = 'declined';
|
||||
|
||||
if ($this->check3DHash($this->request->request->all()) && (string)$this->request->get('ProcReturnCode') == '00') {
|
||||
if (in_array($this->request->get('mdStatus'), [1, 2, 3, 4])) {
|
||||
$status = 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
$transaction_security = 'MPI fallback';
|
||||
if ($status == 'approved') {
|
||||
if ($this->request->get('mdStatus') == '1') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif (in_array($this->request->get('mdStatus'), [2, 3, 4])) {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => (string)$this->request->get('AuthCode'),
|
||||
'trans_id' => (string)$this->request->get('TransId'),
|
||||
'auth_code' => (string)$this->request->get('AuthCode'),
|
||||
'host_ref_num' => (string)$this->request->get('HostRefNum'),
|
||||
'response' => (string)$this->request->get('Response'),
|
||||
'order_id' => (string)$this->request->get('oid'),
|
||||
'transaction_type' => $this->type,
|
||||
'transaction' => $this->order->transaction,
|
||||
'transaction_security' => $transaction_security,
|
||||
'code' => (string)$this->request->get('ProcReturnCode'),
|
||||
'md_status' => $this->request->get('mdStatus'),
|
||||
'status' => $status,
|
||||
'status_detail' => isset($this->codes[$this->request->get('ProcReturnCode')]) ? (string)$this->request->get('ProcReturnCode') : null,
|
||||
'hash' => (string)$this->request->get('HASH'),
|
||||
'rand' => (string)$this->request->get('rnd'),
|
||||
'hash_params' => (string)$this->request->get('HASHPARAMS'),
|
||||
'hash_params_val' => (string)$this->request->get('HASHPARAMSVAL'),
|
||||
'masked_number' => (string)$this->request->get('maskedCreditCard'),
|
||||
'month' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Month'),
|
||||
'year' => (string)$this->request->get('Ecom_Payment_Card_ExpDate_Year'),
|
||||
'amount' => (string)$this->request->get('amount'),
|
||||
'currency' => (string)$this->request->get('currency'),
|
||||
'tx_status' => (string)$this->request->get('txstatus'),
|
||||
'eci' => (string)$this->request->get('eci'),
|
||||
'cavv' => (string)$this->request->get('cavv'),
|
||||
'xid' => (string)$this->request->get('xid'),
|
||||
'error_code' => (string)$this->request->get('ErrCode'),
|
||||
'error_message' => (string)$this->request->get('ErrMsg'),
|
||||
'md_error_message' => (string)$this->request->get('mdErrorMsg'),
|
||||
'name' => (string)$this->request->get('firmaadi'),
|
||||
'email' => (string)$this->request->get('Email'),
|
||||
'campaign_url' => null,
|
||||
'extra' => $this->request->get('Extra'),
|
||||
'all' => $this->request->request->all(),
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
if ($this->order) {
|
||||
$this->order->hash = $this->create3DHash();
|
||||
|
||||
$inputs = [
|
||||
'Version3D' => '2.0',
|
||||
'ShopCode' => $this->account->client_id,
|
||||
'PurchAmount' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'OrderId' => $this->order->id,
|
||||
'OkUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->fail_url,
|
||||
'Rnd' => $this->order->rand,
|
||||
'Hash' => $this->order->hash,
|
||||
'TxnType' => $this->type,
|
||||
'Pan' => $this->card->number,
|
||||
'Cvv2' => $this->card->cvv,
|
||||
'Expiry' => $this->getCardExpDate(),
|
||||
'CardType' => $this->getCardCode(),
|
||||
'BonusAmount' => '',
|
||||
'Lang' => $this->order->lang
|
||||
];
|
||||
|
||||
if ($this->account->model == '3d_pay') {
|
||||
$inputs = array_merge($inputs, [
|
||||
'SecureType' => '3DPay',
|
||||
'InstallmentCount' => $this->order->installment,
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'gateway' => $this->gateway,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->order->hash,
|
||||
'inputs' => $inputs,
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? '' : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
}elseif($this->card->type == '1' || $this->card->type == '2'){
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string) substr($this->card->year, 2,2);
|
||||
$month = (string) substr($this->card->month, 0,2);
|
||||
|
||||
return (string) $month . $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
689
app/Core/Payment/Pos/VkfPos.php
Normal file
689
app/Core/Payment/Pos/VkfPos.php
Normal file
@@ -0,0 +1,689 @@
|
||||
<?php
|
||||
|
||||
namespace App\Core\Payment\Pos;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedPaymentModelException;
|
||||
use App\Core\Payment\Pos\Exceptions\UnsupportedTransactionTypeException;
|
||||
use App\Core\Payment\Pos\PosHelpersTrait;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class VkfPOS
|
||||
* @package Mews\Pos
|
||||
*/
|
||||
class VkfPos implements PosInterface
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
/**
|
||||
* @const string
|
||||
*/
|
||||
public const NAME = 'VPos';
|
||||
|
||||
/**
|
||||
* API URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* 3D Pay Gateway URL
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gateway;
|
||||
|
||||
/**
|
||||
* Response Codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $codes = [
|
||||
'00' => 'approved',
|
||||
'01' => 'bank_call',
|
||||
'02' => 'bank_call',
|
||||
'05' => 'reject',
|
||||
'09' => 'try_again',
|
||||
'12' => 'invalid_transaction',
|
||||
'28' => 'reject',
|
||||
'51' => 'insufficient_balance',
|
||||
'54' => 'expired_card',
|
||||
'57' => 'does_not_allow_card_holder',
|
||||
'62' => 'restricted_card',
|
||||
'77' => 'request_rejected',
|
||||
'99' => 'general_error',
|
||||
];
|
||||
|
||||
/**
|
||||
* Transaction Types
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
'pay' => 'Auth',
|
||||
'pre' => 'PreAuth',
|
||||
'post' => 'PostAuth',
|
||||
];
|
||||
|
||||
/**
|
||||
* Currencies
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $currencies = [];
|
||||
|
||||
/**
|
||||
* Transaction Type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* API Account
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $account = [];
|
||||
|
||||
/**
|
||||
* Order Details
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order = [];
|
||||
|
||||
/**
|
||||
* Credit Card
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $card;
|
||||
|
||||
/**
|
||||
* Request
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Response Raw Data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* Processed Response Data
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $client;
|
||||
|
||||
/**
|
||||
* EstPos constructor.
|
||||
*
|
||||
* @param array $config
|
||||
* @param mixed $account
|
||||
* @param array $currencies
|
||||
*/
|
||||
public function __construct($config, $account, array $currencies)
|
||||
{
|
||||
$client = new Client();
|
||||
$this->client = $client;
|
||||
$this->config = $config;
|
||||
$this->account = $account;
|
||||
$this->currencies = $currencies;
|
||||
|
||||
$this->url = isset($this->config['urls'][$this->account->env]) ?
|
||||
$this->config['urls'][$this->account->env] :
|
||||
$this->config['urls']['production'];
|
||||
|
||||
$this->gateway = isset($this->config['urls']['gateway'][$this->account->env]) ?
|
||||
$this->config['urls']['gateway'][$this->account->env] :
|
||||
$this->config['urls']['gateway']['production'];
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'CardType' => isset($this->card->type) ? $this->card->type : null,
|
||||
'Number' => $this->card->number,
|
||||
'Expires' => $this->card->month . '/' . $this->card->year,
|
||||
'Cvv2Val' => $this->card->cvv,
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
'BillTo' => [
|
||||
'Name' => $this->order->name ? $this->order->name : null,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Regular Payment Post XML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createRegularPostXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->types[$this->order->transaction],
|
||||
'OrderId' => $this->order->id,
|
||||
]
|
||||
];
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Payment XML
|
||||
* @return string
|
||||
*/
|
||||
protected function create3DPaymentXML()
|
||||
{
|
||||
$nodes = [
|
||||
'CC5Request' => [
|
||||
'Name' => $this->account->username,
|
||||
'Password' => $this->account->password,
|
||||
'ClientId' => $this->account->client_id,
|
||||
'Type' => $this->type,
|
||||
'IPAddress' => $this->order->ip,
|
||||
'Email' => $this->order->email,
|
||||
'OrderId' => $this->order->id,
|
||||
'UserId' => isset($this->order->user_id) ? $this->order->user_id : null,
|
||||
'Total' => $this->order->amount,
|
||||
'Currency' => $this->order->currency,
|
||||
'Taksit' => $this->order->installment,
|
||||
'Number' => $this->request->get('md'),
|
||||
'Expires' => '',
|
||||
'Cvv2Val' => '',
|
||||
'PayerTxnId' => $this->request->get('xid'),
|
||||
'PayerSecurityLevel' => $this->request->get('eci'),
|
||||
'PayerAuthenticationCode' => $this->request->get('cavv'),
|
||||
'CardholderPresentCode' => '13',
|
||||
'Mode' => 'P',
|
||||
'GroupId' => '',
|
||||
'TransId' => '',
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->order->name) {
|
||||
$nodes['BillTo'] = [
|
||||
'Name' => $this->order->name,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->createXML($nodes, 'ISO-8859-9');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProcReturnCode
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getProcReturnCode()
|
||||
{
|
||||
return isset($this->data->ProcReturnCode) ? (string)$this->data->ProcReturnCode : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status Detail Text
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getStatusDetail()
|
||||
{
|
||||
$proc_return_code = $this->getProcReturnCode();
|
||||
|
||||
return $proc_return_code ? (isset($this->codes[$proc_return_code]) ? (string)$this->codes[$proc_return_code] : null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create 3D Hash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create3DHash()
|
||||
{
|
||||
$hash_str = '';
|
||||
$hash_str = $this->order->id . $this->order->amount . $this->order->success_url . $this->order->fail_url . $this->type . $this->order->installment . $this->order->rand . $this->account->merchant_pass;
|
||||
|
||||
return base64_encode(pack('H*', sha1($hash_str)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check 3D Hash
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function check3DHash($data)
|
||||
{
|
||||
$return = false;
|
||||
$responseHash = $data['ResponseHash'];
|
||||
|
||||
//MerchantID + MerchantPass + OrderId + AuthCode + ProcReturnCode + 3DStatus + ResponseRnd + UserCode
|
||||
$generatedHash = $this->account->merchant_id . $this->account->merchant_pass . $data['OrderId'] . $data['AuthCode'] . $data['ProcReturnCode'] . $data['3DStatus'] . $data['ResponseRnd'] . $this->account->user_code;
|
||||
$generatedHash = base64_encode(pack('H*', sha1($generatedHash)));
|
||||
|
||||
if ($generatedHash == $responseHash) {
|
||||
$return = true;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regular Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function makeRegularPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Payment
|
||||
*
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function make3DPayment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make 3D Pay Payment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function make3DPayPayment()
|
||||
{
|
||||
$this->request = Request::createFromGlobals();
|
||||
$requestAll = $this->request->request->all();
|
||||
$ipAddress = $this->request->getClientIp();
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r($this->order);
|
||||
die();*/
|
||||
|
||||
$paymentCheck = null;
|
||||
$status = 'declined';
|
||||
$transaction_security = 'MPI fallback';
|
||||
$errorMessage = null;
|
||||
|
||||
try {
|
||||
|
||||
$requestParam = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><VposRequest></VposRequest>');
|
||||
|
||||
$requestParam->addChild('MerchantId', $this->account->merchant_id);
|
||||
$requestParam->addChild('Password', $this->account->merchant_password);
|
||||
$requestParam->addChild('TerminalNo', $this->account->terminal_no);
|
||||
$requestParam->addChild('TransactionType', 'Sale');
|
||||
$requestParam->addChild('OrderId', $this->order->id);
|
||||
$requestParam->addChild('CurrencyAmount', number_format(($requestAll['PurchAmount'] / 100), 2, '.', ''));
|
||||
$requestParam->addChild('CurrencyCode', $requestAll['PurchCurrency']);
|
||||
$requestParam->addChild('Pan', $requestAll['Pan']);
|
||||
$requestParam->addChild('Expiry', $this->order->creditCardYear . $this->order->creditCardMonth);
|
||||
$requestParam->addChild('Cvv', $this->order->creditCardYearCvv);
|
||||
$requestParam->addChild('ECI', $requestAll['Eci']);
|
||||
$requestParam->addChild('CAVV', $requestAll['Cavv']);
|
||||
$requestParam->addChild('MpiTransactionId', $requestAll['VerifyEnrollmentRequestId']);
|
||||
$requestParam->addChild('ClientIp', $ipAddress);
|
||||
$requestParam->addChild('TransactionDeviceSource', 0);
|
||||
|
||||
if (!empty($requestAll['InstallmentCount'])) {
|
||||
$requestParam->addChild('NumberOfInstallments', $requestAll['InstallmentCount']);
|
||||
}
|
||||
|
||||
$payment = $this->client->request('POST', $this->url, [
|
||||
'form_params' => ['prmstr' => $requestParam->asXML()]
|
||||
]);
|
||||
|
||||
$paymentCheck = $this->XMLStringToObject($payment->getBody()->getContents());
|
||||
|
||||
if ($paymentCheck->ResultCode == '0000') {
|
||||
$status = 'approved';
|
||||
} else {
|
||||
$errorMessage = $paymentCheck->ResultDetail;
|
||||
}
|
||||
|
||||
if ($paymentCheck->ThreeDSecureType == '2') {
|
||||
$transaction_security = 'Full 3D Secure';
|
||||
} elseif ($paymentCheck->ThreeDSecureType == '3') {
|
||||
$transaction_security = 'Half 3D Secure';
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error($this->account->bank . ' Error!');
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->response = (object)[
|
||||
'id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'trans_id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'auth_code' => isset($paymentCheck->AuthCode) ? (string)$paymentCheck->AuthCode : null,
|
||||
'host_ref_num' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'order_id' => isset($paymentCheck->TransactionId) ? (string)$paymentCheck->TransactionId : null,
|
||||
'status' => $status,
|
||||
'response' => $paymentCheck,
|
||||
'transaction_security' => $transaction_security,
|
||||
'error_code' => isset($paymentCheck->ResultCode) ? (string)$paymentCheck->ResultCode : null,
|
||||
'error_message' => $errorMessage,
|
||||
'all' => $paymentCheck
|
||||
];
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r($this->response);
|
||||
die();*/
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 3d Form Data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get3DFormData()
|
||||
{
|
||||
$threeDFormData = [];
|
||||
|
||||
try {
|
||||
|
||||
if ($this->order) {
|
||||
|
||||
$threeDCheckParam = [
|
||||
'Pan' => $this->card->number,
|
||||
'ExpiryDate' => $this->getCardExpDate(),
|
||||
'PurchaseAmount' => number_format(($this->order->amount * 100 / 100), 2, '.', ''),
|
||||
'Currency' => $this->order->currency,
|
||||
'BrandName' => null,
|
||||
'VerifyEnrollmentRequestId' => $this->order->id,
|
||||
'MerchantId' => $this->account->merchant_id,
|
||||
'MerchantPassword' => $this->account->merchant_password,
|
||||
'SuccessUrl' => $this->order->success_url,
|
||||
'FailUrl' => $this->order->success_url,
|
||||
];
|
||||
|
||||
$response = $this->client->request('POST', $this->gateway, [
|
||||
'form_params' => $threeDCheckParam
|
||||
]);
|
||||
|
||||
$threeDCheck = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
if ($threeDCheck->MessageErrorCode != 200) {
|
||||
throw new Exception($threeDCheck->MessageErrorCode . ' - ' . $threeDCheck->ErrorMessage);
|
||||
}
|
||||
|
||||
$threeDFormData = [
|
||||
'status' => $threeDCheck->Message->VERes->Status,
|
||||
'gateway' => $threeDCheck->Message->VERes->ACSUrl,
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->success_url,
|
||||
'inputs' => [
|
||||
'PaReq' => $threeDCheck->Message->VERes->PaReq,
|
||||
'TermUrl' => $threeDCheck->Message->VERes->TermUrl,
|
||||
'MD' => $threeDCheck->Message->VERes->MD
|
||||
]
|
||||
];
|
||||
|
||||
if ($threeDFormData['status'] != 'Y') {
|
||||
throw new Exception('3D Secure is not supported for this card.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error($this->account->bank . ' Error!');
|
||||
Log::error($e->getMessage());
|
||||
$threeDFormData = [];
|
||||
}
|
||||
|
||||
return $threeDFormData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contents to WebService
|
||||
*
|
||||
* @param $contents
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send($contents)
|
||||
{
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->request('POST', $this->url, [
|
||||
'body' => $contents
|
||||
]);
|
||||
|
||||
$this->data = $this->XMLStringToObject($response->getBody()->getContents());
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Order
|
||||
*
|
||||
* @param object $order
|
||||
* @param object null $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedTransactionTypeException
|
||||
*/
|
||||
public function prepare($order, $card = null)
|
||||
{
|
||||
$this->type = $this->types['pay'];
|
||||
if (isset($order->transaction)) {
|
||||
if (array_key_exists($order->transaction, $this->types)) {
|
||||
$this->type = $this->types[$order->transaction];
|
||||
} else {
|
||||
throw new UnsupportedTransactionTypeException('Unsupported transaction type!');
|
||||
}
|
||||
}
|
||||
|
||||
$this->order = $order;
|
||||
$this->card = $card;
|
||||
|
||||
$this->order->installment = $this->order->installment == 0 ? 0 : $this->order->installment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Payment
|
||||
*
|
||||
* @param object $card
|
||||
* @return mixed
|
||||
* @throws UnsupportedPaymentModelException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function payment($card)
|
||||
{
|
||||
$this->card = $card;
|
||||
|
||||
$model = 'regular';
|
||||
if (isset($this->account->model) && $this->account->model) {
|
||||
$model = $this->account->model;
|
||||
}
|
||||
|
||||
if ($model == 'regular') {
|
||||
$this->makeRegularPayment();
|
||||
} elseif ($model == '3d') {
|
||||
$this->make3DPayment();
|
||||
} elseif ($model == '3d_pay') {
|
||||
$this->make3DPayPayment();
|
||||
} else {
|
||||
throw new UnsupportedPaymentModelException();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refund Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refund(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Order
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function cancel(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function status(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order History
|
||||
*
|
||||
* @param array $meta
|
||||
* @return $this
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function history(array $meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAccount()
|
||||
{
|
||||
return $this->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencies()
|
||||
{
|
||||
return $this->currencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCardCode()
|
||||
{
|
||||
$card_type = null;
|
||||
if (isset($this->card->type)) {
|
||||
if ($this->card->type == 'visa') {
|
||||
$card_type = '0';
|
||||
} elseif ($this->card->type == 'master') {
|
||||
$card_type = '1';
|
||||
} elseif ($this->card->type == '1' || $this->card->type == '2') {
|
||||
$card_type = $this->card->type;
|
||||
}
|
||||
}
|
||||
return $card_type;
|
||||
}
|
||||
|
||||
protected function getCardExpDate()
|
||||
{
|
||||
$year = (string)substr($this->card->year, 2, 2);
|
||||
$month = (string)substr($this->card->month, 0, 2);
|
||||
|
||||
return (string)$year . $month;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
202
app/Core/Payment/Pos/config/pos.php
Normal file
202
app/Core/Payment/Pos/config/pos.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Payment\Pos\EstPos;
|
||||
use App\Core\Payment\Pos\GarantiPos;
|
||||
use App\Core\Payment\Pos\PosNet;
|
||||
use App\Core\Payment\Pos\VPos;
|
||||
use App\Core\Payment\Pos\QPos;
|
||||
use App\Core\Payment\Pos\VkfPos;
|
||||
use App\Core\Payment\Pos\EstPosV3;
|
||||
use App\Core\Payment\Pos\AkPos;
|
||||
|
||||
return [
|
||||
|
||||
// Currencies
|
||||
'currencies' => [
|
||||
'TRY' => 949,
|
||||
'USD' => 840,
|
||||
'EUR' => 978,
|
||||
'GBP' => 826,
|
||||
'JPY' => 392,
|
||||
'RUB' => 643,
|
||||
],
|
||||
|
||||
// Banks
|
||||
'banks' => [
|
||||
'akbank' => [
|
||||
'name' => 'AKBANK T.A.S.', ////Test - 5571135571135575, 12, 2026, 000, a
|
||||
'class' => AkPos::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://api.akbank.com/api/v1/payment/virtualpos/transaction/process',
|
||||
'test' => 'https://apipre.akbank.com/api/v1/payment/virtualpos/transaction/process',
|
||||
'gateway' => [
|
||||
'production' => 'https://virtualpospaymentgateway.akbank.com/securepay',
|
||||
'test' => 'https://virtualpospaymentgatewaypre.akbank.com/securepay',
|
||||
],
|
||||
]
|
||||
],
|
||||
'denizbank' => [ //https://test.inter-vpos.com.tr, 3123, InterTest11, InterTest11
|
||||
'name' => 'DENIZ BANK', //Test - 4090700090840057, 11, 2022, 592, 123
|
||||
'class' => VPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://spos.denizbank.com/mpi/Default.aspx',
|
||||
'test' => 'https://sanaltest.denizbank.com/mpi/Default.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://spos.denizbank.com/mpi/Default.aspx',
|
||||
'test' => 'https://sanaltest.denizbank.com/mpi/Default.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'ziraat' => [
|
||||
'name' => 'Ziraat Bankası',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos2.ziraatbank.com.tr/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'finansbank' => [
|
||||
'name' => 'QNB Finansbank',
|
||||
'class' => QPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://vpos.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
'test' => 'https://vpostest.qnbfinansbank.com/Gateway/Default.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'vakifbank' => [
|
||||
'name' => 'Vakıfbank',
|
||||
'class' => VkfPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://onlineodeme.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
|
||||
'test' => 'https://onlineodemetest.vakifbank.com.tr:4443/VposService/v3/Vposreq.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://3dsecure.vakifbank.com.tr/MPIAPI/MPI_Enrollment.aspx',
|
||||
'test' => 'https://3dsecuretest.vakifbank.com.tr/MPIAPI/MPI_Enrollment.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'turkiyefinans' => [ //TODO: Check this infos
|
||||
'name' => 'Türkiye Finans',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://www.fbwebpos.com/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://www.fbwebpos.com/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'halkbank' => [
|
||||
'name' => 'Halkbank',
|
||||
'class' => EstPosV3::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.halkbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.halkbank.com.tr/fim/est3dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'teb' => [
|
||||
'name' => 'TEB',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.teb.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.teb.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'ingbank' => [
|
||||
'name' => 'ING Bank',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.ingbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.ingbank.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'isbank' => [
|
||||
'name' => 'İşbank',
|
||||
'class' => EstPosV3::class,//EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalpos.isbank.com.tr/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalpos.isbank.com.tr/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
'isbank-payflex' => [
|
||||
'name' => 'İşbank - PayFlex',
|
||||
'class' => Mews\Pos\PayFlex::class,
|
||||
'urls' => [
|
||||
'production' => 'https://trx.payflex.com.tr/VposWeb/v3/Vposreq.aspx',
|
||||
'test' => 'https://sanalpos.innova.com.tr/ISBANK_v4/VposWeb/v3/Vposreq.aspx',
|
||||
'gateway' => [
|
||||
'production' => 'https://mpi.vpos.isbank.com.tr/MPIEnrollment.aspx',
|
||||
'test' => 'https://sanalpos.innova.com.tr/ISBANK/MpiWeb/Enrollment.aspx',
|
||||
],
|
||||
]
|
||||
],
|
||||
'yapikredi' => [
|
||||
'name' => 'Yapıkredi',
|
||||
'class' => PosNet::class,
|
||||
'urls' => [
|
||||
'production' => 'https://posnet.yapikredi.com.tr/PosnetWebService/XML',
|
||||
'test' => 'https://setmpos.ykb.com/PosnetWebService/XML',
|
||||
'gateway' => [
|
||||
'production' => 'https://posnet.yapikredi.com.tr/3DSWebService/YKBPaymentService',
|
||||
'test' => 'https://setmpos.ykb.com/3DSWebService/YKBPaymentService',
|
||||
],
|
||||
],
|
||||
'order' => [
|
||||
'id_total_length' => 24,
|
||||
'id_length' => 20,
|
||||
'id_3d_prefix' => 'TDSC',
|
||||
'id_3d_pay_prefix' => '', //?
|
||||
'id_regular_prefix' => '' //?
|
||||
]
|
||||
],
|
||||
'garanti' => [
|
||||
'name' => 'Garanti',
|
||||
'class' => GarantiPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://sanalposprov.garanti.com.tr/VPServlet',
|
||||
'test' => 'https://sanalposprovtest.garanti.com.tr/VPServlet',
|
||||
'gateway' => [
|
||||
'production' => 'https://sanalposprov.garanti.com.tr/servlet/gt3dengine',
|
||||
'test' => 'https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine',
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
//STRIPE
|
||||
//4000000000003063 3D required
|
||||
//4000000000003089 3D recommended
|
||||
//4000000000003055 3d optional
|
||||
//378282246310005 3d not_supported direct pay
|
||||
|
||||
//Vakıfbank
|
||||
//4938460158754205 2024/11 715 123456
|
||||
//4119790155203496 2024/04 579 123456
|
||||
//4119790166544284 2024/04 961 123456
|
||||
//6501700161161969 2024/11 390 123456
|
||||
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
4
app/Core/Payment/Pos/ex/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
composer.lock
|
||||
/vendor
|
||||
/.idea
|
||||
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
3
app/Core/Payment/Pos/ex/LICENCE.md
Normal file
@@ -0,0 +1,3 @@
|
||||
© 2018 Muharrem ERİN (me@mewebstudio.com)
|
||||
|
||||
http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
21
app/Core/Payment/Pos/ex/LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 MeWebStudio - Muharrem ERİN
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
190
app/Core/Payment/Pos/ex/README.md
Normal file
190
app/Core/Payment/Pos/ex/README.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# Türk bankaları için sanal pos paketi (PHP)
|
||||
|
||||
Bu paket ile amaçlanan; ortak bir arayüz sınıfı ile, tüm Türk banka sanal pos sistemlerinin kullanılabilmesidir.
|
||||
EST altyapısı tam olarak test edilmiş ve kullanıma hazırdır.
|
||||
Garanti Ödeme sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
YapıKredi Posnet sistemi çalışmaktadır, fakat 3D ödeme kısmının üretim ortamında test edilmesi gerekiyor.
|
||||
|
||||
> EST altyapısında olan Akbank ve Ziraat bankası test edilmiştir.
|
||||
|
||||
### Özellikler
|
||||
- Standart E-Commerce modeliyle ödeme (model => regular)
|
||||
- 3D modeliyle ödeme (model => 3d)
|
||||
- 3D Pay modeliyle ödeme (model => 3d_pay)
|
||||
- Sipariş/Ödeme sorgulama (query)
|
||||
- Sipariş/Ödeme geçmişi sorgulama (history)
|
||||
- Sipariş/Para iadesi yapma (refund)
|
||||
- Sipariş iptal etme (cancel)
|
||||
|
||||
### Minimum Gereksinimler
|
||||
- PHP >= 7.1.3
|
||||
- ext-dom
|
||||
- ext-json
|
||||
- ext-openssl
|
||||
- ext-SimpleXML
|
||||
|
||||
### Kurulum
|
||||
Test sunucunuz üzerinde;
|
||||
```sh
|
||||
$ mkdir pos-test && cd pos-test
|
||||
$ composer require mews/pos
|
||||
```
|
||||
|
||||
**config.php (Ayar dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require './vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos-test/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
// API kullanıcı bilgileri
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXXX',
|
||||
'username' => 'XXXXXXXX',
|
||||
'password' => 'XXXXXXXX',
|
||||
'env' => 'test', // test veya production. test ise; API Test Url, production ise; API Production URL kullanılır.
|
||||
];
|
||||
|
||||
// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
exit();
|
||||
}
|
||||
```
|
||||
|
||||
**test.php (Test Dosyası)**
|
||||
```php
|
||||
<?php
|
||||
|
||||
require 'config.php';
|
||||
|
||||
// Sipariş bilgileri
|
||||
$order = [
|
||||
'id' => 'BENZERSIZ-SIPERIS-ID',
|
||||
'name' => 'John Doe', // zorunlu değil
|
||||
'email' => 'mail@customer.com', // zorunlu değil
|
||||
'user_id' => '12', // zorunlu değil
|
||||
'amount' => (double) 20, // Sipariş tutarı
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth (Direkt satış için pay, ön provizyon için pre)
|
||||
];
|
||||
|
||||
// Kredi kartı bilgieri
|
||||
$card = [
|
||||
'number' => 'XXXXXXXXXXXXXXXX', // Kredi kartı numarası
|
||||
'month' => 'XX', // SKT ay
|
||||
'year' => 'XX', // SKT yıl, son iki hane
|
||||
'cvv' => 'XXX', // Güvenlik kodu, son üç hane
|
||||
];
|
||||
|
||||
// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri gönderiliyor
|
||||
$pos->prepare($order);
|
||||
|
||||
// Ödeme tamamlanıyor
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
// Ödeme başarılı mı?
|
||||
$payment->isSuccess();
|
||||
//veya
|
||||
$pos->isSuccess();
|
||||
|
||||
// Ödeme başarısız mı?
|
||||
$payment->isError();
|
||||
//veya
|
||||
$pos->isError();
|
||||
|
||||
// Sonuç çıktısı
|
||||
var_dump($payment->response);
|
||||
|
||||
````
|
||||
|
||||
### Farklı Banka Sanal Poslarını Eklemek
|
||||
Kendi projenizin dizinindeyken
|
||||
```sh
|
||||
$ cp ./vendor/mews/pos/config/pos.php ./pos_ayarlar.php
|
||||
```
|
||||
ya da;
|
||||
|
||||
Projenizde bir ayar dosyası oluşturup (pos_ayarlar.php gibi), paket içerisinde `./config/pos.php` dosyasının içeriğini buraya kopyalayın.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
return [
|
||||
// Para birimleri
|
||||
'currencies' => [
|
||||
'TRY' => 949,
|
||||
'USD' => 840,
|
||||
'EUR' => 978,
|
||||
'GBP' => 826,
|
||||
'JPY' => 392,
|
||||
'RUB' => 643,
|
||||
],
|
||||
|
||||
// Banka sanal pos tanımlamaları
|
||||
'banks' => [
|
||||
'akbank' => [
|
||||
'name' => 'AKBANK T.A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class,
|
||||
'urls' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/api',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/api',
|
||||
'gateway' => [
|
||||
'production' => 'https://www.sanalakpos.com/fim/est3Dgate',
|
||||
'test' => 'https://entegrasyon.asseco-see.com.tr/fim/est3Dgate',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
// Yeni eklenen banka
|
||||
'isbank' => [
|
||||
'name' => 'İŞ BANKASI .A.S.',
|
||||
'class' => \Mews\Pos\EstPos::class, // Altyapı sınıfı
|
||||
'urls' => [
|
||||
'production' => 'xxxx', // API Url
|
||||
'test' => 'xxxx', // API Test Url
|
||||
'gateway' => [
|
||||
'production' => 'xxxx', // 3d Kapı Url
|
||||
'test' => 'xxxx', // 3d Test Kapı Url
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
```
|
||||
|
||||
Bundan sonra nesnemizi, yeni ayarlarımıza göre oluşturup kullanmamız gerekir. Örnek:
|
||||
```php
|
||||
$yeni_ayarlar = require './pos_ayarlar.php';
|
||||
$pos = new \Mews\Pos\Pos($account, $yeni_ayarlar);
|
||||
```
|
||||
|
||||
### Örnek Kodlar
|
||||
`./pos/examples` dizini içerisinde.
|
||||
|
||||
### Yol Haritası
|
||||
- Dökümantasyon hazırlanacak
|
||||
- UnitTest yazılacak -> Bu hiçbir zaman olmayabilir, birisi el atarsa sevinirim :)
|
||||
|
||||
> Değerli yorum, öneri ve katkılarınızı bekliyorum.
|
||||
|
||||
License
|
||||
----
|
||||
|
||||
MIT
|
||||
31
app/Core/Payment/Pos/ex/composer.json
Normal file
31
app/Core/Payment/Pos/ex/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "mews/pos",
|
||||
"description": "Türk bankaları için sanal pos kütüphanesi",
|
||||
"keywords": ["pos", "sanal pos", "est", "est pos", "akbank"],
|
||||
"homepage": "https://github.com/mewebstudio/pos",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Muharrem ERİN",
|
||||
"email": "me@mewebstudio.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-dom": "*",
|
||||
"ext-json": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-SimpleXML": "*",
|
||||
"guzzlehttp/guzzle": "^6.3.3",
|
||||
"symfony/http-foundation": "^5.0",
|
||||
"symfony/serializer": "^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Mews\\Pos\\": "src/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.0"
|
||||
}
|
||||
}
|
||||
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
30
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/_config.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d-pay/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
32
app/Core/Payment/Pos/ex/examples/akbank/3d/_config.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/akbank/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 320;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/akbank/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/akbank/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
31
app/Core/Payment/Pos/ex/examples/akbank/regular/_config.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/cancel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181029A3C1',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4355084355084358',
|
||||
'month' => '12',
|
||||
'year' => '18',
|
||||
'cvv' => '000',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '201810297189',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
48
app/Core/Payment/Pos/ex/examples/akbank/regular/index.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card Holder Number</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card Holder Number">
|
||||
</div>
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
66
app/Core/Payment/Pos/ex/examples/akbank/regular/post.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/akbank/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'akbank',
|
||||
'model' => 'regular',
|
||||
'client_id' => '100100000',
|
||||
'username' => 'mewsapi',
|
||||
'password' => 'ME12345.',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810297189',
|
||||
'transaction' => 'post',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
35
app/Core/Payment/Pos/ex/examples/akbank/regular/refund.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201810297E8B',
|
||||
'amount' => '100',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
114
app/Core/Payment/Pos/ex/examples/akbank/regular/response.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pre', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
34
app/Core/Payment/Pos/ex/examples/akbank/regular/status.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201810297189'
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d-pay/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d_pay',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Pay Model Payment';
|
||||
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
68
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/form.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$transaction = 'pay'; // pay => Auth, pre PreAuth
|
||||
$transaction_type = $pos->bank->types[$transaction];
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => $transaction,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<pre><?php print_r($form_data) ?></pre>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
109
app/Core/Payment/Pos/ex/examples/garanti/3d-pay/response.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<pre><?php print_r($_POST) ?></pre>
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
33
app/Core/Payment/Pos/ex/examples/garanti/3d/_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => '3d',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'store_key' => '12345678',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
64
app/Core/Payment/Pos/ex/examples/garanti/3d/form.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$rand = microtime();
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'name' => 'John Doe', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth,
|
||||
'lang' => 'tr',
|
||||
'rand' => $rand,
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'name' => $request->get('name'),
|
||||
'type' => $request->get('type'),
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<div class="text-center">Redirecting...</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
57
app/Core/Payment/Pos/ex/examples/garanti/3d/index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$url = $base_url . 'form.php';
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $url; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card holder name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card holder name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="visa">Visa</option>
|
||||
<option value="master">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
108
app/Core/Payment/Pos/ex/examples/garanti/3d/response.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
34
app/Core/Payment/Pos/ex/examples/garanti/regular/_config.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691298',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'refund_username' => 'PROVRFN',
|
||||
'refund_password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/cancel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '20181114DF2C',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803579226',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/garanti/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4282209027132016',
|
||||
'month' => '05',
|
||||
'year' => '20',
|
||||
'cvv' => '165',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/history.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query= $pos->bank->history([
|
||||
'order_id' => '2018111377EF',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
44
app/Core/Payment/Pos/ex/examples/garanti/regular/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
70
app/Core/Payment/Pos/ex/examples/garanti/regular/post.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/garanti/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'garanti',
|
||||
'model' => 'regular',
|
||||
'client_id' => '7000679',
|
||||
'terminal_id' => '30691297',
|
||||
'username' => 'PROVAUT',
|
||||
'password' => '123qweASD/',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '201810231553',
|
||||
'transaction' => 'post',
|
||||
'amount' => '1',
|
||||
'ref_ret_num' => '829603332856',
|
||||
'ip' => $ip,
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
39
app/Core/Payment/Pos/ex/examples/garanti/regular/refund.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '201811142A0A',
|
||||
'ip' => $ip,
|
||||
'email' => 'mail@customer.com',
|
||||
'ref_ret_num' => '831803586333',
|
||||
'amount' => 1,
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
125
app/Core/Payment/Pos/ex/examples/garanti/regular/response.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 1;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '1',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => S, pre => preauth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $payment->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $payment->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">RetrefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->ret_ref_num ? $response->ret_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HashData:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->hash_data ? $response->hash_data : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
36
app/Core/Payment/Pos/ex/examples/garanti/regular/status.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201812195CF2',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->proc_return_code == '00' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->proc_return_code == '00' ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
15
app/Core/Payment/Pos/ex/examples/template/_footer.php
Normal file
@@ -0,0 +1,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
var redirectForm = $('form.redirect-form')
|
||||
if (redirectForm.length) {
|
||||
redirectForm.submit()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
16
app/Core/Payment/Pos/ex/examples/template/_header.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $template_title; ?></title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<div class="container" style="max-width: 640px;">
|
||||
<h2 class="text-center"><?php echo $template_title; ?></h2>
|
||||
<hr>
|
||||
38
app/Core/Payment/Pos/ex/examples/ykb/3d/_config.php
Normal file
38
app/Core/Payment/Pos/ex/examples/ykb/3d/_config.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/3d/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$success_url = $base_url . 'response.php';
|
||||
$fail_url = $base_url . 'response.php';
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXX',
|
||||
'terminal_id' => 'XXXXXX',
|
||||
'posnet_id' => 'XXXXXX',
|
||||
'username' => 'XXXXXX',
|
||||
'password' => 'XXXXXX',
|
||||
'store_key' => '10,10,10,10,10,10,10,10',
|
||||
'promotion_code' => '',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$template_title = '3D Model Payment';
|
||||
48
app/Core/Payment/Pos/ex/examples/ykb/3d/form.php
Normal file
48
app/Core/Payment/Pos/ex/examples/ykb/3d/form.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => $_POST['order_id'],
|
||||
'name' => $_POST['name'],
|
||||
'amount' => $_POST['amount'],
|
||||
'currency' => $_POST['currency'],
|
||||
'transaction' => $_POST['transaction'],
|
||||
'success_url' => $_POST['success_url'],
|
||||
'fail_url' => $_POST['fail_url'],
|
||||
'lang' => $_POST['lang'],
|
||||
];
|
||||
|
||||
$_SESSION['order'] = $order;
|
||||
|
||||
$card = [
|
||||
'type' => $_POST['type'],
|
||||
'name' => $_POST['name'],
|
||||
'number' => $_POST['number'],
|
||||
'month' => $_POST['month'],
|
||||
'year' => $_POST['year'],
|
||||
'cvv' => $_POST['cvv'],
|
||||
];
|
||||
|
||||
$pos->prepare($order, $card);
|
||||
|
||||
$form_data = $pos->get3dFormData();
|
||||
?>
|
||||
|
||||
<span class="text-muted text-center">Redirecting...</span>
|
||||
<form method="post" action="<?php echo $form_data['gateway']; ?>" class="redirect-form" role="form">
|
||||
<?php foreach ($form_data['inputs'] as $key => $value): ?>
|
||||
<input type="hidden" name="<?php echo $key; ?>" value="<?php echo $value; ?>">
|
||||
<?php endforeach; ?>
|
||||
<hr>
|
||||
<button class="btn btn-success" type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
77
app/Core/Payment/Pos/ex/examples/ykb/3d/index.php
Normal file
77
app/Core/Payment/Pos/ex/examples/ykb/3d/index.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 1;
|
||||
$instalment = '0';
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'amount' => $amount,
|
||||
'installment' => $instalment,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => $success_url,
|
||||
'fail_url' => $fail_url,
|
||||
'transaction' => 'pay', // pay => Sale, pre Auth
|
||||
'lang' => 'tr',
|
||||
];
|
||||
?>
|
||||
|
||||
<form method="post" action="./form.php" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="name">Card Holder Name</label>
|
||||
<input type="text" name="name" id="name" class="form-control input-lg" placeholder="Card Holder Name">
|
||||
</div>
|
||||
<div class="form-group col-sm-3">
|
||||
<label for="type">Card Type</label>
|
||||
<select name="type" id="type" class="form-control input-lg">
|
||||
<option value="">Type</option>
|
||||
<option value="1">Visa</option>
|
||||
<option value="2">MasterCard</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-9">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="amount" value="<?php echo $order['amount']; ?>" />
|
||||
<input type="hidden" name="currency" value="<?php echo $order['currency']; ?>" />
|
||||
<input type="hidden" name="order_id" value="<?php echo $order['id']; ?>" />
|
||||
<input type="hidden" name="transaction" value="<?php echo $order['transaction']; ?>" />
|
||||
<input type="hidden" name="success_url" value="<?php echo $order['success_url']; ?>" />
|
||||
<input type="hidden" name="fail_url" value="<?php echo $order['fail_url']; ?>" />
|
||||
<input name="lang" type="hidden" id="lang" value="<?php echo $order['lang'] ?>">
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
112
app/Core/Payment/Pos/ex/examples/ykb/3d/response.php
Normal file
112
app/Core/Payment/Pos/ex/examples/ykb/3d/response.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order = $_SESSION['order'];
|
||||
|
||||
$pos->prepare($order);
|
||||
$payment = $pos->payment();
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $response->status == 'approved' ? 'success' : 'danger'; ?>">
|
||||
<?php echo $response->status == 'approved' ? 'Payment is successful!' : 'Payment is not successful'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response ? $response->response : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Security:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_security; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Hash:</dt>
|
||||
<dd class="col-sm-9">
|
||||
<?php foreach ($response->hash as $key => $hash): ?>
|
||||
<?php echo $key . ': ' . $hash; ?>
|
||||
<?php endforeach; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->id; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code ? $response->code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">mdStatus:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_status ? $response->md_status : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Md Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->md_error_message ? $response->md_error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
31
app/Core/Payment/Pos/ex/examples/ykb/regular/_config.php
Normal file
31
app/Core/Payment/Pos/ex/examples/ykb/regular/_config.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$gateway = $base_url . 'response.php';
|
||||
|
||||
$template_title = 'Regular Payment';
|
||||
43
app/Core/Payment/Pos/ex/examples/ykb/regular/cancel.php
Normal file
43
app/Core/Payment/Pos/ex/examples/ykb/regular/cancel.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Cancel Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Cancel Order
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
/*
|
||||
// faster params...
|
||||
$cancel = $pos->bank->cancel([
|
||||
'order_id' => '201810295863',
|
||||
'host_ref_num' => '018711539490000181',
|
||||
'auth_code' => '115394',
|
||||
]);
|
||||
*/
|
||||
|
||||
$response = $cancel->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Cancel Order is successful!' : 'Cancel Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
35
app/Core/Payment/Pos/ex/examples/ykb/regular/direct.php
Normal file
35
app/Core/Payment/Pos/ex/examples/ykb/regular/direct.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => '0',
|
||||
'currency' => 'TRY',
|
||||
'ip' => $ip,
|
||||
'transaction' => 'pay', // pay => Auth, pre PreAuth
|
||||
];
|
||||
|
||||
$card = [
|
||||
'number' => '4355084355084358',
|
||||
'month' => '12',
|
||||
'year' => '18',
|
||||
'cvv' => '000',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
var_dump($payment->response);
|
||||
34
app/Core/Payment/Pos/ex/examples/ykb/regular/history.php
Normal file
34
app/Core/Payment/Pos/ex/examples/ykb/regular/history.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'History Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// History Order
|
||||
$query = $pos->bank->history([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() == '00' ? 'History Order is successful!' : 'History Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
44
app/Core/Payment/Pos/ex/examples/ykb/regular/index.php
Normal file
44
app/Core/Payment/Pos/ex/examples/ykb/regular/index.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
?>
|
||||
|
||||
<form method="post" action="<?php echo $gateway; ?>" role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-sm-12">
|
||||
<label for="number">Card Number</label>
|
||||
<input type="text" name="number" id="number" class="form-control input-lg" placeholder="Credit card number">
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="month">Expire Month</label>
|
||||
<select name="month" id="month" class="form-control input-lg">
|
||||
<option value="">Month</option>
|
||||
<?php for ($i = 1; $i <= 12; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, 0, STR_PAD_LEFT); ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="year">Expire Year</label>
|
||||
<select name="year" id="year" class="form-control input-lg">
|
||||
<option value="">Year</option>
|
||||
<?php for ($i = date('y'); $i <= date('y') + 20; $i++): ?>
|
||||
<option value="<?php echo $i; ?>"><?php echo 2000 + $i; ?></option>
|
||||
<?php endfor; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-sm-4">
|
||||
<label for="cvv">Cvv</label>
|
||||
<input type="text" name="cvv" id="cvv" class="form-control input-lg" placeholder="Cvv">
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group text-center">
|
||||
<button type="submit" class="btn btn-lg btn-block btn-success">Payment</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
70
app/Core/Payment/Pos/ex/examples/ykb/regular/post.php
Normal file
70
app/Core/Payment/Pos/ex/examples/ykb/regular/post.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
$host_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . "://$_SERVER[HTTP_HOST]";
|
||||
$path = '/pos/examples/ykb/regular/';
|
||||
$base_url = $host_url . $path;
|
||||
|
||||
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
|
||||
$ip = $request->getClientIp();
|
||||
|
||||
$account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$template_title = 'Post Auth Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
try {
|
||||
$pos = new \Mews\Pos\Pos($account);
|
||||
} catch (\Mews\Pos\Exceptions\BankNotFoundException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
} catch (\Mews\Pos\Exceptions\BankClassNullException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$order = [
|
||||
'id' => '2018102949E0',
|
||||
'host_ref_num' => '018711533790000181',
|
||||
'amount' => '100',
|
||||
'currency' => 'TRY',
|
||||
'installment' => '2',
|
||||
'transaction' => 'post',
|
||||
];
|
||||
|
||||
try {
|
||||
$pos->prepare($order);
|
||||
} catch (\Mews\Pos\Exceptions\UnsupportedTransactionTypeException $e) {
|
||||
var_dump($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
$payment = $pos->payment();
|
||||
|
||||
$response = $payment->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Post Auth Order is successful!' : 'Post Auth Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
36
app/Core/Payment/Pos/ex/examples/ykb/regular/refund.php
Normal file
36
app/Core/Payment/Pos/ex/examples/ykb/regular/refund.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Refund Order';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Refund Order
|
||||
$refund = $pos->bank->refund([
|
||||
'order_id' => '20181113DCDB',
|
||||
'amount' => '1',
|
||||
'currency' => 'TRY',
|
||||
]);
|
||||
|
||||
$response = $refund->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Refund Order is successful!' : 'Refund Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
119
app/Core/Payment/Pos/ex/examples/ykb/regular/response.php
Normal file
119
app/Core/Payment/Pos/ex/examples/ykb/regular/response.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
if ($request->getMethod() !== 'POST') {
|
||||
echo new \Symfony\Component\HttpFoundation\RedirectResponse($base_url);
|
||||
exit();
|
||||
}
|
||||
|
||||
$order_id = date('Ymd') . strtoupper(substr(uniqid(sha1(time())),0,4));
|
||||
$amount = (double) 100;
|
||||
|
||||
$order = [
|
||||
'id' => $order_id,
|
||||
'name' => 'John Doe', // optional
|
||||
'email' => 'mail@customer.com', // optional
|
||||
'user_id' => '12', // optional
|
||||
'amount' => $amount,
|
||||
'installment' => 1,
|
||||
'currency' => 'TRY',
|
||||
'transaction' => 'pay', // pay => Sale, pre Auth
|
||||
];
|
||||
|
||||
$pos->prepare($order);
|
||||
|
||||
$card = [
|
||||
'number' => $request->get('number'),
|
||||
'month' => $request->get('month'),
|
||||
'year' => $request->get('year'),
|
||||
'cvv' => $request->get('cvv'),
|
||||
];
|
||||
|
||||
$payment = $pos->payment($card);
|
||||
|
||||
$response = $payment->response;
|
||||
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Payment is successful!' : 'Payment is not successful!'; ?>
|
||||
</h3>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Response:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->response; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Status:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->status; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Transaction Type:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->transaction_type; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Order ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->order_id ? $response->order_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Group ID:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->group_id ? $response->group_id : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">AuthCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->auth_code ? $response->auth_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">HostRefNum:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->host_ref_num ? $response->host_ref_num : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">ProcReturnCode:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->proc_return_code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->code; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Code:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_code ? $response->error_code : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">Error Message:</dt>
|
||||
<dd class="col-sm-9"><?php echo $response->error_message ? $response->error_message : '-'; ?></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
34
app/Core/Payment/Pos/ex/examples/ykb/regular/status.php
Normal file
34
app/Core/Payment/Pos/ex/examples/ykb/regular/status.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
require '_config.php';
|
||||
|
||||
$template_title = 'Order Status';
|
||||
|
||||
require '../../template/_header.php';
|
||||
|
||||
// Query Order
|
||||
$query= $pos->bank->status([
|
||||
'order_id' => '201811133F3F',
|
||||
]);
|
||||
|
||||
$response = $query->response;
|
||||
$dump = get_object_vars($response);
|
||||
?>
|
||||
|
||||
<div class="result">
|
||||
<h3 class="text-center text-<?php echo $pos->isSuccess() ? 'success' : 'danger'; ?>">
|
||||
<?php echo $pos->isSuccess() ? 'Query Order is successful!' : 'Query Order is not successful!'; ?>
|
||||
</h3>
|
||||
<dl class="row">
|
||||
<dt class="col-sm-12">All Data Dump:</dt>
|
||||
<dd class="col-sm-12">
|
||||
<pre><?php print_r($dump); ?></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<div class="text-right">
|
||||
<a href="index.php" class="btn btn-lg btn-info">< Click to payment form</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require '../../template/_footer.php'; ?>
|
||||
25
app/Core/Payment/Pos/ex/phpunit.xml
Normal file
25
app/Core/Payment/Pos/ex/phpunit.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
bootstrap="vendor/autoload.php"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuite name="Integration">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<directory>vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
149
app/Core/Payment/Pos/ex/tests/EstPostTest.php
Normal file
149
app/Core/Payment/Pos/ex/tests/EstPostTest.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
|
||||
use Mews\Pos\EstPos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class EstPostTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $estpos;
|
||||
private $config;
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'VnM5WZ3sGrPusmWP',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
$this->estpos = new EstPos(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->estpos->getConfig());
|
||||
$this->assertEquals($this->account, $this->estpos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->estpos->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->estpos->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->estpos->getCard());
|
||||
$this->assertEquals($this->order, $this->estpos->getOrder());
|
||||
}
|
||||
|
||||
public function testGetCardCode()
|
||||
{
|
||||
$card = $this->card;
|
||||
|
||||
$card->type = '1';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertEquals($card->type, $this->estpos->getCardCode());
|
||||
|
||||
$card->type = 'visa';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertNotNull($this->estpos->getCardCode());
|
||||
|
||||
$card->type = 'master';
|
||||
$this->estpos->prepare($this->order, $card);
|
||||
$this->assertNotNull($this->estpos->getCardCode());
|
||||
}
|
||||
|
||||
public function testGet3DFormData()
|
||||
{
|
||||
$this->estpos->prepare($this->order, $this->card);
|
||||
|
||||
$form = [
|
||||
'gateway' => $this->config['banks'][$this->account->bank]['urls']['gateway'][$this->account->env],
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand,
|
||||
'hash' => $this->estpos->create3DHash(),
|
||||
'inputs' => [
|
||||
'clientid' => $this->account->client_id,
|
||||
'storetype' => $this->account->model,
|
||||
'hash' => $this->estpos->create3DHash(),
|
||||
'cardType' => $this->estpos->getCardCode(),
|
||||
'pan' => $this->card->number,
|
||||
'Ecom_Payment_Card_ExpDate_Month' => $this->card->month,
|
||||
'Ecom_Payment_Card_ExpDate_Year' => $this->card->year,
|
||||
'cv2' => $this->card->cvv,
|
||||
'firmaadi' => $this->order->name,
|
||||
'Email' => $this->order->email,
|
||||
'amount' => $this->order->amount,
|
||||
'oid' => $this->order->id,
|
||||
'okUrl' => $this->order->success_url,
|
||||
'failUrl' => $this->order->fail_url,
|
||||
'rnd' => $this->order->rand,
|
||||
'lang' => $this->order->lang,
|
||||
'currency' => $this->order->currency,
|
||||
]
|
||||
];
|
||||
$this->assertEquals($form, $this->estpos->get3DFormData());
|
||||
}
|
||||
|
||||
public function testCheck3DHash()
|
||||
{
|
||||
$data = [
|
||||
"md" => "478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568",
|
||||
"cavv" => "BwAQAhIYRwEAABWGABhHEE6v5IU=",
|
||||
"AuthCode" => "",
|
||||
"oid" => "880",
|
||||
"mdStatus" => "4",
|
||||
"eci" => "06",
|
||||
"clientid" => "400902568",
|
||||
"rnd" => "hDx50d0cq7u1vbpWQMae",
|
||||
"ProcReturnCode" => "N7",
|
||||
"Response" => "Declined",
|
||||
"HASH" => "D+B5fFWXEWFqVSkwotyuTPUW800=",
|
||||
"HASHPARAMS" => "clientid:oid:AuthCode:ProcReturnCode:Response:mdStatus:cavv:eci:md:rnd:",
|
||||
"HASHPARAMSVAL" => "400902568880N7Declined4BwAQAhIYRwEAABWGABhHEE6v5IU=06478719:0373D10CFD8BDED34FA0546D27D5BE76F8BA4A947D1EC499102AE97B880EB1B9:4242:##400902568hDx50d0cq7u1vbpWQMae"
|
||||
];
|
||||
|
||||
$this->assertTrue($this->estpos->check3DHash($data));
|
||||
|
||||
$data['mdStatus'] = '';
|
||||
$this->assertFalse($this->estpos->check3DHash($data));
|
||||
}
|
||||
}
|
||||
98
app/Core/Payment/Pos/ex/tests/GarantiPosTest.php
Normal file
98
app/Core/Payment/Pos/ex/tests/GarantiPosTest.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
|
||||
use Mews\Pos\GarantiPos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class GarantiPosTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $garantiPos;
|
||||
private $config;
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'akbank',
|
||||
'model' => '3d',
|
||||
'client_id' => 'XXXXXXX',
|
||||
'terminal_id' => '13456',
|
||||
'username' => 'XXXXXXX',
|
||||
'password' => 'XXXXXXX',
|
||||
'store_key' => 'XXXXXXX',
|
||||
'env' => 'test',
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime(),
|
||||
'ip' => '156.155.154.153'
|
||||
];
|
||||
|
||||
$this->garantiPos = new GarantiPos(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->garantiPos->getConfig());
|
||||
$this->assertEquals($this->account, $this->garantiPos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->garantiPos->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->garantiPos->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->garantiPos->getCard());
|
||||
$this->assertEquals($this->order, $this->garantiPos->getOrder());
|
||||
}
|
||||
|
||||
public function testGet3DFormData()
|
||||
{
|
||||
$this->garantiPos->prepare($this->order, $this->card);
|
||||
|
||||
$form = [
|
||||
'gateway' => $this->config['banks'][$this->account->bank]['urls']['gateway'][$this->account->env],
|
||||
'success_url' => $this->order->success_url,
|
||||
'fail_url' => $this->order->fail_url,
|
||||
'rand' => $this->order->rand
|
||||
];
|
||||
$actualForm = $this->garantiPos->get3DFormData();
|
||||
$this->assertNotEmpty($actualForm['inputs']);
|
||||
$this->assertNotEmpty($actualForm['hash']);
|
||||
|
||||
unset($actualForm['inputs']);
|
||||
unset($actualForm['hash']);
|
||||
$this->assertEquals($form, $actualForm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
app/Core/Payment/Pos/ex/tests/PosNetCryptTest.php
Normal file
35
app/Core/Payment/Pos/ex/tests/PosNetCryptTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\PosNetCrypt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
class PosNetCryptTest extends TestCase
|
||||
{
|
||||
private $crypt;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->crypt = new PosNetCrypt();
|
||||
}
|
||||
|
||||
public function testDecrypt(){
|
||||
$data = '9ACF38C842B3522415364850EAD1909BD43FD590BE3CBD539AD5FF6C7465973ABD61E8371E03282605ED06C994DF394244B7E7DAD54A046510484FAA724330C4C95A527D7891151E7C195D4136CBD70A87D1BD1F75473CF6B45A3F2FA8231DD71FFB4150E0BF4B133ECAA5ACC82CFD74903E21BC6EECB4B33AF39B8AF0C183A64002CFC125A55685C69A13192F3A9A4FDAC860E90C3FB6D125285E9E687BEFBE05707E131FC7ABE25FE35AB114FAE8A247B8C0F3DBA8AA74396D10564B7A0617EED913ED';
|
||||
|
||||
$key = '10,10,10,10,10,10,10,10';
|
||||
$expected_output = '6706598320;67005551;100;00;YKB_TST_090519001330;0;0;https://setmpos.ykb.com/PosnetWebService/YKBTransactionService;posnettest.ykb.com;2225;N;0;Not authenticated;1557398383820;TL';
|
||||
|
||||
$dc = $this->crypt->decrypt($data, $key);
|
||||
$this->assertEquals($expected_output, $dc);
|
||||
|
||||
$data = '1974BC4B9984FF173F9DF305090E44241243CCC9648349C0D607AECACCB55C1F1ED47452B3AD90785F9BCC6AC7E65450D4E72F31B9FC8F9F55A7D109C2BE966C6DD3F3DE12B3457FF0C6FA8BCDBB4B8E5341C1C3DA327992C28354EB3B5C62472C06B8FB6DF34E351206D2CCD5E323FA26EC3EFF2C25656C74C836954F193E634AF391761F88B5D53DBE1FC61A89DB713DFC983D9605D080ACA857196DD3E7B3C52BFCC914CE47961D76B590ECB34B28113A6E4FAA572958D836B09546A9A62D24F829FE18628DF84504FB02';
|
||||
$expected_output = '6706598320;67825768;100;00;00000000000000000892;0;0;https://setmpos.ykb.com/PosnetWebService/YKBTransactionService;posnettest.ykb.com;2225;N;9;None 3D - Secure Transaction;1586175747626;TL';
|
||||
|
||||
$dc = $this->crypt->decrypt($data, $key);
|
||||
$this->assertEquals($expected_output, $dc);
|
||||
}
|
||||
|
||||
}
|
||||
110
app/Core/Payment/Pos/ex/tests/PosNetTest.php
Normal file
110
app/Core/Payment/Pos/ex/tests/PosNetTest.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\PosNet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
|
||||
class PosNetTest extends TestCase
|
||||
{
|
||||
private $account;
|
||||
private $posnet;
|
||||
private $config;
|
||||
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->account = (object)[
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67005551',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
'store_key' => '10,10,10,10,10,10,10,10',
|
||||
'model' => '3d'
|
||||
];
|
||||
|
||||
$this->card = (object)[
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = (object)[
|
||||
'id' => 'YKB_TST_190620093100_024',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '1.75',
|
||||
'installment' => 0,
|
||||
'currency' => 'TL',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
$this->posnet = new PosNet(
|
||||
$this->config['banks'][$this->account->bank],
|
||||
$this->account,
|
||||
$this->config['currencies']);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account->bank], $this->posnet->getConfig());
|
||||
$this->assertEquals($this->account, $this->posnet->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->posnet->getCurrencies());
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
$this->posnet->prepare($this->order, $this->card);
|
||||
$this->assertEquals($this->card, $this->posnet->getCard());
|
||||
$this->assertEquals($this->order, $this->posnet->getOrder());
|
||||
}
|
||||
|
||||
public function testCreate3DHash(){
|
||||
|
||||
$this->posnet->prepare($this->order, $this->card);
|
||||
$this->assertEquals('J/7/Xprj7F/KDf98luVfIGyUPRQzUCqGwpmvz3KT7oQ=', $this->posnet->create3DHash());
|
||||
}
|
||||
|
||||
public function testVerifyResponseMAC(){
|
||||
|
||||
$order = $this->order;
|
||||
$order->id = '895';
|
||||
$order->amount = 1;
|
||||
$order->currency = 'TL';
|
||||
|
||||
$account = $this->account;
|
||||
$account->client_id = '6706598320';
|
||||
$account->terminal_id = '67825768';
|
||||
$account->store_key = '10,10,10,10,10,10,10,10';
|
||||
|
||||
$this->posnet->prepare($order, $account);
|
||||
$data = (object)[
|
||||
'mdStatus' => '9',
|
||||
'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0='
|
||||
];
|
||||
$this->assertTrue($this->posnet->verifyResponseMAC($data));
|
||||
|
||||
$order->id = '800';
|
||||
$this->posnet->prepare($order, $account);
|
||||
$data = (object)[
|
||||
'mdStatus' => '9',
|
||||
'mac' => 'U2kU/JWjclCvKZjILq8xBJUXhyB4DswKvN+pKfxl0u0='
|
||||
];
|
||||
$this->assertFalse($this->posnet->verifyResponseMAC($data));
|
||||
}
|
||||
}
|
||||
94
app/Core/Payment/Pos/ex/tests/PosTest.php
Normal file
94
app/Core/Payment/Pos/ex/tests/PosTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Mews\Pos\Tests;
|
||||
use Mews\Pos\Pos;
|
||||
use Mews\Pos\PosHelpersTrait;
|
||||
use Mews\Pos\PosNet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
|
||||
class PosTest extends TestCase
|
||||
{
|
||||
use PosHelpersTrait;
|
||||
|
||||
private $account;
|
||||
private $pos;
|
||||
private $config;
|
||||
|
||||
private $card;
|
||||
private $order;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->config = require __DIR__ . '/../config/pos.php';
|
||||
$this->account = [
|
||||
'bank' => 'yapikredi',
|
||||
'model' => 'regular',
|
||||
'client_id' => '6706598320',
|
||||
'terminal_id' => '67322946',
|
||||
'posnet_id' => '27426',
|
||||
'env' => 'test',
|
||||
'store_key' => '10,10,10,10,10,10,10,10'
|
||||
];
|
||||
|
||||
$this->card = [
|
||||
'number' => '5555444433332222',
|
||||
'year' => '21',
|
||||
'month' => '12',
|
||||
'cvv' => '122',
|
||||
'name' => 'ahmet',
|
||||
'type' => 'visa'
|
||||
];
|
||||
|
||||
$this->order = [
|
||||
'id' => 'order222',
|
||||
'name' => 'siparis veren',
|
||||
'email' => 'test@test.com',
|
||||
'amount' => '100.25',
|
||||
'installment' => 0,
|
||||
'currency' => 'TRY',
|
||||
'success_url' => 'https://domain.com/success',
|
||||
'fail_url' => 'https://domain.com/fail_url',
|
||||
'lang' => 'tr',
|
||||
'rand' => microtime()
|
||||
];
|
||||
|
||||
$this->pos = new Pos($this->account);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account['bank']], $this->pos->getConfig());
|
||||
$this->assertEquals((object)$this->account, $this->pos->getAccount());
|
||||
$this->assertEquals($this->config['currencies'], $this->pos->getCurrencies());
|
||||
$this->assertInstanceOf(PosNet::class, $this->pos->bank);
|
||||
}
|
||||
|
||||
public function testCreateXML()
|
||||
{
|
||||
$xml_str = $this->createXML($this->order);
|
||||
$this->assertIsString($xml_str);
|
||||
}
|
||||
|
||||
public function testXMLStringToObject()
|
||||
{
|
||||
$xml_str = $this->createXML(['order' => $this->order]);
|
||||
$this->assertEquals((object)$this->order, $this->XMLStringToObject($xml_str));
|
||||
}
|
||||
|
||||
public function testPrepare()
|
||||
{
|
||||
|
||||
$this->pos->prepare($this->order, $this->card);
|
||||
$this->assertEquals((object)$this->card, $this->pos->getCard());
|
||||
//$this->assertEquals((object)$order, $this->pos->getOrder());
|
||||
}
|
||||
|
||||
public function testGetGatewayUrl()
|
||||
{
|
||||
$this->assertEquals($this->config['banks'][$this->account['bank']]['urls']['gateway'][$this->account['env']], $this->pos->getGatewayUrl());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user