This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from heidelpay/develop
release v2.0.0
- Loading branch information
Showing
27 changed files
with
712 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,3 @@ | |
<script type="text/javascript" src="./js/creditCardFrame.js"></script> | ||
</body> | ||
</html> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
/** | ||
* This example shows an example implementation for the eps payment type WITHOUT bank selection in the shop | ||
* but with redirect to the eps page providing the selection there. | ||
* | ||
* @license Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
* @copyright Copyright © 2019-present heidelpay GmbH. All rights reserved. | ||
* | ||
* @link http://dev.heidelpay.com/heidelpay-php-payment-api/ | ||
* | ||
* @author Simon Gabriel | ||
* | ||
* @category example | ||
*/ | ||
namespace Heidelpay\Example\PhpPaymentApi; | ||
|
||
/** | ||
* For security reason all examples are disabled by default. | ||
*/ | ||
use Heidelpay\PhpPaymentApi\PaymentMethods\EPSPaymentMethod; | ||
|
||
require_once './_enableExamples.php'; | ||
if (defined('HEIDELPAY_PHP_PAYMENT_API_EXAMPLES') && HEIDELPAY_PHP_PAYMENT_API_EXAMPLES !== true) { | ||
exit(); | ||
} | ||
|
||
/** Require the composer autoloader file */ | ||
require_once __DIR__ . '/../../../autoload.php'; | ||
|
||
/** create a new instance of the payment method */ | ||
$eps = new EPSPaymentMethod(); | ||
$epsRequest = $eps->getRequest(); | ||
|
||
/** | ||
* Set up your authentication data for heidelpay api | ||
* | ||
* @link https://dev.heidelpay.com/testumgebung/#Authentifizierungsdaten | ||
*/ | ||
$epsRequest->authentification( | ||
'31HA07BC8142C5A171745D00AD63D182', // SecuritySender | ||
'31ha07bc8142c5a171744e5aef11ffd3', // UserLogin | ||
'93167DE7', // UserPassword | ||
'31HA07BC816492169CE30CFBBF83B1D5', // TransactionChannel | ||
true // enable/disable sandbox mode | ||
); | ||
|
||
$epsRequest->getFrontend()->setResponseUrl('http://technik.heidelpay.de/jonas/responseAdvanced/response.php'); | ||
|
||
// set up customer information required for risk checks | ||
$epsRequest->customerAddress( | ||
'Hans', // Given name | ||
'Zimmer', // Family name | ||
null, // Company Name | ||
'12344', // Customer id of your application | ||
'Salzachstraße 13', // Billing address street | ||
'', | ||
'1200', // Billing address post code | ||
'Wien', // Billing address city | ||
'AT', // Billing address country code | ||
'support@heidelpay.com' // Customer mail address | ||
); | ||
|
||
// set up basket or transaction information | ||
$epsRequest->basketData( | ||
'2843294932', // Reference Id of your application | ||
23.12, // Amount of this request | ||
'EUR', // Currency code of this request | ||
'39542395235ßfsokkspreipsr' // A secret passphrase from your application | ||
); | ||
|
||
// set bank country | ||
$epsRequest->getAccount()->setCountry('AT'); | ||
|
||
// disable frontend mode -> this shows that there is no additional input necessary by the customer prior to the redirect to the eps page. | ||
$epsRequest->getFrontend()->setEnabled('FALSE'); | ||
|
||
// perform the authorize transaction to retrieve the redirect url and parameters | ||
$eps->authorize(); | ||
|
||
// get the redirect url and necessary parameters from the response. | ||
$redirectGroup = $eps->getResponse()->getProcessing()->getRedirect(); | ||
$redirectUrl = $redirectGroup->getUrl(); | ||
$redirectParams = $redirectGroup->getParameter(); | ||
|
||
echo '<strong>RedirectUrl:</strong> ' . $redirectUrl; | ||
ksort($redirectParams); | ||
foreach($redirectParams as $key=>$value) { | ||
echo '<br><strong>RedirectParam</strong> ' . $key . ': ' . $value; | ||
} | ||
|
||
/** | ||
* Attention: | ||
* Unfortunately Sandbox-mode and Live-mode have to be handled differently. | ||
* In case of .. | ||
* 1. .. a sandbox transaction no redirect parameters exist and you have to perform a GET-Redirect to the redirect url. | ||
* 2. .. a live mode transaction there will be redirect parameters and you have to submit them via POST-request to the redirect url. | ||
* | ||
* The following example shows one possible solution to this task. | ||
*/ | ||
?> | ||
|
||
<html> | ||
<head> | ||
<title>EPS authorize example</title> | ||
</head> | ||
|
||
<body> | ||
<!-- create a form which contains any parameters needed for the redirect --> | ||
<form id="payment-form" action="<?php echo $redirectUrl; ?>" method="post"> | ||
<?php | ||
foreach ($redirectParams as $key=>$param) { | ||
echo '<input hidden="true" name="' . $key . '" value="'. $param . '"/>'; | ||
} | ||
?> | ||
<button type="submit">Pay</button> | ||
</form> | ||
|
||
<script> | ||
var form = document.getElementById('payment-form'); | ||
form.addEventListener('submit', function(event) { | ||
event.preventDefault(); | ||
|
||
// get the number ob redirect parameters | ||
var redirectParameterCount = form.getElementsByTagName('input').length; | ||
if (redirectParameterCount === 0) { | ||
// ... perform a get redirect if there are no parameters needed for the redirect ==> Sandbox mode | ||
window.location.href = form.getAttribute('action'); | ||
} else { | ||
// ... submit the form via post with all redirect parameters ==> Live mode | ||
form.submit(); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.