nickknissen/laravel-quickpay

该包已被废弃且不再维护。没有建议的替代包。

Quickpay API服务的简单Laravel包装器。

v0.7.0 2019-02-13 14:14 UTC

This package is auto-updated.

Last update: 2024-02-29 03:43:39 UTC


README

包装quickpay/quickpay-php-client

安装

composer require nickknissen/laravel-quickpay

php artisan vendor:publish --provider="nickknissen\QuickPay\QuickPayServiceProvider"

#Create card migration
php artisan migrate

v1之前的待办事项

  • 回调/Webhook控制器
  • 创建支付/退款构建器(流畅API/链式调用)
  • 重构卡类
  • 可选的synchronized参数

当前API

非生产环境支付前缀为E+当前环境的第一个字母。见QuickPay@orderIdPrefix
例如,订单ID 12345在APP_ENV=local时变为El12345,在APP_ENV=staging时变为ES12345

>> use nickknissen\QuickPay\Card;
>> use nickknissen\QuickPay\Payments;

>> $orderId = 12345; 
>> $userId = 12345; 
>> $amount = 1000; // amount in its smallest unit (cents/øre)

>> $card = new Card(['number' => 1000000000000008, 'expiration' => 2012, 'cvd' => 123]);
=> nickknissen\QuickPay\Card {#2951
     number: 1000000000000008,
     last_4_digits: "7569",
     type: "Test",
     expiration: 2010,
     cvd: 123,
   }

>> $card->createAsQuickPayCard($userId);
=> nickknissen\QuickPay\Card {#2974
     last_4_digits: "0008",
     type: "Test",
     user_id: 1,
     updated_at: "2018-09-06 07:51:46",
     created_at: "2018-09-06 07:51:46",
     id: 5,
   }

>> $payments = new Payments();
>> $payment = $payments->create($orderId);
=> {#2950
     +"id": 124473005,
     +"order_id": "12345",
     +"accepted": false,
     +"type": "Payment",
     ....
   }

>> $authorized = $payments->authorize($payment->id, $amount, $card);

=> {#2974
     +"id": 124473005,
     +"order_id": "12345",
     +"accepted": true,
     +"type": "Payment",
     ....
    +"operations": [
      {#2971
         +"id": 1,
         +"type": "authorize",
      ...
      },
   }
>> $captured = $payments->capture($payment->id, $amount);