blood72/laravel-iamport

此包已弃用,不再维护。未建议替代包。

Laravel 7 的 Iamport API

v1.1.0 2020-11-23 16:50 UTC

This package is auto-updated.

Last update: 2023-09-24 20:51:49 UTC


README

아임포트(Iamport)는 국내 주요 PG사들을 쉽게 연동할 수 있도록 도와주는 서비스입니다.
Iamport 是一种帮助轻松实现主要支付网关集成的服务。

此包不受官方支持。
This package is not officially supported.

索引

需求

  • PHP ^7.4
  • Laravel ^7.0 | ^8.0
  • Guzzle ^6.3 | ^7.0

安装

composer 可以安装。
使用 composer 安装。

composer require blood72/laravel-iamport

配置文件 可发布。
您可以将 配置文件 发布。

php artisan vendor:publish --provider="Blood72\Iamport\IamportServiceProvider"

配置

需要 IAMPORT_KEYIAMPORT_SECRET 值。
需要 IAMPORT_KEYIAMPORT_SECRET

// in iamport.php
'id' => env('IAMPORT_ID_CODE'), // 가맹점 식별코드 (Merchant ID)
'key' => env('IAMPORT_KEY', 'imp_apikey'),
'secret' => env('IAMPORT_SECRET', 'ekKoeW8RyKuT0zgaZsUtXXTLQ4AhPFW3ZGseDA6bkA5lamv9OqDMnxyeB9wqOsuO9W3Mx9YSJ4dTqJ3f'),

使用

可以通过 Facade 或 resolve 方法使用。
您可以使用 Facade 或 resolve 方法。

$payments = app('iamport')->getPayments();
$payments = Iamport::getPayments();

查看 参考 的 API 文档以了解方法。
查看 API 文档的参考可以帮助理解方法。

  1. getPayment(...$impUid)
    // same result
    $payment = Iamport::getPayment('imp_779297761907');
    $payment = app('iamport')->getPayment(282589766101); // method adds 'imp_' automatically
    
    // return \Illuminate\Support\Collection::class
    $payments = Iamport::getPayment('imp_604050400483', 'imp_993488541671');
  2. getPayments($status = 'all', $options = [])
    // same result (TODO)
    $payments = Iamport::getPayments('paid', ['limit' => 3]);
    // $payments = Iamport::getPayments([
    //     'status' => 'paid',
    //     'limit' => 3,
    // ]);
  3. findPayment($merchantUid, $status = null, array $options = [])
    $payment = Iamport::findPayment('merchant_1591942195747');
  4. findPayments($merchantUid, $status = null, array $options = [])
    $payment = Iamport::findPayment('merchant_1591942195747');
  5. setPreparePayment($merchantUid, $amount) & getPreparePayment($merchantUid)
    // return \Blood72\Iamport\Payloads\PreparedPayment::class
    $payment = Iamport::setPreparePayment('b72-ae8ea2f204bd2285c03918ec321fa4ff', 124);
    $payment = Iamport::getPreparePayment('b72-ae8ea2f204bd2285c03918ec321fa4ff');
  6. cancelPayment($impUid, ?int $amount = null, ?string $reason = null, array $options = [])
    // same result
    Iamport::cancelPayment($impUid, $amount, $reason);
    Iamport::cancelPayment([
        'imp_uid' => $impUid,
        'amount' => $amount,
        'reason' => $reason,
    ]);

TODO

参考

许可证

此包是 MIT 许可证的开放源代码软件。
This package is open-sourced software licensed under the MIT license.