Skip to content

Commit

Permalink
adds bank account tracking adapter to retrieve bank account tracking …
Browse files Browse the repository at this point in the history
…record
  • Loading branch information
Alican Akkus authored and Alican Akkus committed Jul 24, 2023
1 parent 66d2abc commit 3ea179a
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 0 deletions.
20 changes: 20 additions & 0 deletions samples/search_bank_account_tracking_records.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

require_once('config/sample_config.php');

use Craftgate\Model\CardAssociation;
use Craftgate\Model\CardType;

$request = array(
'cardAlias' => 'My YKB Card',
'cardBankName' => 'YAPI VE KREDİ BANKASI A.Ş.',
'cardBrand' => 'World',
'cardAssociation' => CardAssociation::MASTER_CARD,
'cardToken' => 'd9b19d1a-243c-43dc-a498-add08162df72',
'cardUserKey' => 'c115ecdf-0afc-4d83-8a1b-719c2af19cbd',
'cardType' => CardType::CREDIT_CARD
);

$response = SampleConfig::craftgate()->payment()->searchStoredCards($request);

print_r($response);
214 changes: 214 additions & 0 deletions src/Adapter/BankAccountTrackingAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<?php

namespace Craftgate\Adapter;

use Craftgate\Util\QueryBuilder;
use Craftgate\Util\Signature;

class PaymentAdapter extends BaseAdapter
{
public function createPayment(array $request)
{
$path = "/payment/v1/card-payments";
return $this->httpPost($path, $request);
}

public function retrievePayment($paymentId)
{
$path = "/payment/v1/card-payments/" . $paymentId;
return $this->httpGet($path);
}

public function postAuthPayment($paymentId, array $request)
{
$path = "/payment/v1/card-payments/" . $paymentId . "/post-auth";
return $this->httpPost($path, $request);
}

public function init3DSPayment(array $request)
{
$path = "/payment/v1/card-payments/3ds-init";
return $this->httpPost($path, $request);
}

public function complete3DSPayment(array $request)
{
$path = "/payment/v1/card-payments/3ds-complete";
return $this->httpPost($path, $request);
}

public function initCheckoutPayment(array $request)
{
$path = "/payment/v1/checkout-payments/init";
return $this->httpPost($path, $request);
}

public function retrieveCheckoutPayment($token)
{
$path = "/payment/v1/checkout-payments/" . $token;
return $this->httpGet($path);
}

public function createDepositPayment(array $request)
{
$path = "/payment/v1/deposits";
return $this->httpPost($path, $request);
}

public function init3DSDepositPayment(array $request)
{
$path = "/payment/v1/deposits/3ds-init";
return $this->httpPost($path, $request);
}

public function complete3DSDepositPayment(array $request)
{
$path = "/payment/v1/deposits/3ds-complete";
return $this->httpPost($path, $request);
}

public function createFundTransferDepositPayment(array $request)
{
$path = "/payment/v1/deposits/fund-transfer";
return $this->httpPost($path, $request);
}

public function initApmDepositPayment(array $request)
{
$path = "/payment/v1/deposits/apm-init";
return $this->httpPost($path, $request);
}

public function initGarantiPayPayment(array $request)
{
$path = "/payment/v1/garanti-pay-payments";
return $this->httpPost($path, $request);
}

public function initApmPayment(array $request)
{
$path = "/payment/v1/apm-payments/init";
return $this->httpPost($path, $request);
}

public function completeApmPayment(array $request)
{
$path = "/payment/v1/apm-payments/complete";
return $this->httpPost($path, $request);
}

public function createApmPayment(array $request)
{
$path = "/payment/v1/apm-payments";
return $this->httpPost($path, $request);
}

public function initPosApmPayment(array $request)
{
$path = "/payment/v1/pos-apm-payments/init";
return $this->httpPost($path, $request);
}

public function completePosApmPayment(array $request)
{
$path = "/payment/v1/pos-apm-payments/complete";
return $this->httpPost($path, $request);
}

public function retrieveLoyalties(array $request)
{
$path = "/payment/v1/card-loyalties/retrieve";
return $this->httpPost($path, $request);
}

public function refundPaymentTransaction(array $request)
{
$path = "/payment/v1/refund-transactions";
return $this->httpPost($path, $request);
}

public function retrievePaymentTransactionRefund($refundTransactionId)
{
$path = "/payment/v1/refund-transactions/" . $refundTransactionId;
return $this->httpGet($path);
}

public function refundPayment(array $request)
{
$path = "/payment/v1/refunds";
return $this->httpPost($path, $request);
}

public function retrievePaymentRefund($refundId)
{
$path = "/payment/v1/refunds/" . $refundId;
return $this->httpGet($path);
}

public function storeCard(array $request)
{
$path = "/payment/v1/cards";
return $this->httpPost($path, $request);
}

public function updateCard(array $request)
{
$path = "/payment/v1/cards/update";
return $this->httpPost($path, $request);
}

public function searchStoredCards(array $request)
{
$path = "/payment/v1/cards" . QueryBuilder::build($request);
return $this->httpGet($path);
}

public function deleteStoredCard(array $request)
{
$path = "/payment/v1/cards/delete";
return $this->httpPost($path, $request);
}

public function approvePaymentTransactions(array $request)
{
$path = "/payment/v1/payment-transactions/approve";
return $this->httpPost($path, $request);
}

public function disapprovePaymentTransactions(array $request)
{
$path = "/payment/v1/payment-transactions/disapprove";
return $this->httpPost($path, $request);
}

public function checkMasterpassUser(array $request)
{
$path = "/payment/v1/masterpass-payments/check-user";
return $this->httpPost($path, $request);
}

public function updatePaymentTransaction($paymentTransactionId, array $request)
{
$path = "/payment/v1/payment-transactions/" . $paymentTransactionId;
return $this->httpPut($path, $request);
}

public function is3DSecureCallbackVerified($threeDSecureCallbackKey, $params)
{
$hash = $params["hash"];
$hashString = $threeDSecureCallbackKey .
"###" . $this->extractParam('status', $params) .
"###" . $this->extractParam('completeStatus', $params) .
"###" . $this->extractParam('paymentId', $params) .
"###" . $this->extractParam('conversationData', $params) .
"###" . $this->extractParam('conversationId', $params) .
"###" . $this->extractParam('callbackStatus', $params);

$hashed = Signature::generateHash($hashString);
return $hash == $hashed;
}

private function extractParam($key, $params){
return isset($params[$key]) ? $params[$key] : '';
}
}

0 comments on commit 3ea179a

Please sign in to comment.