1. Go to this page and download the library: Download muratdemirel/pos library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
muratdemirel / pos example snippets
I kullanıcı bilgileri
$account = \Mews\Pos\Factory\AccountFactory::createEstPosAccount(
'akbank', //pos config'deki ayarın index name'i
'yourClientID',
'yourKullaniciAdi',
'yourSifre',
AbstractGateway::MODEL_3D_SECURE, //storetype
'yourStoreKey',
AbstractGateway::LANG_TR
);
// API kullanıcı hesabı ile paket bir değişkene aktarılıyor
try {
$pos = \Mews\Pos\Factory\PosFactory::createPosGateway($account);
//değere göre API URL'leri test veya production değerler kullanılır.
$pos->setTestMode(true);
} catch (\Mews\Pos\Exceptions\BankNotFoundException | \Mews\Pos\Exceptions\BankClassNullException $e) {
dd($e));
}
pariş bilgileri
$order = [
'id' => 'BENZERSIZ-SIPERIS-ID',
'amount' => 1.01,
'currency' => 'TRY', //TRY|USD|EUR, optional. default: TRY
'installment' => 0, //0 ya da 1'den büyük değer, optional. default: 0
//MODEL_3D_SECURE, MODEL_3D_PAY, MODEL_3D_HOST odemeler icin zorunlu
//Success ve Fail URL'ler farklı olabilir ama kütüphane success ve fail için aynı kod çalıştırır.
'success_url' => 'https://example.com/response.php',
'fail_url' => 'https://example.com/response.php',
//gateway'e gore zorunlu olan degerler
'ip' => $ip, //EstPos, Garanti, KuveytPos, VakifBank
'email' => '[email protected]', // EstPos, Garanti, KuveytPos, VakifBank
'name' => 'John Doe', // EstPos, Garanti
'user_id' => 'Müşteri ID', // EstPos
'rand' => md5(uniqid(time())), // EstPos, Garanti, PayFor, InterPos, VakifBank. Rastegele değer.
//lang degeri verilmezse account (EstPosAccount) dili kullanılacak
'lang' => AbstractGateway::LANG_TR, //LANG_TR|LANG_EN. Kullanıcının yönlendirileceği banka gateway sayfasının ve gateway'den dönen mesajların dili.
];
$session->set('order', $order);
// Kredi kartı bilgieri
$card = \Mews\Pos\Factory\CreditCardFactory::create(
$pos,
'4444555566667777',
'25',
'12',
'123',
'john',
AbstractCreditCard::CARD_TYPE_VISA, //bankaya göre zorunlu
);
// API kullanıcısı ile oluşturulan $pos değişkenine prepare metoduyla sipariş bilgileri tanımlanıyor.
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY, $card);
try {
// $formData icerigi form olarak banka gateway'ne yonlendirilir.
// /examples/template/_redirect_form.php bakınız.
$formData = $pos->get3DFormData();
} catch (\Throwable $e) {
dd($e);
}
r = $session->get('order');
$pos->prepare($order, \Mews\Pos\Gateways\AbstractGateway::TX_PAY);
// Ödeme tamamlanıyor,
// Ödeme modeli (3D Secure, 3D Pay, 3D Host, Non Secure) $account tarafında belirlenir.
// $card değeri Non Secure modelde ve Vakıfbank için 3DPay ve 3DSecure ödemede zorunlu.
$pos->payment($card);
// Ödeme başarılı mı?
$pos->isSuccess();
// Sonuç çıktısı
dump($pos->getResponse());
//response içeriği için /examples/template/_payment_response.php dosyaya bakınız.