Extension:DonationInterface

This page is a translated version of the page Extension:DonationInterface and the translation is 100% complete.
MediaWiki扩展手册
DonationInterface
发行状态: 稳定版
实现 特殊页面
描述 提供筹款机制来收取款项
作者 Elliott Eggleston, Maggie Epps, Dylan Kozlowski. inactive: Casey Dentinger, Katie Horn, Adam Roses Wight, Matt Walker, Ryan Kaldari, Sherah Smith
最新版本 2.1.0
兼容性政策 master分支维持向后兼容。
MediaWiki >= 1.39
Composer wikimedia/donation-interface
许可协议 GNU通用公眾授權條款2.0或更新版本
下載
  • $wgDonationInterfaceMinFraudAlarmLimit
  • $wgDonationInterfaceEmployersListDataFileLocation
  • $wgDonationInterfaceEnableMinFraud
  • $wgDonationInterfaceEnableIPVelocityFilter
  • $wgPaypalExpressGatewayTestingCertificateURL
  • $wgDonationInterfaceSessionVelocity_HitScore
  • $wgDonationInterfaceChooserProblemURL
  • $wgDonationInterfaceVariantConfigurationDirectory
  • $wgDonationInterfaceDefaultAppeal
  • $wgDonationInterfaceFallbackCurrencyByCountry
  • $wgDonationInterfaceCurlVerboseLog
  • $wgDonationInterfaceIPDenyFailScore
  • $wgDonationInterfaceTest
  • $wgDonationInterfaceLogClientErrors
  • $wgDonationInterfaceTaxDedCountries
  • $wgDonationInterfaceSalt
  • $wgDonationInterfaceClientErrorLogIgnorePatterns
  • $wgDonationInterfaceMajorGiftsEmail
  • $wgPaypalExpressGatewayTestingSignatureURL
  • $wgDonationInterfaceIPVelocityFailScore
  • $wgDonationInterfaceEnableGatewayChooser
  • $wgDonationInterfaceMonthlyConvertCountries
  • $wgDonationInterfaceCustomFiltersRiskScore
  • $wgDonationInterfaceMinFraudLicenseKey
  • $wgDonationInterfaceEnableBannerHistoryLog
  • $wgDonationInterfaceSurnameFirstCountries
  • $wgAmazonGatewayLoginScript
  • $wgDonationInterfaceMinFraudWeight
  • $wgDonationInterfaceMinFraudAccountId
  • $wgDonationInterfaceUseSyslog
  • $wgDonationInterfaceHeader
  • $wgDonationInterfaceDisplayDebug
  • $wgDonationInterfaceFundraiserMaintenance
  • $wgDonationInterfaceEmailFormHelpEmail
  • $wgDonationInterfaceRecurringUpgradeMaxUSD
  • $wgDonationInterfaceCancelPage
  • $wgDonationInterfaceEnableFunctionsFilter
  • $wgDonationInterfaceNotifyOnConvert
  • $wgDonationInterfaceRecurringUpgradeOptions
  • $wgDonationInterfaceAppealWikiTemplate
  • $wgIngenicoGatewayEnabled
  • $wgDonationInterfaceEmailPreferencesLanguages
  • $wgDonationInterfaceCiviproxyURLBase
  • $wgDonationInterfaceSaveCommStats
  • $wgDonationInterfaceEmailPreferencesCountries
  • $wgDonationInterfaceMonthlyConvertAmounts
  • $wgBraintreeGatewayEnabled
  • $wgDonationInterfaceLocalConfigurationDirectory
  • $wgDonationInterfaceCustomFiltersRefRules
  • $wgDonationInterfaceMonthlyConvertDefaultModule
  • $wgDonationInterfaceGatewayAdapters
  • $wgDonationInterfaceGeoIpDbPath
  • $wgDonationInterfaceEnableSystemStatus
  • $wgDonationInterfaceSendOptInOnFailure
  • $wgDonationInterfaceEmailDomainMap
  • $wgDonationInterfaceEnableSessionVelocityFilter
  • $wgDonationInterfaceIPVelocityThreshhold
  • $wgDonationInterfaceEnableSourceFilter
  • $wgDonationInterfaceEnableReferrerFilter
  • $wgDonationInterfaceSessionVelocity_Multiplier
  • $wgDonationInterfaceForbiddenCountries
  • $wgAmazonGatewayEnabled
  • $wgDonationInterfaceIPVelocityTimeout
  • $wgDonationInterfaceTaxURL
  • $wgDonationInterfaceEnableCustomFilters
  • $wgDonationInterfaceProblemsURL
  • $wgPaypalExpressGatewayCertificateURL
  • $wgDonationInterfaceUtmMediumMap
  • $wgDonationInterfaceTimeout
  • $wgPaypalExpressGatewayEnabled
  • $wgAdyenCheckoutGatewayEnabled
  • $wgDonationInterface3DSRules
  • $wgDonationInterfaceNameFilterRules
  • $wgDonationInterfaceDefaultEmail
  • $wgDonationInterfaceMinFraudErrorScore
  • $wgDonationInterfaceUtmSourceMap
  • $wgDonationInterfaceRetryLoopCount
  • $wgDonationInterfaceUtmCampaignMap
  • $wgDonationInterfaceLogoOverride
  • $wgDonationInterfaceCountryMap
  • $wgDonationInterfaceSessionVelocity_Threshold
  • $wgDonationInterfaceMessageSourceType
  • $wgDonationInterfaceSessionVelocity_DecayRate
  • $wgDonationInterfaceFallbackCurrency
  • $wgDonationInterfacePolicyURL
  • $wgDonationInterfaceCustomFiltersInitialFunctions
  • $wgDonationInterfaceCustomFiltersFunctions
  • $wgDonationInterfaceCustomFiltersActionRanges
  • $wgDonationInterfaceOtherWaysURL
  • $wgDonationInterfaceMinFraudExtraFields
  • $wgDonationInterfaceMinFraudClientOptions
  • $wgDonationInterfaceLogCompleted
  • $wgDonationInterfaceCustomFiltersSrcRules
  • $wgPaypalExpressGatewaySignatureURL
  • $wgDlocalGatewayEnabled
  • $wgDonationInterfaceFailPage
  • $wgDonationInterfaceGatewayPriorityRules
  • $wgDonationInterfaceEnableConversionLog
  • $wgDonationInterfaceThankYouPage
  • $wgDonationInterfaceProblemsEmail
  • $wgIngenicoGatewayHostedFormVariants
  • $wgDonationInterfaceNoScriptRedirect
  • $wgDonationInterfaceFaqURL
  • $wgDonationInterfaceDebugLog
季度下載量 2 (Ranked 142nd)
前往translatewiki.net翻譯DonationInterface扩展
問題 开启的任务 · 报告错误

DonationInterface呈现付款表格,并提供recharinary机制,用于通过各种支付网关收集和跟踪付款。

概述

捐赠接口扩展所做的大部分工作都是与支付网关进行通信。 我们还提供了一个面向用户的表单层,用于接受捐赠。

安装

配置

在LocalSettings.php中include以下内容:

wfLoadExtension( "DonationInterface" );

接下来,定义要启用的网关。

例如,以下内容将打开所有当前网关和扩展 (TODO:文档默认值和更新。):

$wgDonationInterfaceAdyenGatewayEnabled = true;
$wgDonationInterfaceAmazonGatewayEnabled = true;
$wgDonationInterfaceAstroPayGatewayEnabled = true;
$wgDonationInterfaceGlobalCollectGatewayEnabled = true;
$wgDonationInterfaceIngenicoGatewayEnabled = true;
$wgDonationInterfaceEnableMinFraud = true;
$wgDonationInterfaceEnableReferrerFilter = true;
$wgDonationInterfaceEnableSourceFilter = true;

在此之后,TODO确保为您打算使用的每个网关定义帐户信息,例如:

    <?php
    # settings.d/wikis/paymentswiki/settings.d/01-DI-real.php

    $wgGlobalCollectGatewayAccountInfo = array(
        'default' => array(
            'MerchantID' => '1234',
        ),
    );

    $wgPaypalGatewayAccountInfo = array(
        'default' => array(
            'AccountEmail' => 'magoo@localhost.net',
        ),
    );

重要信息:

DonationInterface以一种特殊的方式搜索全局。

网关使用的任何DonationInterface全局都可以被分配一个特定于该网关的值,或者是整个扩展的默认值(如果两者都存在,则细节将覆盖默认值)。

要为网关全局分配扩展范围的默认值,只需将全局变量名称中的网关前缀换成“wgDonationInterface”即可。

例如:要在默认情况下为整个DonationInterface扩展打开syslogging,而不仅仅是payflow pro网关,请更改以下内容:

$wgIngenicoGatewayUseSyslog = true;

到这:

$wgDonationInterfaceUseSyslog = true;

Syslog现在将为所有网关启用,除非您使用特定于网关的全局变量关闭它们。

额外配置

要创建自定义捐赠筛选规则,请在LocalSettings.php文件中设置$wgCustomFiltersRefRules和$wgCustomFilter SrcRules全局变量。

这些数组应设置为关联数组,将正则表达式模式与风险评分数字配对,例如:

// Filter for suspicious HTTP referrer URLs
$wgCustomFiltersRefRules = array(
    '/hackers\.com/' => 100
    '/wikipedia\.org/' => -50,
);
// Filter for suspicious utm_source values
$wgCustomFiltersSrcRules = array(
    '/TestNotice1/' => 50
    '/foobar/' => -100,
);

定义全局在LocalSettings.php

虽然还有更多的全局变量可供覆盖,但如果您希望DonationInterface实际工作,则可能需要在LocalSettings中定义以下内容。

全局变量定义在DonationInterface.php中。

TODO: update

全域名称 用途 类型
$wgGlobalCollectGatewayMerchantID 我们的GlobalCollect商户ID 字符串
$wgDonationInterfaceAllowedHtmlForms 允许通过RapidHtml加载的表单的全局白名单。 用于任何网关。 注意:这实际上并没有在任何地方直接使用。 必须将这些值添加到网关的AllowedHtmlForms中,才能在任何给定的网关上实际使用这些值。 数组。 对于每个表单,键应该是表单的名称(也称为“ffname”),值应该是文件的位置。
$wgGlobalCollectGatewayAllowedHtmlForms GlobalCollect允许通过RapidHtml加载的最终表单白名单。 数组。 对于每个表单,键应该是表单的名称(也称为“ffname”),值应该是文件的位置。 注意:如果您也想使用表单的全局列表,则在本地添加(或删除)表单之前,必须手动设置$wgGlobalCollectGatewayAllowedHtmlForms = $wgDonationInterfaceAllowedHtmlForms。
$wgDonationInterfaceDisplayDebug 设置为true可将额外的调试信息转储到屏幕上。 布尔值

实现

代码

一般来说,完成捐赠的过程是这样的:

  • 捐赠者被发送到一个已经绑定到特定支付网关的捐赠表格中。 此表单将由GatewayForm类派生的类的特定于网关的未列出特殊页面控制。
  • 扩展的GatewayForm类将实例化其网关适配器。 在构造时,网关适配器将收集、规范化并验证$wgRequest中的任何相关数据。 所有网关都使用相同的类DonationData来完成此任务。 这样做意味着所有数据都要经过相同的规范化和验证过程,无论是谁要求数据或数据来自哪里。
  • 然后,控制GatewayForm子类将使用网关适配器来确定用户在捐赠过程中的位置,如果合适(验证时没有错误,存在所有数据,对编辑令牌或会话没有陌生感,诸如此类),则使用同一网关适配器与远程支付服务器进行交互,以便在捐赠流程中采取下一步行动。 由于每个支付网关都有自己的一组规则(在某些情况下,完全不同的交易类型与任何其他网关中的任何其他交易类型都不直接相似),因此由适配器在内部对所有这些进行分类,并且只以在所有可能的适配器对象中或多或少通用的方式向控制对象公开功能。
  • 在让网关适配器与远程支付网关执行一个或多个交易之后,控制对象将使用网关来确定发生了什么,并向潜在的捐赠者显示适当的结果。 这可能是一个“谢谢”页面,一个显示在提交的表单上的错误,提示用户以有意义的方式重试,或者是一个更致命的错误页面。

GatewayAdapter 类

(DonationInterface/gateway_common/gateway.adapter.php) - 这是一个抽象类,负责处理一般网关需要执行的所有操作。 如果你没有定义网关需要的任何细节,它也应该大声地对你大喊大叫,以便能够做任何有价值的事情。

GatewayForm

(DonationInterface/gateway_common/GatewayForm.php)- 一个扩展UnlistedSpecialPage的类。 这将处理向用户提交捐赠表格并获得结果所需的所有非网关特定功能。 特别令人感兴趣的是显示(或不显示)请求的表格、处理表格验证的一些更通用的方面以及获取指定表格可以使用的数据的机制(如国家下拉列表中的国家及其代码)。

从中继承的类将特定于特定的支付网关。 因此,它们将位于一个名为DonationInterface/[name]_gateway/的文件夹中。

大多数适配器将为两个路由实现GatewayForm:初始支付表单和结果切换页面。

初始付款表格负责提供一份表格,其中包含要收集的强制性数据的输入。 或者,一些网关(如GlobalCollect)将呈现由支付处理程序托管的iframed表单,而其他网关(如PayPal和亚马逊)将透明地重定向到处理程序,除非捐赠信息(货币和金额)无效且必须更正。

结果切换程序通常不负责确认付款或执行进一步授权,它只是根据处理程序的大致响应将捐赠者发送到“谢谢”或“失败”页面。

DonationData 类

(DonationInterface/gateway_common/DonationData.php)-这个类旨在处理我们可能想要使用DonationData进行的所有操作。 它应该以一致的方式从任何适当的来源加载数据(包括测试),保存相关的贡献跟踪数据,生成我们始终需要生成的数据(如订单ID),规范化所有内容,并将其交回网关。 从GatewayAdapter继承的类将在创建时实例化DonationData类。 GatewayAdapter子类应该只使用通过DonationData类的数据。 它还处理编辑令牌。

DataValidator

所有数据首先通过DonationData进行标准化,然后进行验证。 如果数据未通过验证,则所有处理都将暂停,并将捐赠者重定向回他们可以更正任何错误的表单。 显示消息以指导用户完成更正。 TODO:使消息可读,附加到字段而不是弹出窗口,等等。

其中一些验证会咨询网关适配器,例如有效捐赠金额的下限和上限以及接受的货币。

构造网关适配器

 
最初构造网关适配器时会发生什么的快速图像

定义新的网关适配器

GatewayAdapter扩展了GatewayType接口。 TODO:以下是在GatewayType中定义函数的快速指南。

测试

单元测试可以在DonationInterface扩展的测试目录中找到。

要运行单元测试,请转到mediawiki核心目录,然后在tests/phpunit下:

cd /srv/org.wikimedia.payments
composer phpuninit:entrypoint -- --group DonationInterface

开发

Composer

每当composer.json更改时,必须运行composer update --no-dev来刷新vendor/的内容。

对于WMF生产,供应商作为git子模块部署在“部署”分支上。 提交新包时,必须对包“.git”目录进行$编码,否则它们将被视为畸形的嵌套子模块,您不想去那里。

路线图

我们想做的一些事情:

  • 将表示层与控制器和支付后端解耦 (  完成)
    • 杀死RapidHTML并使用主流模板引擎 (  完成)
    • 将表单合并为一个通用表单,使用布尔参数控制块可见性和可用功能: (  完成)
  • 将支付处理与MediaWiki框架分离,因此它可以用作独立的库 (  进行中)
    • 提供对Drupal内部支付库的访问,以实现CivicCRM的退款、取消和状态检索 (  进行中)
此扩展部署在Wikimedia Foundation的支付集群上,而不是主wiki集群上,因此它不会出现在config中。