承接 tbclla/laravel-revolut-merchant 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tbclla/laravel-revolut-merchant

Composer 安装命令:

composer require tbclla/laravel-revolut-merchant

包简介

An unoffial Laravel wrapper for Revolut's Merchant API

README 文档

README

Latest Stable Version License Build Status Scrutinizer Code Quality

Laravel-Revolut (Merchant)

An unofficial Laravel wrapper for Revolut's Merchant API.
A sister package for Revolut's Open API for Business can be found here.

Requirements

  • Laravel >=5.8
  • PHP >=7.2

Getting Started

Follow this guide on how to install the package, and read Revolut's Merchant API documentation to learn more about the functionalities offered by the API.

⚠️ Please use a sandbox account when setting up this package, and only switch to your real-world account once you're happy that everything is working correclty.

Installing

Pull the package in through Composer

composer require tbclla/laravel-revolut-merchant

Service Provider & Facade

If you have disabled auto-discovery, add the service provider and facade to your config/app.php.

'providers' => [
    // ...
    tbclla\RevolutMerchant\Providers\RevolutMerchantServiceProvider::class,
],

'aliases' => [
    // ...
    'Merchant' => tbclla\RevolutMerchant\Facades\Merchant::class,
]

Publish the configuration (optional)

If you would like to publish this package's configuration to your own config directory, use the below artisan command.

php artisan vendor:publish --provider "tbclla\RevolutMerchant\Providers\RevolutMerchantServiceProvider"

Set environment variables

Add the following keys to your project's .env file, as all of the configuration values are read from there.
❗Complete the REVOLUT_MERCHANT_API_KEY with the API key from your merchant account.

REVOLUT_MERCHANT_SANDBOX=true
REVOLUT_MERCHANT_API_KEY=

That's it, you're all done.

How to use this package

To use the client, you can either instantiate a new tbclla\RevolutMerchant\Client which accepts your API key, and whether or not to run in sandbox mode:

use tbclla\RevolutMerchant\Client;

// sandbox
$merchant = new Client('your_api_key', true);
// production
$merchant = new Client('your_api_key');

$merchant->order()->get($orderId);

Or you can use the facade, which will inject your environment values.
For brevity, all of the examples in this documentation are using the facade.

use tbclla\RevolutMerchant\Facades\Merchant;

Merchant::order()->get($id);

Orders

Please refer to Revolut's official documentation on orders for additional information on how to use the orders endpoint.

Create an order

Merchant::order()->create([
    "amount" => 200,
    "capture_mode" => "MANUAL",
    "merchant_order_id" => "00122",
    "customer_email" => "sally.gibson@gmail.com",
    "description" => "description",
    "currency" => "GBP",
    "settlement_currency" => "USD",
    "merchant_customer_id" => "sally01"
]);

Retrieve an order

$orderId = 'd41c46db-5f82-4dd7-8a22-a43ac517b6df';

Merchant::order()->get($orderId);

Capture an order

Merchant::order()->capture($orderId);

Cancel an order

Merchant::order()->cancel($orderId);

Refund an order

Merchant::order()->refund($orderId, [
    "amount" => 100,
    "currency" => "GBP",
    "merchant_order_id" => "00122",
    "description" => null
]);

Web-Hooks

Read Revolut's official documentation about web-hooks to learn more.

Create the web-hook

Merchant::webhook()->create('https://myapp.com/webhook');

Revoke the web-hook

Merchant::webhook()->revoke();

Retrieve web-hooks

Merchant::webhook()->retrieve();

Revolut Checkout Widget API

To use the checkout widget, you have to embed a script from Revolut on any page that will use the checkout widget.

This package includes a @revolutMerchantScript blade directive which will embed this script for you and set the correct source depending on your configured environment.

<head>
    <title>Checkout Page</title>

    @revolutMerchantScript
</head>
<body>
    ...
</body>

Brief example

Below is a quick and dirty example to illustrate how to create a new payment order, and subsequently display a payment pop-up.

For this example, the logged in user sends an AJAX request to a /purchase route, where a new payment order is created. The payment order's public_id is then returned and passed to RevolutCheckout().

PHP

Route::post('/purchase', function() {
    // Get the logged in user
    $user = Auth::user();
    // Fetch the item being purchased
    $item = Item::find(request('item_id'));
    // Create a new payment order
    $paymentOrder = Merchant::order()->create([
        "currency" => "GBP",
        "description" => $item->name,
        "amount" => $item->price,
        "customer_email" => $user->email,
        "merchant_customer_id" => $user->id,
    ]);
    // return the payment order's 'public_id'
    return $paymentOrder['public_id'];
});

JavaScript

❗Don't forget that any page which intends to use RevolutCheckout() must include the above mentioned checkout widget script before calling RevolutCheckout().

// the user triggers a request to the above route
axios.post('/purchase', {"item_id": 123456}).then((response) => {
    // get the 'public_id' from the response
    let publicId = response.data;
    // pass the 'public_id' to RevolutCheckout()
    RevolutCheckout(publicId).then(function(instance) {
        // Launch the pop-up
        instance.payWithPopup({
            onSuccess() { ... },
            onError(message) { ... }
        });
    });
});

License

This project is licensed under the MIT License - see the LICENSE.md file for details

tbclla/laravel-revolut-merchant 适用场景与选型建议

tbclla/laravel-revolut-merchant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 71 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 04 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tbclla/laravel-revolut-merchant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tbclla/laravel-revolut-merchant 我们能提供哪些服务?
定制开发 / 二次开发

基于 tbclla/laravel-revolut-merchant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 71
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-14