承接 ournameismud/currency-layer 相关项目开发

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

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

ournameismud/currency-layer

Composer 安装命令:

composer require ournameismud/currency-layer

包简介

API integration with https://currencylayer.com/

README 文档

README

API integration with https://currencylayer.com/

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require ournameismud/currency-layer
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Currency Layer.

Currency Layer Overview

This is a plugin layer for the Currency Layer API that lets you store and retrieve currency values locally. If you use this in conjunction with Craft Commerce it will populate the conversion rate values for corresponding Payment Currencies.

Configuring Currency Layer

To use this plugin you will require an API key from Currency Layer. A basic account is free but rate-limited to 250 Requests/mo.

Options available in the plugin can be saved in Plugin > Settings or via a config file.

The plugin settings available are:

  • apiKey the Currency Layer API key
  • primaryCurrency the primary currency you want to use as the base for conversions
  • apiCache whether to cache the response (recommended)
  • cacheDuration how long you want the cache to be stored/saved for

Using Currency Layer

You can use Currency Layer in one of two ways. The first way is via an action. This is best used in conjunction with a CRON job to fetch the results periodically. The action can be triggered via a URL as follows:

http://your.domain.com/actions/currency-layer/currency/fetch?currencies=EUR,GBP,USD with the currencies parameter being a comma-separated list of currencies you wish to retrieve. Note that the base (free) version of Currency Layer will always default to USD as the source.

If you are using Craft Commerce this action will save the conversion rates directly into your Commerce settings. Otherwise the conversion values are available via the craft.currencyLayer.fetch() variable:

craft.currencyLayer.fetch(request,type) where request is required and should be an object of key:value attributes corresponding to the endpoints for the Currency Layer API you require (please note that many of the endpoints are limited to paid-for accounts). The type parameter corresponds to the type of query you wish to make (defaults to live).

For example, {% set data = craft.currencyLayer.fetch({ currencies:'EUR,GBP,USD' }) %} would fetch the following endpoint: https://apilayer.net/api/live?currencies=EUR,GBP,USD&access_key=YOUR_ACCESS_KEY. The response will be an array of values which provide multipliers based on the primary currency defined in your plugin settings. With this in mind we can build out a macro to perform some simple currency conversion, for example:

{%- macro convert(value = 1, currency) -%}
    {% set data = craft.currencyLayer.fetch({ currencies:'EUR,GBP,USD' }) %}
    {{- data[currency] * value -}}
{%- endmacro -%}

{% set GBP = 100 %}
{% set EUR = _self.convert(100,'EUR') %}
{% set USD = _self.convert(100,'USD') %}

<dl>
    <dt>GBP</dt><dd>{{ GBP }}</dd>
    <dt>EUR</dt><dd>{{ EUR }}</dd>
    <dt>USD</dt><dd>{{ USD }}</dd>
</dl>

The plugin is designed to work closely with Craft Commerce currencies. If currencies are already defined in Craft Commerce the option to select a primary currency is restricted to those available in Craft Commerce. If a new primary currency is selected in the plugin then the primary Craft Commerce currency is updated and vice versa.

Currency Layer Roadmap

Some things to do, and ideas for potential features:

  • Release it

Brought to you by cole007

ournameismud/currency-layer 适用场景与选型建议

ournameismud/currency-layer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 842 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 09 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「Craft」 「craftcms」 「currencylayer」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 ournameismud/currency-layer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-26