BKM Express는 터키에서 쉽고 빠른 결제 시스템으로 전체 신용 카드 정보를 제공하지 않고 온라인 결제를 가능하게 하므로이 라이브러리는 간단한 API를 제공합니다.
###### 참고 : 현재이 프로젝트를 진행하고 있습니다. 문서는 아직 완료되지 않았습니다.
작곡가를 통해이 라이브러리를 단순히 설치할 수 있습니다.
먼저이 줄을 composer.json 에 추가하십시오
{
"require" : {
"travijuu/bkm-express" : " 1.0.3 "
}
} 그런 다음 composer update 명령을 실행하십시오.
지불 거래를위한 네 단계가 있습니다.
첫 번째 단계부터 시작하겠습니다.
use Travijuu BkmExpress BkmExpress ;
use Travijuu BkmExpress Common Bank ;
use Travijuu BkmExpress Common Bin ;
use Travijuu BkmExpress Common Installment ;
$ mid = ' 7b928290-b6d2-469e-ac10-29eb36b8c1f6 ' ; // BKM Merchant ID
$ successUrl = ' https://example.com/bkm/success ' ;
$ cancelUrl = ' https://example.com/bkm/error ' ;
$ privateKeyPath = ' /path/to/mykey.pem ' ;
$ publicKeyPath = ' /path/to/mykey.pub ' ;
$ bkmPublicKeyPath = ' /path/to/bkm.pub ' ;
// Infrastructure of the bank you choose as a default payment gateway.
// ['Posnet', 'NestPay', 'Gvp'] one of them should be chosen.
$ defaultBank = ' NestPay ' ;
$ bkm = new BkmExpress ( $ mid , $ successUrl , $ cancelUrl , $ privateKeyPath , $ publicKeyPath , $ bkmPublicKeyPath , $ defaultBank );
$ wsdl = ' /path/to/BkmExpressPaymentService.wsdl ' ;
$ sAmount = 100.50 ; // Sale Amount
$ cAmount = 4.50 ; // Cargo Amount
$ banks = [];
$ bank = new Bank ( ' 0062 ' , ' Garanti Bank ' , ' Garanti Bank via BKM Express ' );
$ bin = new Bin ( ' 554960 ' );
$ installment = new Installment ( $ cAmount , $ sAmount , 1 , ' Garanti Bank without installment ' , true );
$ bin -> addInstallment ( $ installment );
$ installment = new Installment ( $ cAmount , $ sAmount , 3 , ' Garanti Bank with 3 installments ' , true );
$ bin -> addInstallment ( $ installment );
$ bank -> addBin ( $ bin );
$ banks [] = $ bank ;
$ response = $ bkm -> initPayment ( $ wsdl , $ sAmount , $ cAmount , $ banks ); 그런 다음 페이지를 bkm express로 리디렉션하여 3 개의 매개 변수로 $response->getUrl() 에 게시 요청을 만드십시오.
[
' t ' => $ response -> getToken (),
' s ' => $ response -> getSignature (),
' ts ' => $ response -> getTimestamp ()
]후 요청의 또 다른 방법. (그러나 선호하지 않음)
< form name =" bankexpresspayForm " id =" bankexpresspayForm " action =" <?php echo $response->getUrl(); ?> " method =" POST " >
< input type =" hidden " name =" t " value =" <?php echo $response->getToken(); ?> " >
< input type =" hidden " name =" ts " value =" <?php echo $response->getSignature(); ?> " >
< input type =" hidden " name =" s " value =" <?php echo $response->getTimestamp(); ?> " >
<!-- To support javascript unaware/disabled browsers -->
< noscript >
< center >
Eğer yönlenme olmazsa lütfen tıklayınız. < br >
</ center >
</ noscript >
</ form >
< script type =" text/javascript " >
setTimeout ( function ( ) {
$ ( '#bankexpresspayForm' ) . submit ( ) ;
} , 500 ) ;
</ script >이 단계 후에는 BKM Express 웹 사이트로 리디렉션해야합니다.
고객이 시스템에 로그인하면 사용 가능한 신용 카드가 나열됩니다. 따라서 고객은 지불 요청 초기화에서 전송되는 모든 할부 옵션을 볼 수 있습니다.
신용 카드 선택 후 고객에게 SMS 비밀번호가 요청됩니다.
다음 단계에서 BKM Express는 고객의 선택한 카드와 관련된 은행 API 정보를 얻기 위해 응용 프로그램에 SOAP 요청을합니다 ( Request Merch Info ).
중요 : WebService URL을 BKM Express 고객 서비스로 선언해야합니다.
따라서 BKM Express는이 URL에 SOAP 요청을하여 서버에서 은행 API 정보를 가져옵니다.
use Travijuu BkmExpress Common VirtualPos ;
use Travijuu BkmExpress Payment RequestMerchInfo RequestMerchInfoWSRequest ;
$ wsdlServer = ' /path/to/RequestMerchInfoService_latest.wsdl ' ;
$ virtualPosList = [];
$ virtualPos = new VirtualPos ();
$ virtualPos -> setPosUrl ( ' https://sanalposprovtest.garanti.com.tr/VPServlet ' )
-> setPosUid ( ' 600218 ' );
-> setPosPwd ( ' 123qweASD ' );
-> setMpiUrl ( ' https://sanalposprovtest.garanti.com.tr/servlet/gt3dengine ' )
-> setMpiUid ( ' 600218 ' )
-> setMpiPwd ( ' 123qweASD ' )
-> setMd ( '' )
-> setXid ( '' )
-> setCIp ( ' 192.168.0.1 ' )
-> setExtra ( ' {"terminalprovuserid":"PROVAUT", "terminalmerchantid":"7000679", "storekey":"12345678", "terminalid":"30690168"} ' )
-> setIs3ds ( false )
-> setIs3dsFDec ( false );
// Garanti Bank Id: 0062
$ virtualPosList [ ' 0062 ' ] = $ virtualPos ;
/* This callback can help you to be informed what kind of
* payment method is selected in BKM Express website.
* You may insert this into database for info purposes.
* Note: This is optional.
*/
$ callback = function ( RequestMerchInfoWSRequest $ request ) {
$ token = $ response -> getToken ();
$ bankId = $ response -> getBankId ();
$ installment = $ response -> getInstallment ();
. . .
}
$ bkm -> requestMerchInfo ( $ wsdlServer , $ virtualPosList , $ callback ); 이 요청의 결과는 BKM Express로 반환되며 은행 API 정보와 은행 거래가됩니다. 그 후 BKM Express는 은행 거래 결과 ( success / cancel url )에 따라 사후 요청을합니다.
BKM Express는 성공 URL (https://example.com/bkm/success)에 대한 게시물 요청을하거나 URL을 취소합니다 (https://example.com/bkm/error) 게시물 데이터를 가져 와서 확인 기능으로 전달해야합니다.
참고 : https://example.com/bkm/success/ {ordercode} 이와 같은 성공 URL을 사용할 수 있으므로 지불하려는 주문을 이해하는 데 도움이됩니다.
// This part can be used in both success and cancel url. $confirmation->success() will return the result.
$ data = $ _POST ;
$ confirmation = $ bkm -> confirm ( $ data );
if ( $ confirmation -> isSuccess ()) {
// remember the callback which I decribed above. If you save $token, $bankId, $installment into your database, now you can use them to identify the posResponse.
$ token = $ confirmation -> getToken ();
$ bankId = ' 0062 ' ; // get the bank Id from database according to token
$ posResponse = $ bkm -> getPosResponse ( $ bankId , $ confirmation -> getPosRef ());
// This means that bank transcation is successfully completed so you got the money
// now you can save the success result to your database.
if ( $ posResponse -> isSuccess ()) {
$ authCode = $ posResponse -> getAuthCode ();
$ rawResponse = $ posResponse -> getRawResponse ();
. . .
} else {
// Transaction failed so get the error message and code
$ errorCode = $ posResponse -> getResponseCode ();
$ errorMessage = $ posResponse -> getResponseMessage ();
. . .
}
} success url 외에도 BKM Express는 예방 조치를 위해 확인 URL 에이 게시물 요청을 수행합니다. 그들은 success url 로 전송 된 요청에 도달 할 수 없다고 가정했습니다.
중요 : 확인 URL을 BKM Express 고객 서비스에 선언해야합니다.
$ data = $ _POST ;
$ confirmation = $ bkm -> confirm ( $ data );
/* You can use the same methodology as above.
* Save $token, $bankId, $installment into your database,
* now you can use them to identify the posResponse. (Garanti, YKB, Akbank, etc..)
*/
$ token = $ confirmation -> getToken ();
$ bankId = ' 0062 ' ; // get the bank Id from database according to token
$ posResponse = $ bkm -> getPosResponse ( $ bankId , $ confirmation -> getPosRef ());제안 사항이 있으시면 Github에서 문제를 만들 거나이 repo에서 문제를 해결하십시오. 변경하고 풀 요청을 제출하십시오!