https://github.com/gizemsever/laravel-paytr
Laravel Paytr Wrapper - Laravel Paytr Integration
https://github.com/gizemsever/laravel-paytr
laravel laravel-package laravel-wrapper paytr
Last synced: 6 months ago
JSON representation
Laravel Paytr Wrapper - Laravel Paytr Integration
- Host: GitHub
- URL: https://github.com/gizemsever/laravel-paytr
- Owner: GizemSever
- License: mit
- Created: 2022-09-14T22:09:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-03T21:43:04.000Z (about 2 years ago)
- Last Synced: 2026-01-14T14:41:20.106Z (6 months ago)
- Topics: laravel, laravel-package, laravel-wrapper, paytr
- Language: PHP
- Homepage: https://packagist.org/packages/gizemsever/laravel-paytr
- Size: 29.3 KB
- Stars: 26
- Watchers: 3
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Laravel Paytr
This package has been developed only for the Paytr Iframe API service.
**How to install?**
composer require gizemsever/laravel-paytr
Publish provider
php artisan vendor:publish --provider="Gizemsever\LaravelPaytr\PaytrServiceProvider"
Setup your environment
PAYTR_MERCHANT_ID=''
PAYTR_MERCHANT_SALT=''
PAYTR_MERCHANT_KEY=''
PAYTR_SUCCESS_URL='https://your-domain/success-payment'
PAYTR_FAIL_URL='https://your-domain/fail-payment'
PAYTR_TEST_MODE=true
*NOTE: PAYTR_SUCCESS_URL and PAYTR_FAIL_URL are the frontend URLs that will be redirected after the payment screen. They are not addresses where payment will be verified.*
**Create your product basket**
addProducts($products);
**Create Payment Request**
setCurrency(Currency::TRY)
->setUserPhone($phone)
->setUserAddress($address)
->setNoInstallment(1)
->setMaxInstallment(1)
->setEmail($email)
->setMerchantOid($oid) // Payment id generated by you
->setUserIp($ipAddress)
->setPaymentAmount($paymentAmount) // Total payment amount
->setUserName($name)
->setBasket($basket);
$paymentRequest = \Paytr::createPayment($payment);
if($paymentRequest->isSuccess()) {
$token = $paymentRequest->getToken();
// If the payment request has been successfully created,
// you can view the iframe using the token.
// Iframe URL: 'https://www.paytr.com/odeme/guvenli/'. $token
}
**Verify Payment**
You must set the Callback Url, where the result of the payment transaction will be notified to you, on the Paytr Panel.
You should add this endpoint as route
Route::post('paytr/payment-check', [PaytrController::class, 'checkPayment']);
And check payment
verifyRequest()) {
// Throw unauthorized
}
$oid = $verification->getMerchantOid(); // Payment id generated by you
$isSuccess = $verification->isSuccess(); // Is the payment status successful?
// ...
}
}