PHPackages                             travijuu/bkm-express - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. travijuu/bkm-express

ActiveLibrary[Payment Processing](/categories/payments)

travijuu/bkm-express
====================

BKM Express Payment Library

v1.0.3(10y ago)11109MITPHPPHP &gt;=5.4.0

Since Nov 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/travijuu/bkm-express)[ Packagist](https://packagist.org/packages/travijuu/bkm-express)[ RSS](/packages/travijuu-bkm-express/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

BKM Express PHP Payment Library
===============================

[](#bkm-express-php-payment-library)

[![Build Status](https://camo.githubusercontent.com/b8879e13586d6dff395d3ce454de5d575e7cf94c07da4131365e90e353090b5a/68747470733a2f2f7472617669732d63692e6f72672f74726176696a75752f626b6d2d657870726573732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/travijuu/bkm-express)

BKM Express is easy and fast payment system in Turkey which makes possible online payments without giving whole credit card information so this library provides you a simple API for it.

\######NOTE: currently working on this project. Documentation has not been completed yet.

Installation
------------

[](#installation)

You can simply install this library via [Composer](http://getcomposer.org/).

Firstly, add this line into your `composer.json`

```
{
    "require": {
        "travijuu/bkm-express": "1.0.3"
    }
}
```

and then run `composer update` command.

Payment Steps in BKM Express
----------------------------

[](#payment-steps-in-bkm-express)

There are four steps to make payment transaction.

- **Initialize Payment** - prepare your data (banks, installments, payment options, etc..), send them to BKM Express, get the result from BKM Express and make POST request to BKM after the verification.
- **Request Merch Info** - BKM makes SOAP request to you to get your virtual pos info according to client's credit card selection.
- **Success/Cancel URL** - BKM Express makes payment transaction request to defined bank instead of you when it gets your virtual pos info. According to the transaction result, it makes another request to success or cancel url.
- **Confirmation URL** - Apart from success/fail url request, BKM Express makes another request to your confirmation url. This request is same as success/fail request so it is an extra request to be ensure that preventing data loss from a failure in success/fail request

Basic Usage
-----------

[](#basic-usage)

Let's start with first step.

### Initialize Payment

[](#initialize-payment)

```
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);
```

Then, make POST request to `$response->getUrl()` with 3 parameters by redirecting page to BKM Express

```
[
    't'  => $response->getToken(),
    's'  => $response->getSignature(),
    'ts' => $response->getTimestamp()
]
```

Another way of POST request. (But not preferred)

```
