kameli /
与丹麦支付网关Quickpay通信的库
v6.5.0
2023-04-26 09:42 UTC
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
Requires (Dev)
- illuminate/collections: ^9.42.2
- symfony/var-dumper: ^6.2
This package is auto-updated.
Last update: 2024-09-26 12:38:10 UTC
README
功能
- 访问Quickpay API
- 支付
- 订阅
- 卡
- 退款
- 品牌
- 生成支付链接
- 验证回调
- 生成支付表单
前往官方QuickPay文档以探索所有端点和选项: http://tech.quickpay.net/api/services/?scope=merchant
安装
composer require kameli/quickpay-v10
示例
处理支付
<?php use Kameli\Quickpay\Quickpay; $qp = new Quickpay('API_KEY', 'PRIVATE_KEY'); $payment = $qp->payments()->create([ 'currency' => 'DKK', 'order_id' => 'SOME_UNIQUE_ORDER_ID', ]); $link = $qp->payments()->link($payment->getId(), [ 'amount' => 10000, // amount in least valuable unit (øre) ]); // Make the user follow the payment link which will take them to a form where they put in their card details $url = $link->getUrl(); // When the form has been completed, a POST request will be sent to a specified url where you can validate it if ($qp->validateCallback()) { $payment = $qp->receivePaymentCallback(); // Capture the amount to charge the card $qp->payments()->captureAmount($payment->getId(), $payment->amount()); // Handle order }
创建订阅并执行周期性支付
请记住为使用的收购商启用订阅。
<?php use Kameli\Quickpay\Quickpay; $qp = new Quickpay('API_KEY', 'PRIVATE_KEY'); $subscription = $qp->subscriptions()->create([ 'currency' => 'DKK', 'order_id' => 'SOME_UNIQUE_ORDER_ID', 'description' => 'Abonnement', ]); $link = $qp->subscriptions()->link($subscription->getId(), [ 'amount' => 100, // the amount does not matter here, but is still required for some reason ]); // Make the user follow the payment link which will take them to a form where they put in their card details $url = $link->getUrl(); // When the form has been completed, a POST request will be sent to a specified url where you can validate it if ($qp->validateCallback()) { $subscription = $qp->receiveSubscriptionCallback(); } // Use the recurring method to make new payments $payment = $qp->subscriptions()->recurring($subscription->getId(), [ 'amount' => 10000, 'order_id' => 'SOME_UNIQUE_ORDER_ID', ]); // Capture the amount to charge the card $qp->payments()->captureAmount($payment->getId(), $payment->amount());