Skip to content

Commit

Permalink
Payfor move MOTO and MbrId fields inside PayForPos.php from account data
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdy committed Nov 8, 2020
1 parent 07e6ecd commit 6142de3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 57 deletions.
8 changes: 0 additions & 8 deletions examples/finansbank-payfor/3d-host/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
'store_key' => '12345678', //MerchantPass only needed for 3D payment
'env' => 'test',
'lang' => \Mews\Pos\PayForPos::LANG_EN,
'customData' => (object) [
/**
* 0 : İşlemin E-commerce olduğunu ifade eder.
* 1 : İşlemin MO TO olduğunu ifade ede
*/
'moto' => '0',
'mbrId' => 5, //Kurum Kodu
]
];

try {
Expand Down
8 changes: 0 additions & 8 deletions examples/finansbank-payfor/3d-pay/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
'store_key' => '12345678', //MerchantPass only needed for 3D payment
'env' => 'test',
'lang' => \Mews\Pos\PayForPos::LANG_EN,
'customData' => (object) [
/**
* 0 : İşlemin E-commerce olduğunu ifade eder.
* 1 : İşlemin MO TO olduğunu ifade ede
*/
'moto' => '0',
'mbrId' => 5, //Kurum Kodu
]
];

try {
Expand Down
8 changes: 0 additions & 8 deletions examples/finansbank-payfor/3d/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
'store_key' => '12345678', //MerchantPass only needed for 3D payment
'env' => 'test',
'lang' => \Mews\Pos\PayForPos::LANG_EN,
'customData' => (object) [
/**
* 0 : İşlemin E-commerce olduğunu ifade eder.
* 1 : İşlemin MO TO olduğunu ifade ede
*/
'moto' => '0',
'mbrId' => 5, //Kurum Kodu
]
];

try {
Expand Down
8 changes: 0 additions & 8 deletions examples/finansbank-payfor/regular/_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
'password' => 'UcBN0',
'env' => 'test',
'lang' => \Mews\Pos\PayForPos::LANG_EN,
'customData' => (object) [
/**
* 0 : İşlemin E-commerce olduğunu ifade eder.
* 1 : İşlemin MO TO olduğunu ifade ede
*/
'moto' => '0',
'mbrId' => 5, //Kurum Kodu
]
];

try {
Expand Down
43 changes: 27 additions & 16 deletions src/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ class PayForPos implements PosInterface
const LANG_TR = 'tr';
const LANG_EN = 'en';

/**
* Kurum kodudur. (Banka tarafından verilir)
*/
const MBR_ID = '5';

/**
* MOTO (Mail Order Telephone Order) 0 for false, 1 for true
*/
const MOTO = '0';

/**
* Raw Response Data
*
* @var object
*/
protected $data;

/**
* Response Codes
*
Expand Down Expand Up @@ -99,12 +116,6 @@ class PayForPos implements PosInterface
*/
private $response;

/**
* Raw Response Data
*
* @var object
*/
protected $data;

public function __construct($config, $account, array $currencies)
{
Expand Down Expand Up @@ -470,7 +481,7 @@ public function createXML(array $data, $encoding = 'UTF-8'): string
*/
public function create3DHash()
{
$hashStr = $this->account->customData->mbrId . $this->order->id
$hashStr = self::MBR_ID . $this->order->id
. $this->order->amount . $this->order->success_url
. $this->order->fail_url . $this->type
. $this->order->installment . $this->order->rand
Expand Down Expand Up @@ -746,11 +757,11 @@ protected function getDefaultPaymentResponse()
protected function createRegularPaymentXML()
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
'MOTO' => $this->account->customData->moto,
'MOTO' => self::MOTO,
'OrderId' => $this->order->id,
'SecureType' => 'NonSecure',
'TxnType' => $this->type,
Expand All @@ -775,11 +786,11 @@ protected function createRegularPaymentXML()
protected function createRegularPostXML()
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
'MOTO' => $this->account->customData->moto,
'MOTO' => self::MOTO,
'OrgOrderId' => $this->order->id,
'SecureType' => 'NonSecure',
'TxnType' => $this->type,
Expand Down Expand Up @@ -822,7 +833,7 @@ protected function create3DPaymentXML($responseData)
protected function createOrderStatusXML()
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
Expand All @@ -843,7 +854,7 @@ protected function createOrderStatusXML()
protected function createRefundXML()
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
Expand All @@ -866,7 +877,7 @@ protected function createRefundXML()
protected function createCancelXML()
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
Expand All @@ -891,7 +902,7 @@ protected function createCancelXML()
protected function createHistoryXML($customQueryData)
{
$requestData = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantId' => $this->account->client_id,
'UserCode' => $this->account->username,
'UserPass' => $this->account->password,
Expand All @@ -918,7 +929,7 @@ protected function createHistoryXML($customQueryData)
protected function getCommon3DFormData($withCrediCard = false)
{
$inputs = [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => self::MBR_ID,
'MerchantID' => $this->account->client_id,
'UserCode' => $this->account->username,
'OrderId' => $this->order->id,
Expand Down
10 changes: 1 addition & 9 deletions tests/PayForTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ protected function setUp(): void
'store_key' => '12345678', //MerchantPass only needed for 3D payment
'env' => 'test',
'lang' => PayForPos::LANG_EN,
'customData' => (object) [
/**
* 0 : İşlemin E-commerce olduğunu ifade eder.
* 1 : İşlemin MO TO olduğunu ifade ede
*/
'moto' => '0',
'mbrId' => 5, //Kurum Kodu
],
];

$this->card = new CreditCardPayFor('5555444433332222', '22', '01', '123', 'ahmet');
Expand Down Expand Up @@ -95,7 +87,7 @@ public function testGet3DFormData()
$form = [
'gateway' => $this->config['banks'][$this->account->bank]['urls']['gateway'][$this->account->env],
'inputs' => [
'MbrId' => $this->account->customData->mbrId,
'MbrId' => PayForPos::MBR_ID,
'MerchantID' => $this->account->client_id,
'UserCode' => $this->account->username,
'OrderId' => $this->order->id,
Expand Down

0 comments on commit 6142de3

Please sign in to comment.