首页
/ ActiveMerchant Patch for China 使用教程

ActiveMerchant Patch for China 使用教程

2024-08-25 05:28:41作者:江焘钦

项目介绍

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。

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

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