rober-song/laravel-line-pay

LINE Pay for Laravel

v0.0.11 2025-03-10 03:42 UTC

This package is auto-updated.

Last update: 2025-06-10 04:07:52 UTC


README

Tests

申請sandbox帳號

LINE Pay Sandbox

套件安裝

引入 package 到 composer.json

composer require rober-song/laravel-line-pay

Laravel

發布設定檔案

php artisan vendor:publish --provider="Rober\LinePay\LinePayProvider"

設定檔案

設定檔案在 config/line_pay.php

簡介

  • 透過 facade LinePay 來使用
use Rober\LinePay\LinePay;

$response = LinePay::request([
    'amount' => 100,
    'currency' => 'TWD',
    'orderId' => 'order-123'
    ]);

return $response->getInfo();

Testing

<?php

/**
 * fake預設回傳
 * @see \Rober\LinePay\Fakes\PaymentFake::DEFAULT_RETURN
 */
use Rober\LinePay\LinePay;


test('[api] 測試確認', function () {
    LinePay::fake()->setReturn(info: ['orderId' => 'B',]);

    // 請求自己的對應api
    $response = $this->json('POST', '/line/pay/confirm/1');
    
    // 驗證
    $response->assertJson(['orderId' => 'B']);
});

test('[api] 多個請求', function () {
    LinePay::fake()
        ->setReturn(info: ['orderId' => 'A',])
        ->setReturn(code: '1141', message: 'Payment account error');

    // 請求自己的對應api
    $response = $this->json('POST', '/line/pay/A/and/B');
    // 驗證
    $response->assertStatus(400);
});

todo

  • 製作type (幣別, 付款方式, 語系, 確認網址)等等
  • 製作spy的assert (確認是否皆有用到設定的期望、指定對應接口)