From df5417d57f266fdfcea3cd4eeefef225e7a94495 Mon Sep 17 00:00:00 2001
From: Simon Gabriel
Date: Wed, 5 Sep 2018 16:47:14 +0200
Subject: [PATCH 1/9] [change] (PHPLIB-41) Add example for easyCredit
paymentMethod.
---
example/EasyCredit.php | 124 +++++++++++++++++++++++++++++++++
example/EasyCreditResponse.php | 79 +++++++++++++++++++++
2 files changed, 203 insertions(+)
create mode 100755 example/EasyCredit.php
create mode 100755 example/EasyCreditResponse.php
diff --git a/example/EasyCredit.php b/example/EasyCredit.php
new file mode 100755
index 0000000..aefa87d
--- /dev/null
+++ b/example/EasyCredit.php
@@ -0,0 +1,124 @@
+getRequest()->authentification(
+ '31HA07BC8181E8CCFDAD64E8A4B3B766', // SecuritySender
+ '31ha07bc8181e8ccfdad73fd513d2a53', // UserLogin
+ '4B2D4BE3', // UserPassword
+ '31HA07BC8179C95F6B59366492FD253D', // TransactionChannel credit card without 3d secure
+ true // Enable sandbox mode
+);
+/**
+ * Set up asynchronous request parameters
+ */
+$easyCredit->getRequest()->async(
+ 'EN', // Language code for the Frame
+ HEIDELPAY_PHP_PAYMENT_API_URL .
+ HEIDELPAY_PHP_PAYMENT_API_FOLDER .
+ 'EasyCreditResponse.php' // Response url from your application
+);
+/**
+ * Set up customer information required for risk checks
+ */
+$easyCredit->getRequest()->customerAddress(
+ 'Heidel', // Given name
+ 'Berger-Payment', // Family name
+ null, // Company Name
+ '12344', // Customer id of your application
+ 'Vagerowstr. 18', // Billing address street
+ 'DE-BW', // Billing address state
+ '69115', // Billing address post code
+ 'Heidelberg', // Billing address city
+ 'DE', // Billing address country code
+ 'support@heidelpay.com' // Customer mail address
+);
+/**
+ * Set up basket or transaction information
+ */
+$easyCredit->getRequest()->basketData(
+ '2843294932', // Reference Id of your application
+ 203.12, // Amount of this request
+ 'EUR', // Currency code of this request
+ '39542395235ßfsokkspreipsr' // A secret passphrase from your application
+);
+/**
+ * Set up risk information.
+ */
+$easyCredit->getRequest()->getRiskInformation()
+ ->setCustomerGuestCheckout('false')
+ ->setCustomerOrderCount('23')
+ ->setCustomerSince('2005-08-12');
+/**
+ * Set necessary parameters for Heidelpay payment and send the request
+ */
+$easyCredit->initialize();
+
+?>
+
+
+ EasyCredit example
+
+
+getResponse();
+if ($response->isSuccess()) {
+ echo '';
+ echo $response->getConfig()->getOptinText();
+ echo'
Weiter zu easyCredit... ';
+ } else {
+ echo ''. print_r($response->getError(), 1).' ';
+ }
+ ?>
+ It is not necessary to show the redirect url to your customer. You can
+ use php header to forward your customer directly.
+ For example:
+ header('Location: '.$Invoice->getResponse()->getPaymentFromUrl());
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/EasyCreditResponse.php b/example/EasyCreditResponse.php
new file mode 100755
index 0000000..8464c17
--- /dev/null
+++ b/example/EasyCreditResponse.php
@@ -0,0 +1,79 @@
+getCriterion()->get('EASYCREDIT_AMORTISATIONTEXT'));
+
+
+//$easyCredit->initialize();
+//
+//?>
+
+
+
+
+
+getResponse();
+//if ($response->isSuccess()) {
+// echo '';
+// echo $response->getConfig()->getOptinText();
+// echo'
Weiter zu easyCredit... ';
+// } else {
+// echo ''. print_r($response->getError(), 1).' ';
+// }
+// ?>
+
+
+
+
+
+
+
From 74ffad303074d37ed42d7548b4f1b0a343922b7c Mon Sep 17 00:00:00 2001
From: Simon Gabriel
Date: Thu, 6 Sep 2018 08:20:21 +0200
Subject: [PATCH 2/9] [change] (PHPLIB-41) Add path to codecept executable and
extend test section in readme.
---
README.md | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index a5bd4e0..68120fa 100755
--- a/README.md
+++ b/README.md
@@ -55,19 +55,25 @@ Please visit [http://dev.heidelpay.com/heidelpay-php-payment-api/](http://dev.he
This library comes with a set of unit and integration tests. Please do not run the integration tests on each build.
Run prior to tests:
-`codecept build`
+`vendor/bin/codecept build`
Run unit tests:
-`codecept run unit`
+`vendor/bin/codecept run unit`
Run unit tests with code coverage report:
-`codecept run unit --coverage --coverage-html`
+`vendor/bin/codecept run unit --coverage --coverage-html`
Run integration tests:
-`codecept run integration`
+`vendor/bin/codecept run integration`
Run integration tests with debug output:
-`codecept run integration --debug`
+`vendor/bin/codecept run integration --debug`
+
+Run all integration test of a specific class:
+`vendor/bin/codecept run tests/integration/PaymentMethods/EasyCreditPaymentMethodTest`
+
+Run a specific integration test:
+`vendor/bin/codecept run tests/integration/PaymentMethods/EasyCreditPaymentMethodTest:initialRequest`
For coverage analysis results see:
`./tests/_output/coverage/index.html`
From 0fd87ced03f7253b00b3602f746901c39f4d2dc7 Mon Sep 17 00:00:00 2001
From: Simon Gabriel
Date: Thu, 6 Sep 2018 15:18:00 +0200
Subject: [PATCH 3/9] [change] (PHPLIB-41) Add easyCredit reservation to
example.
---
composer.json | 1 +
example/EasyCreditReservation.php | 103 ++++++++++++++++++++++++++++++
example/EasyCreditResponse.php | 76 ++++++++++------------
3 files changed, 139 insertions(+), 41 deletions(-)
create mode 100755 example/EasyCreditReservation.php
diff --git a/composer.json b/composer.json
index 697f4e7..44cab28 100755
--- a/composer.json
+++ b/composer.json
@@ -26,6 +26,7 @@
"ext-SimpleXML": "*"
},
"require-dev": {
+ "ext-json": "*",
"friendsofphp/php-cs-fixer": "^2.0",
"heidelpay/phpdocumentor": "2.9.1",
"codeception/codeception": "~2.3.9",
diff --git a/example/EasyCreditReservation.php b/example/EasyCreditReservation.php
new file mode 100755
index 0000000..1904452
--- /dev/null
+++ b/example/EasyCreditReservation.php
@@ -0,0 +1,103 @@
+getRequest();
+
+/**
+ * Set up your authentification data for Heidepay api
+ *
+ * @link https://dev.heidelpay.com/testumgebung/#Authentifizierungsdaten
+ */
+$request->authentification(
+ '31HA07BC8181E8CCFDAD64E8A4B3B766', // SecuritySender
+ '31ha07bc8181e8ccfdad73fd513d2a53', // UserLogin
+ '4B2D4BE3', // UserPassword
+ '31HA07BC8179C95F6B59366492FD253D', // TransactionChannel credit card without 3d secure
+ true // Enable sandbox mode
+);
+
+/**
+ * Set up asynchronous request parameters
+ */
+$request->getFrontend()->setEnabled('FALSE');
+
+/**
+ * Set up customer information required for risk checks
+ */
+$request->customerAddress(
+ 'Heidel', // Given name
+ 'Berger-Payment', // Family name
+ null, // Company Name
+ '12344', // Customer id of your application
+ 'Vagerowstr. 18', // Billing address street
+ 'DE-BW', // Billing address state
+ '69115', // Billing address post code
+ 'Heidelberg', // Billing address city
+ 'DE', // Billing address country code
+ 'support@heidelpay.com' // Customer mail address
+);
+/**
+ * Set up basket or transaction information
+ */
+$request->basketData(
+ '2843294932', // Reference Id of your application
+ 203.12, // Amount of this request
+ 'EUR', // Currency code of this request
+ '39542395235ßfsokkspreipsr' // A secret passphrase from your application
+);
+
+/**
+ * Set up risk information.
+ */
+$request->getRiskInformation()
+ ->setCustomerGuestCheckout('false')
+ ->setCustomerOrderCount('23')
+ ->setCustomerSince('2005-08-12');
+
+/**
+ * Set necessary parameters for Heidelpay payment and send the request
+ */
+$easyCredit->authorizeOnRegistration($response->getIdentification()->getUniqueId());
+
+$url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . '/HeidelpaySuccess.php';
+
+if ($response->isError()) {
+ $url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . '/HeidelpayError.php';
+}
+Header('Location: ' . $url);
+?>
\ No newline at end of file
diff --git a/example/EasyCreditResponse.php b/example/EasyCreditResponse.php
index 8464c17..7257b8b 100755
--- a/example/EasyCreditResponse.php
+++ b/example/EasyCreditResponse.php
@@ -29,51 +29,45 @@
require_once __DIR__ . '/../vendor/autoload.php';
if (!empty($_POST)) {
- echo HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCreditResponse.php';
-// mail('simon.gabriel@heidelpay.com', 'betreff', print_r($_POST,1));
- file_put_contents (EASY_CREDIT_RESPONSE_PARAMS_TXT, print_r($_POST, 1));
+ $responseURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCreditResponse.php';
+ echo $responseURL;
+ file_put_contents (EASY_CREDIT_RESPONSE_PARAMS_TXT, json_encode($_POST));
exit();
}
+$reservationURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCreditReservation.php';
-$params = file_get_contents(EASY_CREDIT_RESPONSE_PARAMS_TXT);
+$params = json_decode(file_get_contents(EASY_CREDIT_RESPONSE_PARAMS_TXT),1);
-echo print_r($params,1);
+$response = Response::fromPost($params);
+//var_dump($response);
-///**
-// * Load a new instance of the payment method
-// */
-// $easyCredit = new EasyCreditPaymentMethod();
-//
-// /** @var Response $response */
-// $response = Response::fromPost($_POST);
-
-// var_dump($_POST);
-// var_dump($response);
-// var_dump($response->getCriterion()->get('EASYCREDIT_AMORTISATIONTEXT'));
-
-
-//$easyCredit->initialize();
-//
-//?>
-
-
-
-
-
+?>
+
+
+ EasyCredit example
+
+
getResponse();
-//if ($response->isSuccess()) {
-// echo '';
-// echo $response->getConfig()->getOptinText();
-// echo'
Weiter zu easyCredit... ';
-// } else {
-// echo ''. print_r($response->getError(), 1).' ';
-// }
-// ?>
-
-
-
-
-
-
-
+if ($response->isSuccess()) {
+ echo 'Hier Ihr ausgewählter Ratenplan: ' . '';
+ $amortisationtext = $response->getCriterion()->get('EASYCREDIT_AMORTISATIONTEXT');
+ $precontractInformationUrl = $response->getCriterion()->get('EASYCREDIT_PRECONTRACTINFORMATIONURL');
+ echo $amortisationtext . '';
+ echo 'Ihre vorvertraglichen Informationen zum Download... ';
+ echo 'Rechnungsbetrag: ' . $response->getCriterion()->get('EASYCREDIT_TOTALORDERAMOUNT') . '';
+ echo 'Zinsen: '. $response->getCriterion()->get('EASYCREDIT_ACCRUINGINTEREST') . '';
+ echo 'Gesamt inkl. Zinsen: '. $response->getCriterion()->get('EASYCREDIT_TOTALAMOUNT') . '';
+
+ echo'
Bestellen... ';
+} else {
+ echo ''. print_r($response->getError(), 1).' ';
+}
+?>
+ It is not necessary to show the redirect url to your customer. You can
+ use php header to forward your customer directly.
+ For example:
+ header('Location: '.$Invoice->getResponse()->getPaymentFromUrl());
+
+
+
From c434b419ac042afb414c0c2c7831745e1023da60 Mon Sep 17 00:00:00 2001
From: Simon Gabriel
Date: Thu, 6 Sep 2018 15:31:05 +0200
Subject: [PATCH 4/9] [change] (PHPLIB-41) Move easyCredit files to dedicated
folder.
---
example/EasyCredit.php | 2 +-
example/{ => EasyCredit}/EasyCreditReservation.php | 8 ++++----
example/{ => EasyCredit}/EasyCreditResponse.php | 13 ++++++-------
example/EasyCredit/EasyCreditResponseParams.txt | 0
4 files changed, 11 insertions(+), 12 deletions(-)
rename example/{ => EasyCredit}/EasyCreditReservation.php (95%)
rename example/{ => EasyCredit}/EasyCreditResponse.php (83%)
create mode 100755 example/EasyCredit/EasyCreditResponseParams.txt
diff --git a/example/EasyCredit.php b/example/EasyCredit.php
index aefa87d..e70b399 100755
--- a/example/EasyCredit.php
+++ b/example/EasyCredit.php
@@ -58,7 +58,7 @@
'EN', // Language code for the Frame
HEIDELPAY_PHP_PAYMENT_API_URL .
HEIDELPAY_PHP_PAYMENT_API_FOLDER .
- 'EasyCreditResponse.php' // Response url from your application
+ 'EasyCredit/EasyCreditResponse.php' // Response url from your application
);
/**
* Set up customer information required for risk checks
diff --git a/example/EasyCreditReservation.php b/example/EasyCredit/EasyCreditReservation.php
similarity index 95%
rename from example/EasyCreditReservation.php
rename to example/EasyCredit/EasyCreditReservation.php
index 1904452..88b4a7c 100755
--- a/example/EasyCreditReservation.php
+++ b/example/EasyCredit/EasyCreditReservation.php
@@ -21,12 +21,12 @@
use Heidelpay\PhpPaymentApi\Response;
const EASY_CREDIT_RESPONSE_PARAMS_TXT = __DIR__ . '/EasyCreditResponseParams.txt';
-require_once './_enableExamples.php';
+require_once './../_enableExamples.php';
/**
* Require the composer autoloader file
*/
-require_once __DIR__ . '/../vendor/autoload.php';
+require_once __DIR__ . '/../../vendor/autoload.php';
$params = json_decode(file_get_contents(EASY_CREDIT_RESPONSE_PARAMS_TXT),1);
@@ -94,10 +94,10 @@
*/
$easyCredit->authorizeOnRegistration($response->getIdentification()->getUniqueId());
-$url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . '/HeidelpaySuccess.php';
+$url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'HeidelpaySuccess.php';
if ($response->isError()) {
- $url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . '/HeidelpayError.php';
+ $url = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'HeidelpayError.php';
}
Header('Location: ' . $url);
?>
\ No newline at end of file
diff --git a/example/EasyCreditResponse.php b/example/EasyCredit/EasyCreditResponse.php
similarity index 83%
rename from example/EasyCreditResponse.php
rename to example/EasyCredit/EasyCreditResponse.php
index 7257b8b..41fc701 100755
--- a/example/EasyCreditResponse.php
+++ b/example/EasyCredit/EasyCreditResponse.php
@@ -21,25 +21,24 @@
use Heidelpay\PhpPaymentApi\Response;
const EASY_CREDIT_RESPONSE_PARAMS_TXT = __DIR__ . '/EasyCreditResponseParams.txt';
-require_once './_enableExamples.php';
+require_once './../_enableExamples.php';
/**
* Require the composer autoloader file
*/
-require_once __DIR__ . '/../vendor/autoload.php';
+require_once __DIR__ . '/../../vendor/autoload.php';
if (!empty($_POST)) {
- $responseURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCreditResponse.php';
+ $responseURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCredit/EasyCreditResponse.php';
echo $responseURL;
file_put_contents (EASY_CREDIT_RESPONSE_PARAMS_TXT, json_encode($_POST));
exit();
}
-$reservationURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCreditReservation.php';
+$reservationURL = HEIDELPAY_PHP_PAYMENT_API_URL . HEIDELPAY_PHP_PAYMENT_API_FOLDER . 'EasyCredit/EasyCreditReservation.php';
$params = json_decode(file_get_contents(EASY_CREDIT_RESPONSE_PARAMS_TXT),1);
$response = Response::fromPost($params);
-//var_dump($response);
?>
@@ -54,12 +53,12 @@
$amortisationtext = $response->getCriterion()->get('EASYCREDIT_AMORTISATIONTEXT');
$precontractInformationUrl = $response->getCriterion()->get('EASYCREDIT_PRECONTRACTINFORMATIONURL');
echo $amortisationtext . '';
- echo 'Ihre vorvertraglichen Informationen zum Download... ';
+ echo 'Ihre vorvertraglichen Informationen zum Download... ';
echo 'Rechnungsbetrag: ' . $response->getCriterion()->get('EASYCREDIT_TOTALORDERAMOUNT') . '';
echo 'Zinsen: '. $response->getCriterion()->get('EASYCREDIT_ACCRUINGINTEREST') . '';
echo 'Gesamt inkl. Zinsen: '. $response->getCriterion()->get('EASYCREDIT_TOTALAMOUNT') . '';
- echo'Bestellen... ';
+ echo'Zahlungspflichtig bestellen... ';
} else {
echo ''. print_r($response->getError(), 1).' ';
}
diff --git a/example/EasyCredit/EasyCreditResponseParams.txt b/example/EasyCredit/EasyCreditResponseParams.txt
new file mode 100755
index 0000000..e69de29
From e4e03703b573a1f5bd93b0a8c803b45b89c8c354 Mon Sep 17 00:00:00 2001
From: Simon Gabriel
Date: Thu, 6 Sep 2018 16:16:06 +0200
Subject: [PATCH 5/9] [change] (PHPLIB-41) Finish example.
---
example/EasyCredit.php | 48 +++++++++++---------
example/EasyCredit/EasyCreditReservation.php | 10 ++--
example/EasyCredit/EasyCreditResponse.php | 15 ++----
3 files changed, 38 insertions(+), 35 deletions(-)
diff --git a/example/EasyCredit.php b/example/EasyCredit.php
index e70b399..55fcad4 100755
--- a/example/EasyCredit.php
+++ b/example/EasyCredit.php
@@ -28,12 +28,17 @@
exit();
}
-
/**
* Require the composer autoloader file
*/
require_once __DIR__ . '/../vendor/autoload.php';
+if (!is_writable(__DIR__ . '/EasyCredit/EasyCreditResponseParams.txt')) {
+ echo 'EasyCredit example ';
+ echo 'File: ' . __DIR__ . '/EasyCredit/EasyCreditResponseParams.txt' . ' is not writable or does not exist. Please change permissions.';
+ exit;
+}
+
/**
* Load a new instance of the payment method
*/
@@ -51,6 +56,7 @@
'31HA07BC8179C95F6B59366492FD253D', // TransactionChannel credit card without 3d secure
true // Enable sandbox mode
);
+
/**
* Set up asynchronous request parameters
*/
@@ -60,30 +66,33 @@
HEIDELPAY_PHP_PAYMENT_API_FOLDER .
'EasyCredit/EasyCreditResponse.php' // Response url from your application
);
+
/**
* Set up customer information required for risk checks
*/
$easyCredit->getRequest()->customerAddress(
'Heidel', // Given name
- 'Berger-Payment', // Family name
- null, // Company Name
+ 'Berger-Payment', // Family name
+ null, // Company Name
'12344', // Customer id of your application
'Vagerowstr. 18', // Billing address street
'DE-BW', // Billing address state
'69115', // Billing address post code
'Heidelberg', // Billing address city
'DE', // Billing address country code
- 'support@heidelpay.com' // Customer mail address
+ 'support@heidelpay.com' // Customer mail address
);
+
/**
* Set up basket or transaction information
*/
$easyCredit->getRequest()->basketData(
- '2843294932', // Reference Id of your application
- 203.12, // Amount of this request
- 'EUR', // Currency code of this request
- '39542395235ßfsokkspreipsr' // A secret passphrase from your application
+ '2843294932', // Reference Id of your application
+ 203.12, // Amount of this request
+ 'EUR', // Currency code of this request
+ '39542395235ßfsokkspreipsr' // A secret passphrase from your application
);
+
/**
* Set up risk information.
*/
@@ -91,6 +100,7 @@
->setCustomerGuestCheckout('false')
->setCustomerOrderCount('23')
->setCustomerSince('2005-08-12');
+
/**
* Set necessary parameters for Heidelpay payment and send the request
*/
@@ -103,22 +113,18 @@
EasyCredit example';
$response = $easyCredit->getResponse();
if ($response->isSuccess()) {
- echo '';
- echo $response->getConfig()->getOptinText();
- echo'
Weiter zu easyCredit... ';
+ echo '';
} else {
echo ''. print_r($response->getError(), 1).' ';
}
?>
- It is not necessary to show the redirect url to your customer. You can
- use php header to forward your customer directly.
- For example:
- header('Location: '.$Invoice->getResponse()->getPaymentFromUrl());
-
-
-