Skip to content

Commit b48fd61

Browse files
authored
Merge pull request #118 from bluem-development/giropay-etc
2 parents 3c4676b + f5f15f5 commit b48fd61

8 files changed

Lines changed: 74 additions & 111 deletions

File tree

README.md

Lines changed: 17 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,25 @@ Utilized by other applications as well:
1111
- [Magento2 module](https://github.com/bluem-development/bluem-magento/), available for Bluem customers.
1212
- Several third-party customer applications by Bluem customers.
1313

14+
## Documentation
15+
16+
> Read our improved documentation [**here**](https://bluem-development.github.io/bluem-docs/bluemphp.html)
17+
18+
We have several guides available there. They include:
19+
20+
- [Getting started guide](https://bluem-development.github.io/bluem-docs/tutorial-configuration.html)
21+
- [Tutorial on payments](https://bluem-development.github.io/bluem-docs/tutorial-payments.html)
22+
- [Tutorial on webhooks](https://bluem-development.github.io/bluem-docs/tutorial-webhooks.html)
23+
- More are coming soon!
24+
25+
## Remaining documentation
26+
27+
Most of this will be migrated into the documentation mentioned above. Note: You might find duplicate information below.
28+
1429
## Table of Contents
1530

16-
* [Requirements](#requirements)
31+
- [Requirements](#requirements)
32+
1733
- [Getting started:](#getting-started)
1834
- [Changelog](#changelog)
1935
- [Testing](#testing)
@@ -183,103 +199,6 @@ The Webhook is only needed for ePayments and eMandates: online stores/portals th
183199
Please note that the flow for the IBAN-Name check is shorter: a TransactionRequest is performed. The results return as a TransactionResponse.
184200
This is because the end-user is not needed; the call is straight to the Bank Database, that provides in the TransactionResponse the IBAN-Name check results.
185201

186-
## Preselecting a bank for Payment requests using debtorWallet
187-
188-
**Note:** This is relevant for bank-based transactions and services:
189-
190-
It is possible to preselect a Bank within your own application for Payments, based on an IssuerID (BIC/Swift code) when creating a Mandate, Payment or Identity request. This can be used if you want to user to select the given bank in your own interface and skip the bank selection within the Bluem portal interface.
191-
This reduces the amount of steps required by performing the selection of the bank within your own application and interface by utilizing the preselection feature from the PHP library on the request object as so:
192-
193-
```php
194-
$BIC = "INGBNL2A";
195-
$request->selectDebtorWallet($BIC);
196-
```
197-
198-
Parameter has to be a valid BIC code of a supported bank. An invalid BIC code will trigger an exception. **Please note that supported BICs differ per service as not every bank offers the same services!** The supported BIC codes per service can also be requested from a Bluem object, given the service context. **As appendix to this Documentation file, you can find a full list of all BICs per context.**
199-
200-
Illustrated here is that a list of BICs per context can also be retrieved programmatically:
201-
202-
```php
203-
$MandatesBICs = $bluem->retrieveBICsForContext("Mandates"); // also specific to localInstrumentCode, see notes.
204-
$PaymentsBICs = $bluem->retrieveBICsForContext("Payments");
205-
$IdentityBICs = $bluem->retrieveBICsForContext("Identity");
206-
```
207-
208-
Input of a different context will trigger an exception. If valid, the result is an array of `Bluem\BluemPHP\BIC` objects with attributes `IssuerID` and `IssuerName`: the BIC and Bank name respectively. You can use this to populate your user interface.
209-
210-
Please note that the BIC list will vary when a different `localInstrumentCode` is configured. The localInstrumentCode `CORE` and `B2B` are supported by different banks. Based on your configuration, the right BIC list is loaded from context automatically and used to verify the debtorWallet.
211-
212-
This method can be used when creating iDIN and when creating iDEAL requests; you could store the selected bank (“Issuer”) on user level and use it when creating a request for your user.
213-
214-
- You can inform the user WHY this is necessary and refer to the new laws and rules, in your own website/application or refer to the news/public announcements.
215-
- You can inform the user about the amount of trouble required: display a piece of text saying that it only takes a minute or two, and that it is stored for your convenience: that it ensures integrity, and a valid webshop experience.
216-
217-
## Using different Payment transaction methods
218-
219-
**Important note: ensure you have the right BrandID set up for specific payment methods. Refer to your account manager to retrieve a list of the specific BrandIDs per payment method**
220-
221-
You can allow the PayPal and Creditcard payment methods by selecting these within the request object before sending it.
222-
223-
To use iDeal, (default option). A BIC **can** be provided. If left empty, bank selection will occur in the Bluem portal.
224-
225-
```php
226-
$BIC = 'INGBNL2A';
227-
$request = $request->setPaymentMethodToIDEAL($BIC);
228-
```
229-
230-
To use PayPal, give in a PayPal account email address. The email is also not required.
231-
232-
```php
233-
$payPalAccount = 'john.doe@gmail.com';
234-
$request = $request->setPaymentMethodToPayPal($payPalAccount);
235-
```
236-
237-
To use Creditcards, you can set the credit card details as follows (not required)
238-
239-
```php
240-
$request = $request->setPaymentMethodToCreditCard();
241-
```
242-
243-
or
244-
245-
```php
246-
$cardNumber = '1234000012340000';
247-
$name = 'John Doe';
248-
$securityCode = 123;
249-
$expirationDateMonth = 11;
250-
$expirationDateYear = 2025;
251-
252-
$request = $request->setPaymentMethodToCreditCard(
253-
$cardNumber,
254-
$name,
255-
$securityCode,
256-
$expirationDateMonth,
257-
$expirationDateYear
258-
);
259-
```
260-
261-
To use Sofort, use the following method:
262-
263-
```php
264-
$request = $request->setPaymentMethodToSofort();
265-
```
266-
267-
To use Carte Bancaire, use the following method:
268-
269-
```php
270-
$request = $request->setPaymentMethodToCarteBancaire();
271-
```
272-
273-
To use Bancontact, use the following method
274-
275-
```php
276-
$request = $request->setPaymentMethodToBancontact();
277-
```
278-
279-
These methods will throw an exception if required information is missing.
280-
281-
Once the request executes, the link to the transaction will send you to the Bluem Portal with the corresponding interface and flow.
282-
283202
## Webhooks
284203

285204
Webhooks exist for Payments, eMandates and Identity. They trigger during requests to the Bluem flow and send data to your application.

src/Contexts/PaymentsContext.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ class PaymentsContext extends BluemContext
2323
public const PAYMENT_METHOD_CREDITCARD = 'CreditCard';
2424

2525
public const PAYMENT_METHOD_SOFORT = 'Sofort';
26+
public const PAYMENT_METHOD_SOFORT_DIGITAL_SERVICES = 'SofortDigitalServices';
2627

2728
public const PAYMENT_METHOD_CARTE_BANCAIRE = 'CarteBancaire';
28-
2929
public const PAYMENT_METHOD_BANCONTACT = 'Bancontact';
30+
public const PAYMENT_METHOD_GIROPAY = 'Giropay';
3031

3132
public const PAYMENT_METHODS = [
33+
self::PAYMENT_METHOD_BANCONTACT,
34+
self::PAYMENT_METHOD_CARTE_BANCAIRE,
35+
self::PAYMENT_METHOD_CREDITCARD,
36+
self::PAYMENT_METHOD_GIROPAY,
3237
self::PAYMENT_METHOD_IDEAL,
3338
self::PAYMENT_METHOD_PAYPAL,
34-
self::PAYMENT_METHOD_CREDITCARD,
39+
self::PAYMENT_METHOD_SOFORT_DIGITAL_SERVICES,
3540
self::PAYMENT_METHOD_SOFORT,
36-
self::PAYMENT_METHOD_CARTE_BANCAIRE,
37-
self::PAYMENT_METHOD_BANCONTACT,
3841
];
3942

4043
public string $debtorWalletElementName = self::PAYMENT_METHOD_IDEAL;

src/Requests/BluemRequest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,18 @@ public function setBrandId(string $brandID): void
445445
{
446446
$this->brandID = $brandID;
447447
}
448+
449+
/**
450+
* Use the right separator based on the presence of a query string
451+
*/
452+
protected function appendToUrl(string $urlBase, string $key, $value): string
453+
{
454+
$hasQueryString = preg_match('/\?.+=.+/', $urlBase);
455+
456+
if ($hasQueryString) {
457+
return "{$urlBase}&{$key}={$value}";
458+
}
459+
460+
return "{$urlBase}?{$key}={$value}";
461+
}
448462
}

src/Requests/EmandateBluemRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function __construct(BluemConfiguration $config, private $debtorReference
6767
$this->mandateID = $mandateID;
6868

6969
// https - unique return URL for customer
70-
$this->merchantReturnURL = sprintf('%s?mandateID=%s', $this->merchantReturnURLBase, $this->mandateID);
70+
$this->merchantReturnURL = $this->appendToUrl($this->merchantReturnURLBase, 'mandateID', $this->mandateID);
71+
7172
$this->sequenceType = $config->sequenceType ?? "RCUR";
7273
// reason for the mandate; configurable per client
7374
$this->eMandateReason = $config->eMandateReason ?? "Incasso machtiging";

src/Requests/IdentityBluemRequest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ public function __construct(
7070
$this->requestCategory = $this->getRequestCategoryElement($requestCategory);
7171
$this->description = $this->_sanitizeDescription($description);
7272
if (empty($debtorReturnURL)) {
73-
throw new InvalidBluemRequestException("Debtor return URL is required");
73+
$debtorReturnURL = $config->merchantReturnURLBase;
7474
}
75-
76-
$this->debtorReturnURL = $debtorReturnURL . ('?debtorReference=' . $this->debtorReference);
75+
$this->debtorReturnURL = $this->appendToUrl($debtorReturnURL, "debtorReference", $this->debtorReference);
7776

7877
// @todo: make this a configurable setting
7978
$this->minAge = $config->minAge ?? BLUEM_DEFAULT_MIN_AGE;

src/Requests/PaymentBluemRequest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ public function __construct(
106106
$this->debtorReturnURL = $config->merchantReturnURLBase;
107107
}
108108

109-
$this->debtorReturnURL .= sprintf('?entranceCode=%s&transactionID=%s', $this->entranceCode, $this->transactionID);
110-
111-
$this->debtorReturnURL = str_replace('&', '&', $this->debtorReturnURL);
109+
$this->debtorReturnURL = $this->appendToUrl($this->debtorReturnURL, 'entranceCode', $this->entranceCode);
110+
$this->debtorReturnURL = $this->appendToUrl($this->debtorReturnURL, 'transactionID', $this->transactionID);
112111

113112
// Note: different variable name in config
114113
// added entranceCode as well, useful. Defined in generic bluem request class.
@@ -276,19 +275,30 @@ public function setPaymentMethodToSofort(): self
276275
return $this;
277276
}
278277

278+
public function setPaymentMethodToSofortDigitalServices(): self
279+
{
280+
$this->setPaymentMethod($this->context::PAYMENT_METHOD_SOFORT_DIGITAL_SERVICES);
281+
return $this;
282+
}
283+
279284
public function setPaymentMethodToCarteBancaire(): self
280285
{
281286
$this->setPaymentMethod($this->context::PAYMENT_METHOD_CARTE_BANCAIRE);
282287
return $this;
283288
}
284289

290+
public function setPaymentMethodToGiropay(): self
291+
{
292+
$this->setPaymentMethod($this->context::PAYMENT_METHOD_GIROPAY);
293+
return $this;
294+
}
295+
285296
public function setPaymentMethodToBancontact(): self
286297
{
287298
$this->setPaymentMethod($this->context::PAYMENT_METHOD_BANCONTACT);
288299
return $this;
289300
}
290301

291-
292302
/**
293303
* @throws InvalidBluemRequestException
294304
*/

tests/Acceptance/PaymentsAcceptanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testPaymentRequestXmlUsesSandboxSampleData(): void
3939
'<Currency>EUR</Currency>',
4040
'<Amount>12.34</Amount>',
4141
'<DueDateTime>2026-04-12T00:00:00.000Z</DueDateTime>',
42-
'<DebtorReturnURL automaticRedirect="1">http://localhost:8000/?a=callback?entranceCode=PAYMENT-ENTRANCE-123&amp;transactionID=TRANS123</DebtorReturnURL>',
42+
'<DebtorReturnURL automaticRedirect="1">http://localhost:8000/?a=callback&amp;entranceCode=PAYMENT-ENTRANCE-123&amp;transactionID=TRANS123</DebtorReturnURL>',
4343
'<DebtorWallet>',
4444
'<Bancontact>',
4545
);

validation/EPayment.xsd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.7.0">
23
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.7.0">
34
<!--=====================================================================-->
45
<!-- Schema Management -->
@@ -9,6 +10,8 @@
910
<xsd:documentation xml:lang="en"/>
1011
<xsd:documentation>
1112
<name>EPayment Interface</name>
13+
<revision version="1.6.0">
14+
<date>2023-JANUARY-10</date>
1215
<revision version="1.6.0">
1316
<date>2023-JANUARY-10</date>
1417
</revision>
@@ -177,6 +180,7 @@
177180
</xsd:restriction>
178181
</xsd:simpleType>
179182

183+
<xsd:simpleType name="CurrencySimpleType">
180184
<xsd:simpleType name="CurrencySimpleType">
181185
<xsd:restriction base="xsd:token">
182186
<xsd:enumeration value="EUR"/>
@@ -279,6 +283,7 @@
279283
<xsd:enumeration value="SuccessManual"/>
280284
<xsd:enumeration value="BankSelected"/>
281285
<xsd:enumeration value="Refunded"/>
286+
<xsd:enumeration value="Refunded"/>
282287
</xsd:restriction>
283288
</xsd:simpleType>
284289

@@ -322,6 +327,7 @@
322327
<xsd:enumeration value="VISA_MASTER"/>
323328
<xsd:enumeration value="SOFORT"/>
324329
<xsd:enumeration value="SOFORT_DIGITALSERVICES"/>
330+
<xsd:enumeration value="SOFORT_DIGITALSERVICES"/>
325331
<xsd:enumeration value="CARTE_BANCAIRE"/>
326332
<xsd:enumeration value="BANCONTACT"/>
327333
<xsd:enumeration value="GIROPAY"/>
@@ -464,8 +470,10 @@
464470

465471

466472

473+
<!-- BEGIN - DebtorWallet additions -->
467474
<!-- BEGIN - DebtorWallet additions -->
468475
<xsd:complexType name="DebtorCreditCardComplexType">
476+
</xsd:complexType>
469477
</xsd:complexType>
470478

471479
<xsd:complexType name="IDealComplexType">
@@ -553,6 +561,14 @@
553561
</xsd:sequence>
554562
</xsd:complexType>
555563

564+
<xsd:complexType name="SofortDigitalServicesDetailsComplexType">
565+
<xsd:sequence>
566+
<xsd:element name="DebtorAccountName" type="TokenLength70SimpleType" minOccurs="0"/>
567+
<xsd:element name="DebtorAccount" type="TokenLength70SimpleType" minOccurs="0"/>
568+
</xsd:sequence>
569+
</xsd:complexType>
570+
571+
556572
<xsd:complexType name="SofortDigitalServicesDetailsComplexType">
557573
<xsd:sequence>
558574
<xsd:element name="DebtorAccountName" type="TokenLength70SimpleType" minOccurs="0"/>
@@ -708,6 +724,7 @@
708724
<xsd:attribute name="language" type="LanguageCodeSimpleType" default="nl"/>
709725
</xsd:attributeGroup>
710726

727+
711728
<xsd:element name="EPaymentInterface" type="EPaymentInterfaceType"/>
712729

713730
</xsd:schema>

0 commit comments

Comments
 (0)