定制 turown/laravel-paytr 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

turown/laravel-paytr

最新稳定版本:v1

Composer 安装命令:

composer require turown/laravel-paytr

包简介

PayTR integration for Laravel.

README 文档

README

MIT License

Description

PayTR integration for Laravel.
This package is under development, first version only supports iFame payment screen.

Thanks in advance for your contribution.

Installation

composer require turown/laravel-paytr

Publish configuration and assets

php artisan vendor:publish --tag="paytr"

Usage

To run this project you will need to add the following environment variables to your .env file

PAYTR_MERCANT_ID
PAYTR_MERCANT_KEY
PAYTR_MERCANT_SALT
PAYTR_API_URL
PAYTR_OK_URL
PAYTR_FAIL_URL

Configs

You can change or get the necessary settings in the config file. This file is important

use PayTR\Config;

You can easily access it with the help of it, you can perform operations as in the example.

The example below is the config that needs to be set for simple api triggering.

$config = new Config();
$config->setMerchantId(00000)
       ->setMerchantKey("XXXXX")
       ->setMerchantSalt("XXXX")
       ->setApiType(2) // iFrame Type
       ->setApiUrl(ENV('PAYTR_API_URL') . 'odeme/api/get-token');

Next, we define the required array variable to generate the HASH DATA.

 $hash_data = [
        "merchant_id"       => $config->getMerchantId(),
        "user_ip"           => request()->ip(),
        "merchant_oid"      => 1002945, //must be unique
        "email"             => "ali.riza.oztetik@gmail.com",
        "payment_amount"    => 999, //9.99 TL|EUR|USD vs. for 999;
        "user_basket"       => json_encode([
            ["Test Product", "9.99", 1] //(Product Name - Unit Price - Quantity)
        ]),
        "no_installment"    => $config->getNoInstallment(),
        "max_installment"   => $config->getMaxInstallment(),
        "currency"          => $config->getCurrency(),
        "test_mode"         => $config->getTestMode()
    ];

And we set the post data array and trigger the necessary

 $post_data = [
        'user_name'         => "Ali Rıza Öztetik",
        'user_address'      => "test",
        'user_phone'        => "901111111111", //Need [+][country code][area code][phone number]
        'paytr_token'       => $paytr->setHashStr($hash_data)->getToken()->token,
        'debug_on'          => $config->getDebugOn(),
        'merchant_ok_url'   => $config->getMerchantOkUrl(),
        'merchant_fail_url' => $config->getMerchantFailUrl(),
        'timeout_limit'     => $config->getTimeoutLimit()
    ];

 $post_data = array_merge($post_data, $hash_data); //Absolutely 2 array data must be combined.

Then you can activate the PayTR class and operate with the call method.

use PayTR\Paytr;

$trigger = $paytr->call($post_data, $config->getApiUrl());



Using iFrame will return you success and a token after the transaction. In addition, I have included the necessary javascript codes for you.

{
  +"status": "success"
  +"token": "090aab565210f757db0d9948ed4f58c8723a9f1de3beac1f651a90cdf9b2f678-324703229"
  +"javascript_file_url": "https://www.paytr.com/js/iframeResizer.min.js"
  +"iframe_code": "<iframe src="https://www.paytr.com/odeme/guvenli/090aab565210f757db0d9948ed4f58c8723a9f1de3beac1f651a90cdf9b2f678-324703229" id="paytriframe" frameborder="0" scrolling="no" style="width: 100%;"></iframe>"
  +"script": "<script>iFrameResize({},'#paytriframe');</script>"
}

By including the script with the "javascript_file_url" in the return, you can print the "iframe_code" code wherever you want. Don't forget to include the "script" variable as well.



It's actually that simple!

A payment screen will then appear on your screen. After the transaction made on this screen, the API will return to you, all your successful or unsuccessful returns are specified in the settings;

'merchant_ok_url' => $config->getMerchantOkUrl()
'merchant_fail_url' => $config->getMerchantFailUrl()

This is why these settings are very important.

统计信息

  • 总下载量: 143
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-18