Bluem PHP 接口

2.3.3 2024-06-26 10:13 UTC

README

Bluem

Bluem-php 用于支付、指令、iDIN 以及 IBAN-Name 检查

Bluem 服务 ePayments、eMandates、iDIN 和/或 IBAN-Name 检查的 PHP 接口。使用此库编写您自己的 PHP 应用程序,无需自己处理流程。

也被其他应用程序使用

目录

2.4 即将推出

在接下来的 1-2 个月内将发布 PHP 库的新版本。从本版本开始,PHP 8.1 是此库的最低要求版本。

要求

  • 2024年:从我们的发布 >= 2.4 开始,PHP 8.1 是此库的最低要求版本。之前的版本需要 PHP 8.0

  • 2023年4月更新:从我们的发布 >= 2.3 开始,PHP 8.0 是此库的最低要求版本。之前的版本需要 PHP 7.4

  • 请使用此插件的主要 Git 发布版进行稳定版本。

  • 有关其他依赖项,请参阅 composer.json 要求。

入门

通过 Composer 安装库。在项目文件夹中运行 Composer 以安装此库及其依赖项。

composer require bluem-development/bluem-php

有关完整示例实现,请参阅 示例,您可以根据自己的集成进行参考。

如果您对示例或库在项目中的实现有任何问题,请与我们联系。

各版本说明

版本 2.3.2.4(最新版)

  • 已将银行 'N26' 添加到 ePayments BIC 列表。
  • 重构代码以兼容 Magento。

版本 2.3.2.3

更新证书。

版本 2.3.2.2

更新了 BIC 电子支付列表。

版本 2.3.2

将 BIC 添加到指令请求中。

版本 2.3.1

将 BIC 添加到身份请求中。

版本 2.3

添加了对 PHP 8+ 的支持。

版本 2.2

Webhooks 和新的支付方式

  • 添加了显式的 Webhook 功能和相关的文档。
  • 支持 PayPal、信用卡、SOFORT 和 Carte Bancaire。

版本 2.1

代码风格有重大改进。

  • 添加了 $bluem->getConfig($key) 方法以检索配置值。
  • 添加了 $bluem->setConfig($key, $value) 方法来设置配置值。
  • 添加了几个验证步骤。
  • 增加了更多的单元测试覆盖率。
  • 将更多责任分离以使代码更清晰。

2.1 之前的版本

版本 2.0.12

允许利用地理位置集成(IP-API)验证当前 IP 是否位于荷兰。

$bluem->VerifyIPIsNetherlands();
// returns bool true if NL or error, returns false if no error and other country.

此功能可以用于确定是否在任何应用程序中使用 iDIN 身份验证,因为此功能仅支持荷兰银行。

版本 2.0.2

自 2021 年 6 月 1 日起,不再支持 Triodos 银行(BIC TRIONL2U)的标识请求。请参阅:https://www.triodos.nl/veelgestelde-vragen/kan-ik-idin-gebruiken?id=4de127e85eee

  • 如果您使用DebtorWallet 预选银行,您必须更新此库以确保 Triodos 不再是 iDIN 的选项。如果您不这样做,选择 Triodos 的客户将看到错误。

  • 如果您使用 Bluem 门户,您无需采取任何行动。此更改已在 Bluem 门户中应用。

版本 2.0.1

重大版本,具有更高的稳定性、验证和功能。

请注意:主集成类称为 Bluem,因此要包含它,请使用

$bluem = new Bluem($config);

或者使用类别名以确保代码功能。这是自 1.x 版以来的重构。

此外,所有一般可用功能仍然可用。

没有更早的变更日志。请参阅 提交日志 以获取更多信息。

测试

为了改进未来的功能,自 2021 年 11 月以来引入了单元测试。

测试位于 tests 文件夹中。要运行测试

./vendor/bin/phpunit 

测试是在 .env 文件的基础上进行的。请确保有一个填充的 .env 文件可用。提供了一个 .env.example 文件以帮助您配置它。

基础测试描述

  • 测试是否可以创建请求
  • 测试是否可以生成入口代码

常见问题解答

我收到消息 "未授权:检查您的账户凭据"。我该怎么做?
请确保您的 SenderID、BrandID 和测试/或生产环境的令牌设置正确。通常此消息保留为无效配置或未激活的账户。如果您已检查凭据是否正确,但仍收到此消息,请联系您的 Bluem 账户经理。

我能否将身份服务与像 E-Mandates 或 iDEAL 这样的支付服务连接起来,以便用户只被重定向一次?

  • 不行,因为这些都是独立的过程。

配置

如果尚未通过其他依赖项进行,请在您的代码中包含所需的 Composer 自动加载函数。

// get composer dependencies
require_once __DIR__. '/vendor/autoload.php';

// then use the library in the top of your script(s).
use Bluem\BluemPHP\Bluem;

然后您可以获取一个对象以利用以下所有功能。建议将这些建议的配置设置保存到数据库或设置处理程序中,以便用户可以存储它们而不是在代码中。

$config = new Stdclass();

// Fill in the string 'prod', 'test' or 'acc' for production, test or acceptance environment, respectively.
$config->environment = ...
v
// The sender ID, issued by Bluem. Starts with an S, followed by a number.
$config->senderID = ... 

// The access token to communicate with Bluem, for the test environment.
$config->test_accessToken = ... 

// The access token to communicate with Bluem, for the production environment.
$config->production_accessToken = ... 

// the merchant ID (for eMandates), to be found on the contract you have with the bank for receiving direct debit mandates.
$config->merchantID = ...

// The slug of the 'Thank You' page to which should be referred after completing process. If your Order ID is processed in the URL it will be filled in for you.
$config->thanksPage = ...
// Not applicable for IBAN-Name check

// What status would you like to get back for a TEST transaction or status request? Possible values: none, success, cancelled, expired, failure, open, pending
$config->expectedReturnStatus = ...
// Not applicable for IBAN-Name check

// What's your BrandID? Set at Bluem
$config->brandID = ...
// Not applicable for IBAN-Name check

// eMANDATES Specific:
// Brief description of the debt collection
$config->eMandateReason = ...

// Choose collection: CORE or B2B
$config->localInstrumentCode = ...

// URL to return to after finishing the process
$config->merchantReturnURLBase = ...;
// Not applicable for IBAN-Name check

$bluem = new Bluem($config);

如果 Bluem 对象的部分没有正确实例化,实例化可能会抛出异常。

总体概念

这个库使得与Bluem的服务(电子支付、电子授权、iDIN和IBAN-Name检查)进行通信变得简单。每个服务的流程相似,因此一旦理解并实现其中一个,理解其他服务就会变得容易。

  1. TransactionRequest(从网站到Bluem):您的应用程序创建一个请求对象,并通过认证将其发送到Bluem服务器。
  2. TransactionResponse(包括TransactionURL)(从Bluem到网站):如果请求成功,您的应用程序将接收到一个包含URL的响应,该URL是进入Bluem环境的入口点。
  3. Bluem环境:将客户端重定向到TransactionURL,客户端(通过结账)到银行,确认交易,然后通过MerchantReturnURL(带有eMandates)或通过DebtorReturnURL(带有支付/身份验证)返回到商家,这是StatusRequest的触发器。用户被重定向到Bluem服务器上的响应URL。在这个Bluem环境中,用户执行支付/授权签署或身份/iDIN检查,然后返回到预定义的URL。
  4. StatusRequest(从网站到Bluem):使用这个相同的包,可以检查请求的状态,使用第二个端点(给定请求创建时定义的交易ID和entranceCode)。这对于更改订单或检查的状态至关重要,因为这些状态是根据从Bluem获取的交易状态进行的。建议在用户在Bluem处理交易后直接返回到您的网站/应用程序时进行此检查,并且使用webhook功能。
  5. StatusUpdate(从Bluem到网站):这个响应对象来自回调或webhook,包含一个更新的状态,您可以在您的应用程序中处理它。例如:当用户付款或验证后,您需要更改产品、订单或流程的状态,并进入下一步。
  6. Webhook:webhook功能允许Bluem直接且安全地将状态更改和交易结果推送到您的网站或应用程序。因此,无论用户在访问Bluem交易页面后做什么,您的订单和交易都会更新到相应的状态。

Webhook仅适用于电子支付和电子授权:对于需要在交易成功确认后直接了解状态的在线商店/门户网站。对于iDIN不需要webhook,因为iDIN客户端在成功识别后始终返回到网站。请参阅Webhook部分以获取实施说明。

请注意,IBAN-Name检查的流程更短:执行TransactionRequest。结果作为TransactionResponse返回。这是因为最终用户不需要;直接调用银行数据库,在TransactionResponse中提供IBAN-Name检查结果。

使用debtorWallet预先选择支付请求的银行

注意:这与基于银行的交易和服务相关

您可以在自己的应用程序中预先选择银行进行支付,基于创建授权、支付或身份请求时的IssuerID(BIC/Swift代码)。如果想在您的用户界面中选择给定的银行并跳过Bluem门户界面中的银行选择,可以使用此功能。这可以通过在请求对象上利用PHP库的预选择功能在您的应用程序和界面中执行银行选择来实现。

$BIC = "INGBNL2A";
$request->selectDebtorWallet($BIC);

参数必须是受支持银行的有效的BIC代码。无效的BIC代码将触发异常。请注意,支持的BIC代码因服务而异,因为并非每家银行都提供相同的服务!每个服务的支持的BIC代码也可以从Bluem对象中请求,给定服务上下文。作为本文件附录,您可以找到每个上下文的全部BIC列表。

这里说明了可以以编程方式检索每个上下文的BIC列表。

$MandatesBICs = $bluem->retrieveBICsForContext("Mandates"); // also specific to localInstrumentCode, see notes.
$PaymentsBICs = $bluem->retrieveBICsForContext("Payments");
$IdentityBICs = $bluem->retrieveBICsForContext("Identity");

不同上下文输入将触发异常。如果有效,结果将是一个包含具有IssuerIDIssuerName属性的Bluem\BluemPHP\BIC对象的数组:分别是BIC和银行名称。您可以使用它来填充您的用户界面。

请注意,当配置不同的localInstrumentCode时,BIC列表会有所不同。《CORE》和《B2B》localInstrumentCode被不同银行支持。根据您的配置,正确的BIC列表将自动从上下文中加载并用于验证债务钱包。

此方法可用于创建iDIN和创建iDEAL请求;您可以将选定的银行(“发行者”)存储在用户级别,并在创建针对您用户的请求时使用它。

  • 您可以在自己的网站/应用程序中向用户说明为什么这是必要的,并引用新的法律和规则,或者参考新闻/公开声明。
  • 您可以向用户说明所需的麻烦程度:显示一条文本说明,只需一分钟左右,并且它将存储以便于您使用:这确保了完整性,并提供了有效的网店体验。

使用不同的支付交易方法

重要提示:请确保您已为特定的支付方法设置了正确的BrandID。请咨询您的账户经理以获取每种支付方法的特定BrandID列表。

您可以在发送请求之前在请求对象中选择这些选项以允许PayPal和信用卡支付方式。

要使用iDeal(默认选项),可以提供BIC。如果留空,则将在Bluem门户中发生银行选择。

$BIC = 'INGBNL2A';
$request = $request->setPaymentMethodToIDEAL($BIC); 

要使用PayPal,请提供PayPal账户电子邮件地址。电子邮件地址也不必提供。

$payPalAccount = 'john.doe@gmail.com';
$request = $request->setPaymentMethodToPayPal($payPalAccount); 

要使用信用卡,您可以按如下方式设置信用卡详情(不要求)

$request = $request->setPaymentMethodToCreditCard();

$cardNumber = '1234000012340000';
$name = 'John Doe';
$securityCode = 123;
$expirationDateMonth = 11;
$expirationDateYear = 2025;

$request = $request->setPaymentMethodToCreditCard(
    $cardNumber,
    $name,
    $securityCode,
    $expirationDateMonth,
    $expirationDateYear
); 

要使用Sofort,请使用以下方法

$request = $request->setPaymentMethodToSofort(); 

要使用Carte Bancaire,请使用以下方法

$request = $request->setPaymentMethodToCarteBancaire(); 

如果缺少必要信息,这些方法将抛出异常。

请求执行后,交易链接将带您前往具有相应界面和流程的Bluem门户。

Webhooks

Payments、eMandates和Identity存在Webhooks。它们在请求Bluem流程期间触发,并将数据发送到您的应用程序。它们对于确保所有流程始终完成至关重要,即使客户/用户未到达您流程中的常规回调方法。

通过为测试和生产环境创建端点来激活端点。然后需要在Bluem侧进行配置,并在客户端进行实现。

1. 实现方法

为TEST和生产环境创建一个可HTTP访问的端点。例如:

在该端点中调用Webhook()函数

$bluem_object->setConfig("webhookDebug", false);
$webhook = $bluem_object->Webhook();

// implement this like you implemented the callback
// for the regular services in your application.
if ($webhook !== null) {     
    if ($webhook->getStatus() === "Success") {
        // deal with the successful callback
    }
    // elseif (...) {...etc
}

有关更深入的示例实现和接收应用程序中的Webhook数据的示例,请参阅examples/payments-webhook.php

您可以在回调对象上使用以下函数从Webhook获取数据并处理相关数据。

注意:大多数函数返回字符串值,除非另有说明。

所有服务中可用的函数

$webhook->getEntranceCode();
$webhook->getPaymentReference();
$webhook->getCreationDateTime();
$webhook->getStatus();
$webhook->getDebtorReference();

支付特定函数

$transactionID = $webhook->getTransactionID();
$amount = $webhook->getAmount();
$amountPaid = $webhook->getAmountPaid();
$currency = $webhook->getCurrency();
$paymentMethod = $webhook->getPaymentMethod();

// note: these return a SimpleXML object
$paymentMethodDetails = $webhook->getPaymentMethodDetails(); 
$iDealDetails = $webhook->getIDealDetails();

// note: these are iDEAL specific
$debtorAccountName = $webhook->getDebtorAccountName();
$debtorIBAN = $webhook->getDebtorIBAN();
$debtorBankID = $webhook->getDebtorBankID();

EMandates特定函数

$mandateID = $webhook->getMandateID();
$statusDateTime = $webhook->getStatusDateTime();
$originalReport = $webhook->getOriginalReport(); // note: returns raw XML cdata object that still needs to be parsed.
$acceptanceReport = $webhook->getAcceptanceReportArray(); // note: returns array with a lot of values that are of use.

Identity特定函数

$requestType = $webhook->getRequestType();
$transactionID = $webhook->getTransactionID();
$debtorReference = $webhook->getDebtorReference();
$authenticationAuthorityID = $webhook->getAuthenticationAuthorityID();
$authenticationAuthorityName = $webhook->getAuthenticationAuthorityName();

// note: returns array with a lot of values that are of use.
$identityReportArray = $webhook->getIdentityReportArray(); 

2. 配置方法

将端点URL传达给pluginsupport@bluem.nl,以便在您的帐户中配置这些URL。请允许几天时间进行此配置。我们将一旦端点添加,立即跟进。

3. 验证是否正常工作

您可以通过向自己的端点POST来验证它是否正常工作。请与我们联系以获取用于您服务的示例Webhook调用。

Webhook支持

我们可以帮助您解决创建端点后可能遇到的问题。我们还可以帮助您验证数据是否正确发送。如果您在这方面需要帮助,请与我们联系。

支付

以下配置中的属性对于正确的eMandate功能至关重要

  • PaymentReference:一个在管理界面中可见的引用,可用于识别客户和/或交易详情。
  • 金额
    • 金额可变
    • 最小金额
    • 最大金额
    • AmountArray,
  • 设置并启用了支付功能的有效brandID

创建支付交易

支付服务类似于eMandates服务,但使用其他参数。以下是一个示例

$description = "Test payment"; // a concise description with possible references to order name and such.
$amount = 100.00;	 // as a float
$currency = "EUR"; // if set to null, will default to EUR as string
$debtorReference = "1234023"; 
$dueDateTime = null; // Set it automatically a day in advance. If you want to set it, use a datetime string in "YYYY-MM-DD H:i:s" format

$entranceCode = $bluem->CreateEntranceCode();

// To create AND perform a request:
$request = $bluem->CreatePaymentRequest(
    $description,
    $debtorReference,
    $amount,
    $dueDateTime,
    $currency,
    $entranceCode
);
// Or, to create and perform a request together in shorthand:
$response = $bluem->Payment(
    $description,
    $debtorReference,
    $amount,
    $dueDateTime,
    $currency
);

请求支付状态

类似于请求Mandate状态(见下文)

$statusResponse = $bluem->PaymentStatus($transactionID, $entranceCode);

if ($statusresponse->ReceivedResponse()) {

    $statuscode = ($statusresponse->GetStatusCode());

    // add your own logic in each case:
    switch ($statuscode) {
        case 'Success':
            // do something when the payment is successful directly
        case 'Processing':
        case 'Pending':
            // do something when the request is still processing (for example tell the user to come back later to this page)
            break;
        case 'Cancelled':
            // do something when the request has been canceled by the user.
            break;
        case 'Open':
            // do something when the request has not yet been completed by the user, redirecting to the transactionURL again.
            break;
        case 'Expired':
            // do something when the request has expired
            break;
        default:
            // unexpected status returned, show an error
            break;
    }

}

测试支付的小贴士

在Bluem测试模式下,您可以放置特定金额的iDEAL订单,以获取某种状态。这样,您可以查看支付成功或失败的情况。可用状态包括

  • 1.00(或任何其他值)成功
  • 4.00开放
  • 2.00已取消
  • 3.00已过期
  • 5.00失败
  • 7.00系统失败

向请求添加附加数据

您可以在执行之前向请求对象中添加额外信息,这可能很有用。数据将在ViaMijnBank门户中存储,以供进一步管理使用。

$key = "EmailAddress";
$value = "john@doe.com";

// after instantiating the request
$request->addAdditionalData($key, $value);
// but before performing it

提供未知密钥或无效格式化的值将导致异常。

密钥选项包括

EmailAddress

包含客户的电子邮件地址。

MobilePhoneNumber

包含客户的电子邮件地址。

CustomerProvidedDebtorIBAN

包含客户的额外债务人IBAN地址。

CustomerNumber

包含客户编号。

CustomerName

包含客户名称。

AttentionOf

包含要称呼的客户头衔或姓名。

Salutation

包含要问候的客户头衔或姓名。

CustomerAddressLine1

包含客户地址的第一部分。

CustomerAddressLine2

包含客户地址的第二部分。

DebtorBankID

以下有更多说明。

DynamicData

以下有更多说明。

eMandates

指令特定配置字段

bluem_config中的以下属性对于正确的eMandate功能至关重要。以下是每个配置字段意义的简要说明

  • 本地工具代码(CORE,B2B)
  • RequestType
    • 发行是默认值。修订/取消未使用。
  • SequenceType
    • 一次性,或OOFF
    • 定期,或 RCUR
  • MandateID,
  • MerchantID,
  • MaxAmount(用于B2B),
  • ValidationReference

创建 eMandate 交易:辅助函数

您需要某些信息来引用交易请求:一个ID(在这种情况下是MandateID),以及一个entranceCode(基本上是您开始请求时的一个时间戳)。创建此信息可以使用辅助函数完成。当创建新交易时,entranceCode和MandateID将在$bluem中生成。

生成Mandate ID

$mandateId = $bluem->CreateMandateId($order_id, $customer_id);

生成entrance code

$entranceCode = $bluem->CreateEntranceCode();

创建 eMandate 交易

默认交易返回到特定URL的回调函数,然后自动执行状态更新并可以执行其他功能。它使用在创建$bluem对象时设置的merchantReturnURLBase属性,以了解重定向到何处以期望此功能。此过程自动将mandateID作为GET参数添加到返回URL中,以便在状态更新时可以检索。

// default
$request = $bluem->CreateMandateRequest($customer_id,$order_id,"default");

// After creating any request, you will still have to perform the request:

$response = $bluem->PerformRequest($request);

提示:如果您不想在之前操作或读取请求对象,您也可以在一个函数调用中将请求的创建和执行结合起来

$response = $bluem->Mandate($customer_id, $order_id,"default");

如果您做错了任何事情,或者您未经授权,则响应对象将是Bluem\BluemPHP\ErrorBluemResponse类型,并有一个Error()函数来检索有关您的错误的信息,您可以将其显示给用户或自行处理。

关于无效访问令牌和ID的示例可以是:“未经授权:检查您的访问凭证”。

eMandate 交易创建后的重定向

当您成功完成交易请求后,您将从Bluem收到一个响应对象。此对象告诉您将用户重定向到哪个位置,以便在Bluem门户中实际执行管理步骤。

if ($response->ReceivedResponse()) {

	$entranceCode = $response->GetEntranceCode();
    // save the entranceCode in your data store

	$transactionURL = $response->GetTransactionURL();

    // TODO: redirect to the above transaction URL
    header("Location: ". $transactionURL); // or something of the sort.
} else {
    // TODO: no proper status given, show an error.
    exit("Error: " . $response->Error()); // for example
}

请求 eMandate 交易状态

$response = $bluem->MandateStatus(
    $existing_mandate_id,
    $existing_entrance_code
);
if (!$response->Status()) {
    // no valid response received
} else {
    if ($response->EMandateStatusUpdate->EMandateStatus->Status . "" === "Success") { // casting to string
        // successful status response
    } else {
        // different status response
    }
}

可能的状态有 Success(成功)、Processing(处理中)、Pending(挂起)、Cancelled(已取消)、Open(打开)和Expired(过期)。有关这些状态的更多详细信息,请参阅Bluem文档。

身份(iDIN)

配置 iDIN

确保在配置中设置了IDINBrandID属性,以便与其他Bluem服务并行使用iDIN。不同服务的BrandID可能不同:例如,CompanyPayment、CompanyMandate和CompanyIdentity。设置方式如下

$config->IDINBrandID = "CompanyIdentity";

身份请求类型说明

存在几种可能的IdentityRequests。可以同时访问一种或多种请求类型。在成功响应后,银行将返回每种类型的详细信息,以便您进一步处理。可能性包括

[
	"CustomerIDRequest",
	"NameRequest",
	"AddressRequest",
	"BirthDateRequest",
	"AgeCheckRequest",
	"GenderRequest",
	"TelephoneRequest",
	"EmailRequest",
	"AgeCheckRequest",
    "CustomerIDLoginRequest"
]

有关这些特定请求类型的详细信息,将很快提供更全面的指南。目前,请联系您的Bluem账户经理,以获得帮助选择与您期望的活动相匹配的使用案例。

与Identity请求最常用的三种案例是

  1. 完整身份验证(请求1或多个:Name(姓名)、Address(地址)、BirthDate(出生日期)、Gender(性别)、EmailAddress(电子邮件地址)、PhoneNumber(电话号码)、CustomerID(客户ID))。这用于KYC、Wwft、AML合规性和账户创建。
  2. 年龄验证18+(请求AgeVerify且不能与其他请求类别组合
  3. 使用iDIN进行安全登录(请求CustomerIDLogin且不能与其他请求类别组合;在此,您将利用iDIN登录作为传统用户名-密码登录的替代安全登录方法。请注意,使用iDIN进行安全登录需要先进行完整身份验证。

创建身份请求

在正确实例化Bluem对象后,可以创建身份交易请求。请记住,BrandID必须与身份请求兼容。通常,相应的品牌ID以“Identity”结尾,而不是例如“Mandate”或“Payment”。

$returnURL至关重要,因为Bluem将在处理完成后将用户重定向到该位置。下一节将介绍创建回调函数。

$description = "Test identity"; // description shown to customer
$debtorReference = "1234"; // client reference/number
$returnURL = "https://yourdomain.com/integration/identity.php?action=callback"; 
// provide a link here to the callback function; either in this script or another script.

$request = $bluem->CreateIdentityRequest(
	["BirthDateRequest", "AddressRequest"],
	$description,
	$debtorReference,
	$returnURL
);

$response = $bluem->PerformRequest($request);

从那时起处理请求很简单。请注意:将返回的信息保存在会话或用户数据存储中,以便您可以轻松地稍后引用此身份请求。注意:建议存储您已执行的请求,以便稍后知道如何处理它。

if ($response->ReceivedResponse()) {

	$entranceCode = $response->GetEntranceCode();
	$transactionID = $response->GetTransactionID();
	$transactionURL = $response->GetTransactionURL();
	// save this somewhere in your data store

	$_SESSION['entranceCode'] = $entranceCode;
	$_SESSION['transactionID'] = $transactionID;
	$_SESSION['transactionURL'] = $transactionURL;

	// direct the user to this place
	header("Location: ".$transactionURL);

} else {
	// no proper response received, tell the user
}

身份响应回调

在正确实例化Bluem对象后,可以处理回调函数。

// Retrieve from a store, preferably more persistent than session.
// The code below is purely for demonstrative purposes.

$transactionID = $_SESSION['transactionID'];
$entranceCode = $_SESSION['entranceCode'];


$statusResponse = $bluem->IdentityStatus(
    $transactionID,
    $entranceCode
);

现在,根据响应,您可以采取行动

if ($statusResponse->ReceivedResponse()) {

    $statusCode = ($statusResponse->GetStatusCode());

    switch ($statusCode) {
        case 'Success':
            // handle a success callback

            // retrieve a report that contains the information based on the request type:
            $identityReport = $statusResponse->GetIdentityReport();

            // this contains an object with key-value pairs of relevant data from the bank:
            /**
             * example contents:
             *  "DateTime": string(24) "2020-10-16T15:30:45.803Z"
             *  "CustomerIDResponse": string(21) "FANTASYBANK1234567890"
             *  "AddressResponse":
             *  object(Bluem\BluemPHP\IdentityStatusBluemResponse)#4 (5) {
             *      "Street": string(12) "Pascalstreet"
             *      "HouseNumber": string(2) "19"
             *      "PostalCode": string(6) "0000AA"
             *      "City": string(6) "Aachen"
             *      "CountryCode": string(2) "DE"
             *  }
             *  "BirthDateResponse": string(10) "1975-07-25"
             *  */
            // store information and process it.

            // You can for example use the BirthDateResponse to determine the age of the user and act accordingly.


            break;
        case 'Processing':
        case 'Pending':
            // do something when the request is still processing (for example tell the user to come back later to this page)
            break;
        case 'Cancelled':
            // do something when the request has been canceled by the user.
            break;
        case 'Open':
            // do something when the request has not yet been completed by the user, redirecting to the transactionURL again.
            break;
        case 'Expired':
            // do something when the request has expired
            break;
        default:
            // unexpected status returned, show an error
            break;
    }
} else {
    // no proper response received, tell the user
}

测试身份返回状态

当使用以给定前缀开始的特定entranceCodes进行iDIN时,您总是会到达银行的一个测试状态页面,您可以选择要接收的状态。您可以通过修改请求对象轻松利用此功能。

请注意,此功能仅在测试环境中有效。

$request->enableStatusGUI();

高级提示:此功能将一个字符串添加到您的entranceCode前面。如果它超过最大长度,可能会截断原始entranceCode。

CustomerIDLoginRequest

还可以使用此库为您应用程序执行登录请求,使用自定义流程。详细的说明将很快在此处提供。

IBAN-Name 检查

此服务允许您验证姓名和IBAN组合是否匹配且有效,这在验证用户注册、输入或在结账过程中非常有用。以下是一个此类请求及其结果的简单示例

$iban = "NL99ABNA1234012428";
$name = "H. de Vries";
$debtorReference = "1234";

$request = $bluem->CreateIBANNameCheckRequest(
    $iban,
    $name,
    $debtorReference
);

$response = $bluem->PerformRequest($request);

switch ($response->GetIBANResult()) {
case 'INVALID':
    echo "IBAN $iban and name $name do not match";
    break;
case 'KNOWN':
    // handle how the response should be taken in
    break;
}

IBAN-Name 检查用例和边缘情况

有关如何使用IBAN-Name检查的更多详细信息,将很快提供。

重要杂项说明

通过证书检查启用安全 Webhook 接收

要使用webhook功能,获取Bluem提供的Webhook证书的副本,并将其放入名为keys的文件夹中,该文件夹可由此库中的代码写入。

附录

每个上下文支持的所有 BIC 列表

ePayments

  • ABN AMRO
    银行识别码(BIC): ABNANL2A
  • ASN 银行
    银行识别码(BIC): ASNBNL21
  • bunq
    银行识别码(BIC): BUNQNL2A
  • ING
    银行识别码(BIC): INGBNL2A
  • Knab
    银行识别码(BIC): KNABNL2H
  • Rabobank
    银行识别码(BIC): RABONL2U
  • RegioBank
    银行识别码(BIC): RBRBNL21
  • SNS
    银行识别码(BIC): SNSBNL2A
  • Triodos Bank
    银行识别码(BIC): TRIONL2U
  • Van Lanschot
    银行识别码(BIC): FVLBNL22
  • Revolut
    银行识别码(BIC): REVOLT21
  • Yoursafe
    银行识别码(BIC): BITSNL2A
  • N26
    银行识别码(BIC): NTSBDEB1
  • Nationale-Nederlanden
    银行识别码(BIC): NNBANL2G

eMandates CORE

  • ABN AMRO
    银行识别码(BIC): ABNANL2A
  • ASN 银行
    银行识别码(BIC): ASNBNL21
  • ING
    银行识别码(BIC): INGBNL2A
  • Rabobank
    银行识别码(BIC): RABONL2U
  • RegioBank
    银行识别码(BIC): RBRBNL21
  • SNS
    银行识别码(BIC): SNSBNL2A
  • Triodos Bank
    银行识别码(BIC): TRIONL2U

eMandates B2B

  • ABN AMRO
    银行识别码(BIC): ABNANL2A
  • ING
    银行识别码(BIC): INGBNL2A
  • Rabobank
    银行识别码(BIC): RABONL2U

身份验证

  • ABN AMRO
    银行识别码(BIC): ABNANL2A
  • ASN 银行
    银行识别码(BIC): ASNBNL21
  • bunq
    银行识别码(BIC): BUNQNL2A
  • ING
    银行识别码(BIC): INGBNL2A
  • Rabobank
    银行识别码(BIC): RABONL2U
  • RegioBank
    银行识别码(BIC): RBRBNL21
  • SNS
    银行识别码(BIC): SNSBNL2A

请注意:截至2023年10月4日,Knab(银行识别码:KNABNL2H)不再支持eMandates CORE。

待办事项