Code Monkey home page Code Monkey logo

laravel-omnipay's Introduction

Laravel Omnipay


Latest version Build status Quantity score StyleCI Total download License

Thông tin

Hiện nay các cổng thanh toán trong nước có cấu trúc API rất đa dạng và ít có điểm chung, khiến cho việc chúng ta xây dựng các api-client cũng gặp nhiều khó khăn, chính vì vậy package này được sinh ra nhằm đồng bộ các phương thức của các cổng thanh toán, giúp cho việc tích hợp sẽ dễ dàng hơn, nó được thiết kế trên nền tảng Omnipay giúp bạn tối giản lại các tham trị khi tạo request gửi lên các cổng thanh toán. Do tất cả các cổng thanh toán đều có phương thức chung nên nó sẽ giúp cho bạn chuyển tiếp từ cổng thanh toán này sang cổng thanh toán khác đơn giản hơn.

Ví dụ:

\MoMoAIO::purchase([
    'amount' => 20000,
    'returnUrl' => 'https://github.com/phpviet',
    'notifyUrl' => 'https://github.com/phpviet',
    'orderId' => 'Mã đơn hàng',
    'requestId' => 'Mã request id, gợi ý nên xài uuid4',
])->send();


\OnePayDomestic::purchase([
    'AgainLink' => 'https://github.com/phpviet',
    'vpc_MerchTxnRef' => microtime(false),
    'vpc_ReturnURL' => 'https://github.com/phpviet',
    'vpc_TicketNo' => '127.0.0.1',
    'vpc_Amount' => '200000',
    'vpc_OrderInfo' => 456,
])->send();

\VNPay::purchase([
    'vnp_TxnRef' => time(),
    'vnp_OrderType' => 100000,
    'vnp_OrderInfo' => time(),
    'vnp_IpAddr' => '127.0.0.1',
    'vnp_Amount' => 1000000,
    'vnp_ReturnUrl' => 'https://github.com/phpviet',
])->send();

\VTCPay::purchase([
    'receiver_account' => '0963465816',
    'reference_number' => microtime(false),
    'amount' => 50000,
    'url_return' => 'https://phpviet.org'
])->send();

Các cổng thanh toán đang được hổ trợ tích hợp:

Cài đặt

Cài đặt Laravel Omnipay thông qua Composer:

composer require phpviet/laravel-omnipay

Sau khi cài đặt xong bạn cần phải publish config file để thiết lập thông số cho cổng thanh toán bạn cần tích hợp, publish thông qua câu lệnh:

php artisan vendor:publish --provider="PHPViet\Laravel\Omnipay\OmnipayServiceProvider" --tag="config"

Nội dung file publish nằm trong thư mục config/laravel-omnipay.php của bạn như sau:

return [
    // Cấu hình cho các cổng thanh toán tại hệ thống của bạn, các cổng không xài có thể xóa cho gọn hoặc không điền.
    // Các thông số trên có được khi bạn đăng ký tích hợp.
    
    'gateways' => [
        'MoMoAIO' => [
            'driver' => 'MoMo_AllInOne',
            'options' => [
                'accessKey' => '',
                'secretKey' => '',
                'partnerCode' => '',
                'testMode' => false,
            ],
        ],
        'MoMoQRCode' => [
            'driver' => 'MoMo_QRCode',
            'options' => [
                'accessKey' => '',
                'secretKey' => '',
                'partnerCode' => '',
                'testMode' => false,
            ],
        ],
        'MoMoAIA' => [
            'driver' => 'MoMo_AppInApp',
            'options' => [
                'accessKey' => '',
                'secretKey' => '',
                'partnerCode' => '',
                'publicKey' => '',
                'testMode' => false,
            ],
        ],
        'MoMoPOS' => [
            'driver' => 'MoMo_POS',
            'options' => [
                'accessKey' => '',
                'secretKey' => '',
                'partnerCode' => '',
                'publicKey' => '',
                'testMode' => false,
            ],
        ],
        'OnePayDomestic' => [
            'driver' => 'OnePay_Domestic',
            'options' => [
                'vpcMerchant' => '',
                'vpcAccessCode' => '',
                'vpcUser' => '',
                'vpcPassword' => '',
                'vpcHashKey' => '',
                'testMode' => false,
            ],
        ],
        'OnePayInternational' => [
            'driver' => 'OnePay_International',
            'options' => [
                'vpcMerchant' => '',
                'vpcAccessCode' => '',
                'vpcUser' => '',
                'vpcPassword' => '',
                'vpcHashKey' => '',
                'testMode' => false,
            ],
        ],
        'VTCPay' => [
            'driver' => 'VTCPay',
            'options' => [
                'websiteId' => '',
                'securityCode' => '',
                'testMode' => false,
            ],
        ],
        'VNPay' => [
            'driver' => 'VNPay',
            'options' => [
                'vnpTmnCode' => '',
                'vnpHashSecret' => '',
                'testMode' => false,
            ],
        ],
    ],
];

Cách sử dụng

Dành cho nhà phát triển

Nếu như bạn cảm thấy thư viện chúng tôi còn thiếu sót hoặc sai sót và bạn muốn đóng góp để phát triển chung, chúng tôi rất hoan nghênh! Hãy tạo các issue để đóng góp ý tưởng cho phiên bản kế tiếp hoặc tạo PR để đóng góp phần thiếu sót hoặc sai sót. Riêng đối với các lỗi liên quan đến bảo mật thì phiền bạn gửi email đến [email protected] thay vì tạo issue. Cảm ơn!

laravel-omnipay's People

Contributors

harryoppa avatar notmd avatar vuongxuongminh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-omnipay's Issues

Lỗi Data Signature response from VNPay is Invalid của Vnpay

Mình bị lỗi như trên title (có khả năng là do config định dạng hash md5 hoặc sha256) có cách nào để fix không ạ? Lỗi này hiển thị khi mình query hóa đơn bên VnPay, còn khi thực hiện giao dịch thì hoàn toàn bình thường

Vui lòng hỗ trợ thêm laravel 10

Hi tác giả,

Mình có sử dụng package này cho công ty, tuy nhiên công ty đang sử dụng Laravel 10, bạn có thể nâng cấp package để hỗ trợ laravel 10 được không?

Sai chính tả.

Package hổ trợ tích hợp các cổng thanh toán trong nước.
Hỗ trợ chứ không phải hổ trợ nhé bạn.

Lỗi The `accessKey` parameter is required

Mình đã điên đầy thủ thông tin accessKey, secretKey, partnerCode và testMode đang để false. Nhưng khi "kiểm tra thông tin notifyUrl do MoMo gửi sang" thì bị báo lỗi này "The accessKey parameter is required". Tài mình đang làm việc trong môi trường test của momo. Mong mọi người giải đáp ạ. Cảm ơn

Lỗi refund vnpay

Mình đã điền đầy đủ các trường cần thiết như trong docs:
['vnp_Amount', 'vnp_TransactionType', 'vnp_TransDate', 'vnp_TxnRef', 'vnp_OrderInfo', 'vnp_IpAddr', 'vnp_TransactionNo']
Tuy nhiên vnpay trả về lỗi Parameter required, nhờ bạn xem giúp mình là mình đang thiếu trường nào ạ?

Phiên bản php

Này mình tích hơp trên php 8 kh đc hả ad , e tích hợp mà nó yêu cầu php 7.1 , có cách nào đc k ạ

Lỗi khi cài trên Laravel 8

Hiện là mình khi cài trên laravel 8 thì bị lỗi như thế này
Hình như là bị conflic với version guzzlehttp/guzzle mặc định trên laravel 8
Mình có xem trên trên upgrade guide laravel 8 thì thấy yêu cầu update guzzle lên ^7.0.1, còn bên laravel-omnipay thì hình như yêu cầu 6.5

Using version ^1.1 for phpviet/laravel-omnipay
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpviet/laravel-omnipay ^1.1 -> satisfiable by phpviet/laravel-omnipay[1.1.0, 1.1.1, 1.1.x-dev].
    - Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.2.0].
    - Can only install one of: guzzlehttp/guzzle[7.2.0, 6.5.x-dev].
    - Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.2.0].
    - Conclusion: install guzzlehttp/guzzle 6.5.x-dev
    - Installation request for guzzlehttp/guzzle (locked at 7.2.0, required as ^7.0.1) -> satisfiable by guzzlehttp/guzzle[7.2.0].


Installation failed, reverting ./composer.json to its original content.

Làm thế nào test cho môi trường sanbox với VNPay

Làm thế nào test cho môi trường sanbox với VNPay
$gateway = Omnipay::create('VNPay');
$gateway->initialize([
'vnp_TmnCode' => '',
'vnp_HashSecret' => '',
]);

    $response = $gateway->purchase([
        'vnp_TxnRef' => time(),
        'vnp_OrderType' => 100000,
        'vnp_OrderInfo' => time(),
        'vnp_IpAddr' => '127.0.0.1',
        'vnp_Amount' => 1000000,
        'vnp_ReturnUrl' => 'https://github.com/phpviet',
    ])->send();

Thấy trong PurchaseRequest có
class PurchaseRequest extends AbstractSignatureRequest{

protected $productionEndpoint = 'https://pay.vnpay.vn/vpcpay.html';
protected $testEndpoint = 'http://sandbox.vnpayment.vn/paymentv2/vpcpay.html';

Nhờ hỗ trợ

Screen Shot 2020-06-19 at 11 08 09

Mình đã cấu hình đúng như hướng dẫn nhưng vẫn gặp lỗi này, xin hỗ trợ giúp. Xin cảm ơn!

Phiên bản php

Này mình tích hơp trên php 8 kh đc hả ad , e tích hợp mà nó yêu cầu php 7.1 , có cách nào đc k ạ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.