首页
/ ActiveMerchant Patch for China 使用教程

ActiveMerchant Patch for China 使用教程

2024-08-25 09:14:38作者:江焘钦

项目介绍

activemerchant_patch_for_china 是一个 Rails 插件,旨在为中国的在线支付平台添加 ActiveMerchant 补丁。该项目支持多种支付平台,包括支付宝(Alipay)、快钱(99bill)、财付通(Tenpay)等。该插件由 Richard Huang 开发,并在 MIT 许可证下发布。

项目快速启动

安装

作为插件安装

script/plugin install git://github.com/Shopify/active_merchant.git
script/plugin install git://github.com/flyerhzm/activemerchant_patch_for_china.git

作为 Gem 安装

gem install activemerchant
gem install activemerchant_patch_for_china

配置

如果你将 activemerchantactivemerchant_patch_for_china 作为 Rails 插件安装,需要在 config/environment.rb 中定义插件加载顺序,确保 activemerchant_patch_for_chinaactivemerchant 之后加载:

config.plugins = [:all, :active_merchant, :activemerchant_patch_for_china]

应用案例和最佳实践

使用支付宝(Alipay)

以下是一个使用支付宝的示例:

require 'active_merchant'
require 'active_merchant/billing/integrations/action_view_helper'

ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)

在视图中使用支付宝支付:

<%= payment_service_for 'order_id', 'your_alipay_account', :service => :alipay do |service|
  service.seller_email 'your_alipay_account@example.com'
  service.item_name 'Order #123'
  service.amount '100.00'
  service.return_url 'http://yourwebsite.com/payment_return'
  service.notify_url 'http://yourwebsite.com/payment_notify'
end %>

典型生态项目

ActiveMerchant

ActiveMerchant 是一个用于处理支付网关的 Ruby 库,支持多种支付服务提供商。它是 Shopify 开发的一个开源项目,广泛用于电子商务应用中。

其他相关项目

  • Alipay Gem: 专门用于集成支付宝的 Ruby Gem。
  • 99bill Gem: 专门用于集成快钱的 Ruby Gem。
  • Tenpay Gem: 专门用于集成财付通的 Ruby Gem。

这些项目共同构成了一个完整的支付生态系统,为开发者提供了丰富的选择和灵活的集成方式。

登录后查看全文
热门项目推荐

项目优选

收起
kernelkernel
deepin linux kernel
C
27
11
docsdocs
OpenHarmony documentation | OpenHarmony开发者文档
Dockerfile
469
3.48 K
nop-entropynop-entropy
Nop Platform 2.0是基于可逆计算理论实现的采用面向语言编程范式的新一代低代码开发平台,包含基于全新原理从零开始研发的GraphQL引擎、ORM引擎、工作流引擎、报表引擎、规则引擎、批处理引引擎等完整设计。nop-entropy是它的后端部分,采用java语言实现,可选择集成Spring框架或者Quarkus框架。中小企业可以免费商用
Java
10
1
leetcodeleetcode
🔥LeetCode solutions in any programming language | 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
Java
65
19
flutter_flutterflutter_flutter
暂无简介
Dart
716
172
giteagitea
喝着茶写代码!最易用的自托管一站式代码托管平台,包含Git托管,代码审查,团队协作,软件包和CI/CD。
Go
23
0
kernelkernel
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
208
83
RuoYi-Vue3RuoYi-Vue3
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
1.27 K
695
rainbondrainbond
无需学习 Kubernetes 的容器平台,在 Kubernetes 上构建、部署、组装和管理应用,无需 K8s 专业知识,全流程图形化管理
Go
15
1
apintoapinto
基于golang开发的网关。具有各种插件,可以自行扩展,即插即用。此外,它可以快速帮助企业管理API服务,提高API服务的稳定性和安全性。
Go
22
1