rf1705/omnipay-payone

用于Omnipay PHP支付处理库的PAYONE网关驱动程序

3.0.2 2022-03-21 07:37 UTC

README

GitHub license Packagist GitHub issues Build Status

目录

Omnipay: PAYONE

PAYONE PHP支付处理库的驱动程序

按照规范编写

  • PAYONE平台渠道客户端API技术参考 1.28 (2016-05-09)
  • PAYONE平台渠道服务器API技术参考 2.84 (2016-05-09)
  • PAYONE平台前端技术参考 2.40 (2016-05-09)

Omnipay 3.x 是一个与框架无关、多网关支付处理库,适用于PHP 7.1+。本包实现了OmniPay对OmniPay的支持。

Alt text

安装

这是当前Omnipay 3.x分支的master分支(针对3.0-beta.1进行了测试)。 旧的2.x分支可以在此处找到

Omnipay通过Composer进行安装。要安装,请将其添加到您的composer.json文件中

{
    "require": {
        "academe/omnipay-payone": "~3.0"
    }
}

或直接从packagist

composer require "academe/omnipay-payone: ~3.0"

然后运行composer来更新您的依赖项

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

基本用法

此包提供了以下网关

  • Payone_ShopServer
  • Payone_ShopFrontend
  • Payone_ShopClient

有关一般使用说明,请参阅主Omnipay存储库。更具体的详细信息可以在下面找到。

网关背景

PAYONE API有三个对电子商务感兴趣的接入点

  • 服务器API - 用于直接与服务器交互,无需用户干预。
  • 前端API - 用于向用户交付托管信用卡(CC)表单(iframe或重定向)。
  • 客户端API - 用于与JavaScript前端交互。

服务器API主要用于捕获授权的支付,前端用于设置信用卡表单。客户端用于支持浏览器的AJAX。您还可以使用服务器API进行授权和支付,只要您完全了解PCI的影响。

服务器API还有一个用于接收来自PAYONE服务器的支付结果和捕获的用户信息的通知处理器。

您很可能会使用服务器、前端和客户端函数的组合,因为它们可以相互补充。

商店和访问API版本

PAYONE上设置了一个支付门户,作为两个版本之一

  • 商店
  • 访问

《Shop》门户版本用于一次性支付。《Access》门户版本用于订阅、开票、连续续订和服务。一些支付方式仅适用于《Shop》版本,而另一些仅适用于《Access》版本。某些方法适用于两个版本,但参数集略有不同。

目前,此包仅处理《Shop》版本。然而,类和服务的命名允许在需要时添加《Access》版本的方法。

扩展项(订单行)

PAYONE API 支持两个额外的购物车项属性,必须填写(idvat)。由于核心 OmniPay v2 Item 对象无法接受自定义属性值,因此进行了扩展。扩展的 Item 类可以在以下位置找到

\Omnipay\Payone\Extend\Item

创建 Item 使用这些字段

$lines[] = new \Omnipay\Payone\Extend\Item([
    'id' => '{merchant-site-stock-ID}',
    'name' => '{product-name}',
    'quantity' => 2,
    'price' => 123,
    'vat' => 20, // Optional
    // Used but optional for clearingType = \Omnipay\Payone\AbstractShopGateway::CLEARING_TYPE_WLT
    // and walletType = \Omnipay\Payone\AbstractShopGateway::WALLET_TYPE_PPE
    'itemType' => \Omnipay\Payone\Extend\ItemInterface::ITEM_TYPE_GOODS,
]);

price 可以以 次要货币单位主要货币单位 提供。以下 Item 价格在美元或欧元(两位小数的货币)中是等效的

  • 123
  • 1.23
  • "123"
  • "1.23"

vat 值是增值税率,以百分比(%)或以 基点(‱)表示。规则如下

  • 任何小于等于 99 的整数将被解释为百分比。
  • 任何在 100 到 9999 之间的整数将被解释为基点。

然后将这些项目作为对象的数组以正常方式添加到 ItemBag

$items = new \Omnipay\Common\ItemBag($lines);

当通过信用卡结算时,ItemBag 的总价似乎不需要与订单总价相匹配,但对于《Shop Server API》方法,它必须与订单总价相匹配。但是,当使用 CLEARING_TYPE_WLT 结算类型时,它必须正确匹配。

如果您不使用扩展的 Item,则将使用默认值替换("000000" 用于 idnull 用于 vat 图形)。如果您为《Shop Frontend》方法不提供任何项目,则将自动创建一个包含全额的默认项目。《Shop Frontend》必须有一个包含至少一个项目的篮子,这就是为什么此驱动程序会在您不提供篮子时创建默认项目。

商店服务器API网关

创建一个网关对象以访问服务器 API 《Shop》版本的方法

$gateway = Omnipay\Omnipay::create('Payone_ShopServer');

// Merchant Account ID
$gateway->setMerchantId(12345);
// Merchant Portal ID
$gateway->setPortalId(1234567);
// Sub-Account ID
$gateway->setSubAccountId(56789);
// True to use test mode.
$gateway->setTestMode(true);
// Default language is "en" and determines the language of forms and error messages.
$gateway->setLanguage("de");
// Currency as ISO 4217 three-character code
$gateway->setCurrency('EUR');

服务器API授权支付

PAYONE 将此称为“预授权”。它授权稍后捕获付款。

要创建授权请求

$request = $gateway->authorize([
    // Unique merchant site transaction ID
    'transactionId' => 'ABC123',
    // Amount as decimal.
    'amount' => 0.00,
    // Pre-shared secret key used for hashing and authentication.
    'portalKey' => 'Ab12Cd34Ef56Gh78',
    // Card and personal details.
    'card' => $card,
    // Optional card type override.
    //'cardType' => 'V',
    // The ItemBag/Cart
    'items' => $items,
    // Optional ecommerce mode declares risk
    'ecommerceMode' => '3dsecure',
]);

驱动程序将尝试从卡号中确定卡类型,但如果不成功或您正在使用驱动程序或 OmniPay 尚未支持的卡类型,则可以提供自己的卡类型字母。

$card 的详细信息与其他标准 OmniPay 卡一样填充,但有以下一个例外。您可以将其作为数组或作为 \Omnipay\Common\CreditCard 对象提供。

ecommerceMode 覆盖了在门户中设置的 3D Secure 配置。值包括 internet 以关闭 3D Secure,3dsecure 以打开 3D Secure,以及 moto 用于电话和电子邮件支付。注意:在捕获授权付款时,必须使用 相同的 ecommerceMode,否则捕获将被拒绝。但是,由于 PAYONE 在其自己的网站上包装银行的 3D Secure 表单,因此它不提供任何额外的 POST 数据发送。

这四个字段通常定义了信用卡的详细信息

[
    ...
    'number' => '4111111111111111',
    'expiryYear' => '2020',
    'expiryMonth' => '12',
    'cvv' => '123',
];

PAYONE 还接受“伪卡”号码。这是由另一个进程(例如,“信用卡检查”)提供的临时令牌,用于代替卡。如果提供伪卡号码,则将剩余的卡字段留空或为 null。网关驱动程序将然后将卡号视为伪卡

[
    ...
    // A pseudo-card number.
    'number' => '4111111111111111',
    // Other card details left as null.
    'expiryYear' => null,
    'expiryMonth' => null,
    'cvv' => null,
];

强烈建议仅通过 Server API 通道处理伪卡号码,以减少潜在的 PCI DSS 问题。伪卡号码应通过使用“hosted iFrame”功能的 Client API 通道获取。

关于卡片数据,需要注意的是,国家必须以ISO 3166两位字母代码提供

    'billingCountry' => 'US',

州必须以ISO 3166-2子分区代码提供(根据国家,格式各不相同)

    'billingCountry' => 'US',
    'billingState' => 'AL',

返回URL和取消URL(在使用3D Secure时)通常在账户设置中设置,但可以在此覆盖

    // Return URL on successful authorisation.
    'returnUrl' => '...',
    // Return URL on failure to authorise the payment.
    'errorUrl' => '...',
    // Return URL if the user choses to cancel the authorisation.
    'cancelUrl' => '...',

将此请求发送给PAYONE以获取响应

$response = $request->send();

标准的OmniPay文档展示了如何处理响应。此外,在发生错误的情况下,将会有正常的可记录的错误消息,以及一个安全地放在最终用户面前的单独错误消息

if (!$response->isSuccessful()) {
    echo $response->getMessage();
    // e.g. "Expiry date invalid, incorrect or in the past"
    echo $response->getCustomerMessage();
    // e.g. "Invalid card expiry date. Please verify your card data."
}

服务器API购买

PAYONE将其称为“授权”。它立即授权和捕获支付。

它以与authorize相同的方式使用和响应。请求消息是这样创建的

$request = $gateway->purchase([...]);

服务器API捕获

一旦支付被授权,它就可以被捕获。这是通过这个最小消息完成的

$request = $gateway->capture([
    // The reference for the original authorize transaction.
    'transactionReference' => '123456789',
    // Amount as decimal.
    'amount' => 1.23,
    // Pre-shared secret key used for authentication, if not already set on $gateway.
    'portalKey' => 'Ab12Cd34Ef56Gh78',
]);

这将捕获指定的金额并结算账户。如果您想将账户保持开放以分阶段捕获总额,则指定账户保持未结算

    'sequenceNumber' => $sequence,
    'settleAccount' => false,

序列号从第一次捕获的1开始,并且必须为每次后续捕获递增。它应从通知回调中获取,见下文。

对于发票模块,必须提供一些附加参数

$lines[] = new \Omnipay\Payone\Extend\Item([
    'id' => '{merchant-site-stock-ID}',
    'name' => '{product-name}',
    'itemType' => 'goods', // Available types: goods, shipping etc.
    'quantity' => 2,
    'price' => 123,
    'vat' => 20, // Optional
]);

$items = new ItemBag($lines);

并在捕获请求中

    'items' => $items,
    'sequenceNumber' => 1,
    'settleAccount' => false,
    'invoiceid' => 1,
    'invoiceDeliveryMode' => 'P', // PDF, for others look into documentation
    'invoiceDeliveryDate' => date('Ymd'),
    'invoiceAppendix' => 'This is your invoice appendix'

请注意,卡片详细信息中的电子邮件字段必须在预授权步骤中将授权方法传递,因为这是Payone将用于向客户发送发票的电子邮件。

服务器API取消

要取消授权支付

$request = $gateway->void([
    // The reference for the original authorize transaction.
    'transactionReference' => '123456789',
    // Amount as decimal.
    'amount' => 1.23,
    // Pre-shared secret key used for authentication, if not already set on $gateway.
    'portalKey' => 'Ab12Cd34Ef56Gh78',
]);
$response = $request->send();

当发送到PAYONE时,void方法将以ShopCaptureResponse响应。

服务器API信用卡检查

此方法将检查信用卡的详细信息是否合理,并且可选地将卡片详细信息标记化以供其他方法使用。信用卡检查方法适用于服务器直接请求,也适用于客户端的AJAX调用。

请求是这样设置的

$gateway = Omnipay\Omnipay::create('Payone_ShopServer');
$gateway->setSubAccountId(12345);
$gateway->setTestMode(true); // Or false for production.
$gateway->setMerchantId(67890);
$gateway->setPortalId(3456789);
$gateway->setPortalKey('Ab12Cd34Ef56Gh78');

$request = $gateway->creditCardCheck([
    'card' => [
        'number' => '4012001037141112',
        'expiryYear' => '2020',
        'expiryMonth' => '12',
        'cvv' => '123',
    ],
    'storeCard' => true,
]);

$response = $request->send();

如果信用卡详细信息是合理的,则响应将成功

$response->isSuccessful();
// true

如果响应不成功,则详细信息将在getCode()getMessage()getCustomerMessage()中可用。

如果响应成功且storeCardTRUE,则将提供两个额外的数据项

// The tokenised card:
$token = $response->getToken();
// e.g. 4100000227987220

// The truncated card number:
$response->getCardNumber()
// e.g. 401200XXXXXX1112

在任何需要信用卡详细信息的API中,您可以用令牌替换详细信息,例如

$request = $gateway->authorize([
    'card' => [
        'number' => $token
    ],
    ...

通常令牌将来自Web客户端(浏览器中的AJAX),但此服务器API可以在开发和测试期间与测试卡一起使用。

商店前端API网关

前端网关支持托管支付表单,可以接受仅信用卡或银行详情,或完整的个人详情。这些表单托管在PAYONE网站上,可以进行定制,并且可以是iframe中的最终用户呈现,或者最终用户可以完全重定向到远程表单。

// Set up the Front End gateway.
$gateway = Omnipay\Omnipay::create('Payone_ShopFrontend');

前端授权

前端API方法封装在一个单独的网关类中

$gateway = Omnipay\Omnipay::create('Payone_ShopFrontend');

// Merchant Portal ID
$gateway->setPortalId(1234567);
// Sub-Account ID
$gateway->setSubAccountId(56789);
// True to use test mode.
$gateway->setTestMode(true);
// Default language is "en" and determines the language of forms and error messages.
$gateway->setLanguage("de");
// Currency as ISO 4217 three-character code
$gateway->setCurrency('EUR');
// The pre-shared secret, used for hashing.
$gateway->setPortalKey('Ab12Cd34Ef56Gh78');
// The default for this gateway is HASH_MD5 for legacy applications, but the hash
// method recommended by PAYONE is HASH_SHA2_384,
$gateway->setHashMethod($gateway::HASH_SHA2_384);

发送授权涉及设置请求消息

$transactionId = {merchant-site-transaction-ID}

$request = $gateway->authorize([
    'transactionId' => $transactionId,
    'amount' => 3.99,
    'accessMethod' => 'iframe',
    'redirectMethod' => 'POST',
    'items' => $items,
    'card' => [
        'firstName' => 'Firstname',
        'billingAddress1' => 'Street Name',
        ...
    ],
    // Any of these optional URLs can override those set in the account settings:
    'returnUrl' => '...',
    'errorUrl' => '...',
    'cancelUrl' => '...',
]);

accessMethod将是"classic""iframe";默认为ShopFrontendAuthorizeRequest::ACCESS_METHOD_CLASSICredirectMethod将是"GET""POST";默认为ShopFrontendAuthorizeRequest::REDIRECT_METHOD_GET

items是可选的,但如果您不提供至少一个项目,则会为您创建一个默认项目;前端API强制要求购物车,与服务器API不同。

可以用来预先填充支付表单的card账单详情。如果个人详细信息已检查并且已知有效(另一个API可以做到这一点),则可以使用'showName' => false'showAddress' => false将姓名和地址字段在支付表单上隐藏。

请注意,可能无法覆盖上述URL。只有在账户设置中没有定义的情况下,才能设置这些URL。关于这一点,文档并不完全明确。

执行下一步操作时,OmniPay的响应消息是

$response = $request->send();

响应将是一个重定向响应,根据redirectMethod参数,是GET或POST。

您可以在您的应用程序中检索GET URL并进行重定向,或者让OmniPay执行重定向。

// Get the URL.
$url = $response->getRedirectUrl();

// Just do the redirect using the methods in OmniPay core.
$response->redirect();

对于POST重定向方法,同样,您可以仅让OmniPay进行重定向,但您可能想要构建自己的表单,并在页面的iframe中target它。构建表单需要的是目标URL和表单项。表单项以name/value对的形式提供。

// This form needs JavaScript to auto-submit on page load.
echo '<form action="' . $response->getRedirectUrl() . '" method="POST" target="target-iframe">';
foreach($response->getRedirectData() as $name => $value) {
    echo '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
}
echo '</form>';

// The autp-submitted form, tagetting at this iframe, will generate the
// remote credit card payment form within this iframe.
echo '<iframe name="target-iframe" width="400" height="650"></iframe>';

从远程网关返回时,如果使用iframe,您需要跳出iframe才能到达您的商家网站中的最终页面。PAYONE API确实内置了iframe破坏功能。在您的授权请求上设置setTargetWindow()以告诉网关将用户带到哪里。接受值在ShopFrontendAuthorizeRequest::TARGET_WINDOW_*中给出。

请注意,此驱动程序不会尝试生成HTML表单。它将提供数据供您创建自己的HTML表单。

用户在PAYONE网站上完成详细信息后,将向您的商家网站发送结果通知,然后用户将被返回到“成功”页面或“失败”页面。该重定向不会携带任何数据,因此必须在会话中保留交易详情以与回传通道中的结果匹配。

前端购买

与前端授权功能相同,但将需要单独的Server API捕获。

前端信用卡检查

以与客户端API信用卡检查相同的方式设置此内容。然后,使用响应生成您将用于配置用于标记卡表单的数据。

$jsonForJavaScript = json_encode($request->send()->getData());

设置卡标记化表单和JavaScript来处理它,超出了本指南的范围。官方文档提供了很好的示例。只需用$jsonForJavaScript的内容替换示例请求配置数据。

商店客户端API网关

Shop Client网关通过客户端AJAX调用或在商家网站上直接POST到PAYONE网关的表单来处理支付。

// Set up the Client gateway.
$gateway = Omnipay\Omnipay::create('Payone_ShopClient');

客户端API信用卡检查

这与服务器API信用卡检查类似,并且以类似的方式设置。但是,不会传递任何信用卡详情,因为这是在客户端处理的。

$gateway = Omnipay\Omnipay::create('Payone_ShopClient');
$gateway->setSubAccountId(12345);
$gateway->setTestMode(true); // Or false for production.
$gateway->setMerchantId(67890);
$gateway->setPortalId(3456789);
$gateway->setPortalKey('Ab12Cd34Ef56Gh78');
$gateway->setHashMethod($gateway::HASH_SHA2_384);

$request = $gateway->creditCardCheck();
$response = $request->send();

它为此提供了以下数据,以供您的客户端使用

// The endpoint used to check the card details - GET or POST can be used.
$endpoint = $response->getRedirectUrl();

// The additional data that must be included with the card data.
// This will be an array that can be JSON encoded for the client JavaScript to use:
$data = $response->getRedirectData();

然后在客户端,您需要在非提交表单中提供信用卡字段(没有name属性的表单项)

  • cardpan - 信用卡号码
  • cardexpiredate - YYMM
  • cardtype - 例如,V代表Visa
  • cardcvc2
  • cardissuenumber - 仅限英国Maestro

这些值将由您的客户端代码构建,然后提交到端点。例如,cardexpiredate可能是两个下拉列表的连接。cardtype可以是下拉列表,或者客户端库可以通过匹配卡号模式自动设置它。

结果将是类似于这样的JSON响应

{
    "status" : "VALID",
    "pseudocardpan" : "4100000228091881",
    "truncatedcardpan" : "401200XXXXXX1112",
    "cardtype" : "V",
    "cardexpiredate" : "2012"
}

处理这些数据超出了OmniPay的范围,但这里最重要的值是pseudocardpan,可以用作任何服务器API调用的占位符,而不是真实的信用卡号码(例如,商店服务器授权方法)。

官方PAYONE文档进一步解释了其工作原理,并提供了客户端代码片段的示例。

建议使用“托管iframe”模式来捕获信用卡数据。这超出了OmniPay的范围,并在这里有更详细的描述。

客户端API授权

客户端授权操作有两种主要模式

  • 重定向 - 用户直接将POST请求发送到PAYONE网关,如果需要,在该处输入3D Secure详细信息,然后返回到您的网站。
  • JSON - 在请求授权期间,用户最初停留在您的网站上,通过AJAX请求授权。客户端可以将用户发送到PAYONE输入3D Secure密码,如果需要,但如果不需要,则可以直接将结果发布到商家网站,而无需用户离开。

REDIRECT模式支持在商家网站上构建完整的支付表单,该表单直接POST到PAYONE网关。授权的结果将由PAYONE POST到通知处理器。当用户在没有使用3D Secure的情况下返回时,网关还将向商家网站返回成功状态。需要注意的是,如果使用3D Secure,并且最终用户被重定向以输入他们的3D Secure密码,则他们将返回到您的网站的成功/失败/取消URL,且没有数据,因此商家网站必须在会话中保存足够的信息以通过Notification回传处理器接收授权结果。

AJAX模式设置方式相同,但所有详细信息都是通过AJAX而不是标准浏览器表单POST。结果将以JSON响应返回,可能包括3D Secure重定向,或者可能只包含授权结果。

设置消息的方式与其它方法类似。对于REDIRECT和JSON响应类型都是如此。

$gateway = Omnipay\Omnipay::create('Payone_ShopClient');
$gateway->setSubAccountId(12345);
$gateway->setTestMode(true); // Or false for production.
$gateway->setMerchantId(67890);
$gateway->setPortalId(3456789);
$gateway->setPortalKey('Ab12Cd34Ef56Gh78');
// The default for this gateway is HASH_MD5 for legacy applications, but the hash
// method recommended gby PAYONE is HASH_SHA2_384,
$gateway->setHashMethod($gateway::HASH_SHA2_384);
// Set up the response type - redirect the user or do an AJAX call.
$gateway->setResponseType($gateway::RETURN_TYPE_REDIRECT);
//$gateway->setResponseType($gateway::RETURN_TYPE_JSON);

$request = $gateway->authorize([
    'transactionId' => $transactionId, // Merchant site ID (or a nonce for it)
    'amount' => 9.99, // Major units
    'currency' => 'EUR',
    '3dSecure' => false, // or true
    'items' => $items, // Array or ItemBag of Items or Exten\Items
    // Where to send the user in authorisation suucess or falure.
    'returnUrl' => $returnUrl,
    'errorUrl' => $errorUrl,
    // Where to send the user on cancellation in 3D Secure form.
    'cancelUrl' => $cancelUrl,
]);
$response = $request->send();

$response现在包含了客户端直接POST表单的隐藏字段或AJAX调用所需的详细信息。这些详细信息包括:

// Array of name/value pairs
$params = $response->getRedirectData();

// The destination endpoint.
$endpoint = $response->getRedirectUrl();

除了$params外,您还需要包括以下由最终用户提供的资料:

  • 姓 - 必须填写
  • 国家 - ISO3166,例如GB
  • 卡号
  • 卡有效期 YYMM
  • 卡类型 - 例如V
  • cardcvc2
  • 卡发行号码 - 仅限英国Maestro
  • 持卡人 - 可选

如果您的redirectMethod是REDIRECT,那么所有这些信息都将放入一个用户提交的表单中。该表单将直接POST到PAYONE。接下来会发生什么将取决于是否已启用3D Secure并且该卡是否可用。

  • 如果3D Secure可用,PAYONE将向最终用户提供一个3D Secure密码表单。然后用户将无结果地返回到网站。结果将发送到Notification处理器,商家网站必须使用商家网站的transactionId获取这些结果。
  • 如果3D Secure不可用,则卡将被验证,用户将带有结果返回到商家网站。结果不能完全信任,因为它未签名,但在流程中可能很有用。结果可以使用completeAuthorize消息(见下文)捕获。

如果您的responseType是JSON(ShopClientGateway::RETURN_TYPE_REDIRECT),则商家网站客户端页面应使用AJAX发布数据。返回将是详细说明结果的JSON消息,这可能是一个成功、失败或3D Secure的重定向。处理该响应超出了OmniPay的范畴,但PAYONE文档提供了一些示例和一些有用的脚本。

客户端完成授权

这可以用来解析来自服务器请求的数据(即用户带回来的数据)。

$gateway = Omnipay\Omnipay::create('Payone_ShopClient');

$server_request = $gateway->completeAuthorize();
$server_response = $server_request->send();

$server_response可以提供一些标准化的项目。

// The raw data
$server_response->getData();

// The authorisation success state:
$server_response->isSuccessful();

// The redirect status and URL (we would not expect to see this for a REDIRECT response
// type as the redirect has already been processed on the client side:
$server_response->isRedirect();
$server_response->getRedirectUrl()

// If there are errors, then there will be a system message and a user-safe message:
$server_response->getMessage();
$server_response->getCustomerMessage();

客户端API购买

这与客户端API授权的工作方式相同,但使用的是purchase方法。

您仍会使用completeAuthorize与购买API。

通知回调

对于大多数交易(如果不是所有交易),PAYONE都将发送交易详情到您的通知URL。此URL在PAYONE账户配置中指定。对于大多数服务器API方法,这是一个方便功能。对于前端方法,这是必要的,因为这是获取交易已完成通知的唯一方式。

通知来自IP地址185.60.20.0/24(185.60.20.1到185.60.20.254)。此驱动程序不尝试验证此点。

您的应用程序必须在十秒内响应该通知,因为当使用托管在前端的形式时,用户将等待在PAYONE网站上的确认 - 只需将数据保存到存储中并结束。

通知服务器请求(即对您的服务器的传入请求)由使用标准OmniPay acceptNotification()网关方法创建的completeStatus类捕获/处理。

$gateway = Omnipay\Omnipay::create('Payone_ShopServer');

// The portal key must be provided.
// This will be used to verify the hash sent with the transaction status notification.
// PAYONE will send an MD5 hash at all times. This is subject to change and will support
// the option to use a SHA2-384 hash eventually.
$gateway->setPortalKey('Ab12Cd34Ef56Gh78');

$server_request = $gateway->acceptNotification();

// The raw data sent is available:
$data = $server_request->getData();

// Provides the result of the hash verification.
// If the hash is not verified then the data cannot be trusted.
$server_request->isValid();

只要通知有效,您也可以获取交易的状态。下表列出了此驱动程序将状态和事件(txaction)映射到OmniPay的整体状态值的方法(“-”表示“任何”)

还可以从服务器请求中提取个别数据项(见下表)。

一旦数据保存到本地应用程序,响应远程网关以指示您已收到通知

$server_response = $server_request->send();
// Your application will exit on the next command by default.
// You can prevent that by passiong in `false` as a single parameter, but
// do make sure no further stdout is issued.
$server_response->acknowledge(); // or $server_response->send()

$server_request数据方法列表

  • getPaymentPortalKey() - 根据门户网站账户配置,为MD5或SHA2 384
  • getPaymentPortalId()
  • getSubAccountId()
  • getEvent() - 通知被发送的原因的名称。包括“appointed”、“capture”、“paid”、“underpaid”、“cancelation”、“refund”、“debit”、“reminder”、“vauthorization”、“vsettlement”、“transfer”、“invoice”、“failed”
  • getAccessName()
  • getAccessCode()
  • getTxStatus() - 原始状态代码
  • getTransactionStatus() - OmniPay交易状态代码
  • getTransactionId()
  • getTransactionReference()
  • getNotifyVersion()
  • getParam()
  • getMode() - 测试或实时
  • getSequenceNumber()
  • getClearingType() - 'cc'为信用卡;'wlt'和walletType = 'PPE'为PayPal Express
  • getWalletType() - 'PPE'为PayPal Express
  • getTxTimestamp() - 原始Unix时间戳
  • getTxTime() - 作为\DateTime对象的时间戳
  • getCompany()
  • getCurrency() - ISO三位字母代码
  • getCurrencyObject() - 作为OmniPay Currency对象
  • getDebtorId()
  • getCustomerId()
  • getNumber() - 隐藏中间数字的CC号码,例如“411111xxxxxx1111”
  • getNumberLastFour() - 例如“1111”
  • getCardType() - PAYONE单字母代码,例如“V”、“M”、“D”。
  • getBrand() - OmniPay的卡类型名称,例如“visa”、“mastercard”、“diners”。
  • getExpireDate() - YYMM格式,如提供
  • getExpireDateObject() - 作为\DateTime对象返回的到期日期
  • getCardholder() - 已记录,但大部分时间似乎为空
  • getFirstName()
  • getLastName()
  • getName()
  • getStreet()
  • getAddress1() - getStreet()的别名
  • getCity()
  • getPostcode()
  • getCountry() - ISO代码
  • getShippingFirstName()
  • getShippingLastName()
  • getShippingName()
  • getShippingStreet()
  • getShippingAddress1() - getShippingStreet()的别名
  • getShippingCity()
  • getShippingPostcode()
  • getShippingCountry() - ISO代码
  • getEmail()
  • getPrice() - 主货币单位的小数
  • getPriceInteger() - 次货币单位的小整数
  • getBalance() - 主货币单位的小数
  • getBalanceInteger() - 次货币单位的小整数
  • getReceivable() - 主货币单位的小数
  • getReceivableInteger() - 次货币单位的小整数

completeAuthorize和completePurchase方法

尽管前端购买和授权会将用户带到站点外(全屏模式或iframe),但用户回来时不会返回数据。因此,不需要completeAuthorizecompletePurchase方法。

3D Secure 需要访问授权银行。然而,PAYONE 会将这次访问封装到一个它所托管的页面中(该页面将包含一个iframe)。这意味着,如果需要3D Secure密码,结果仍将通过与任何非3D Secure交易相同的通知URL发送到商家网站。一个优点是,您的商家网站不需要处理来自终端银行的 PAReq/PARes 参数等内容。

参考