1. Go to this page and download the library: Download daanrijpkema/bluem-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daanrijpkema / bluem-php example snippets
$bluem->VerifyIPIsNetherlands();
// returns bool true if NL or error, returns false if no error and other country.
$bluem = new Bluem($config);
// get composer dependencies
he 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);
$MandatesBICs = $bluem->retrieveBICsForContext("Mandates"); // also specific to localInstrumentCode, see notes.
$PaymentsBICs = $bluem->retrieveBICsForContext("Payments");
$IdentityBICs = $bluem->retrieveBICsForContext("Identity");
$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
}
$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();
$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.
$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();
$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
);
$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;
}
}
$key = "EmailAddress";
$value = "[email protected]";
// after instantiating the request
$request->addAdditionalData($key, $value);
// but before performing it
// 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);
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
}
$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
}
}
$config->IDINBrandID = "CompanyIdentity";
$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
}
// 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
}
$request->enableStatusGUI();
$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;
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.