-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgeneratepaymentform.php
107 lines (98 loc) · 5.87 KB
/
generatepaymentform.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?
/*
========================================================================================
========================================================================================
====== This PHP code provides a payment form for the Adyen Hosted Payment Pages ========
====== Version 0.3 ========
========================================================================================
========================================================================================
*/
/* ========================================================================================
================================== account details ===================================
========================================================================================
$skinCode
The skin to be used
$merchantAccount
The merchant account we want to process this payment with.
$sharedSecret
The shared HMAC key.
*/
$skinCode = "3fP3PsJA";
$merchantAccount = "MyMerchantAccount";
$sharedSecret = "testKeyx"; // shared HMAC secret for TEST environment
// $sharedSecret = "liveKeyx"; // shared HMAC secret for LIVE environment
/* ========================================================================================
=========================== payment-specific details ============================
========================================================================================
$merchantReference
This reference will be used in all communication to you about the status of the payment.
$paymentAmmount
The payment amount is specified in minor units.
$currencyCode
The currency in which the payment is processed.
$shipBefore
The date by which the goods or services specified in order must be shipped or rendered.
$orderDataRaw
Order Data is a fragment of HTML which will be displayed to the customer on a
'review payment' page just before final confirmation of the payment
$sessionValidity
The final time by which a payment needs to have been made.
$shopperReference
The unique reference to this (registered?) shopper
$shopperEmail
The email of the shopper
*/
$merchantReference = "TestOrder12345"; // The transaction reference you assign to the payment
$paymentAmount = 10000; // Amount in minor units (10000 for 100.00 EUR)
$currencyCode = "EUR"; // 3 Digit ISO Currency Code (e.g. GBP, USD)
$shipBeforeDate = date("Y-m-d" , mktime(date("H"), date("i"), date("s"), date("m"), date("j")+5, date("Y"))); // example: ship in 5 days
$shopperLocale = "en_GB"; // Locale (language) to present to shopper (e.g. en_US, nl, fr, fr_BE)
$orderDataRaw = "<b>1 <i>iPod</i> MP3 Player</b>"; // A description of the payment which is displayed to shoppers
$sessionValidity = date(DATE_ATOM , mktime(date("H")+1, date("i"), date("s"), date("m"), date("j"), date("Y"))); // example: shopper has one hour to complete
$shopperReference = "shopper123"; // the shopper id in our system
$shopperEmail = "[email protected]"; // the shopper's email address
/* ========================================================================================
================================== process fields ====================================
========================================================================================
$merchantSig
The signature in Base64 encoded format. The is generated by concatenating the values of above fields and computing HMAC over this using the shared secret
(the shared secret is configured in the Skin in the Adyen test backoffice)
$orderData
The $orderDataRaw which is GZIP compressed and base64 encoded
*/
//GZIP and base64 encode the orderData
$orderData = base64_encode(gzencode($orderDataRaw));
// concatenate all the data needed to calculate the HMAC-string in the correct order
// (please refer to Appendix B in the Integration Manual for more details)
$hmacData = $paymentAmount . $currencyCode . $shipBeforeDate . $merchantReference . $skinCode
. $merchantAccount . $sessionValidity . $shopperEmail . $shopperReference;
// base64 encode the binary result of the HMAC computation. If you use a PHP version < 5.0.12 you
// you may need to use a different HMAC implementation. Please refer to "Computing the HMAC in PHP"
// example from the downloads section on https://support.adyen.com/
$merchantSig = base64_encode(hash_hmac('sha1',$hmacData,$sharedSecret,true));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Adyen Payment</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<form name="adyenForm" action="https://test.adyen.com/hpp/pay.shtml" method="post">
<input type="hidden" name="merchantReference" value="<?=$merchantReference?>" />
<input type="hidden" name="paymentAmount" value="<?=$paymentAmount?>" />
<input type="hidden" name="currencyCode" value="<?=$currencyCode?>" />
<input type="hidden" name="shipBeforeDate" value="<?=$shipBeforeDate?>" />
<input type="hidden" name="skinCode" value="<?=$skinCode?>" />
<input type="hidden" name="merchantAccount" value="<?=$merchantAccount?>" />
<input type="hidden" name="shopperLocale" value="<?=$shopperLocale?>" />
<input type="hidden" name="orderData" value="<?=$orderData?>" />
<input type="hidden" name="sessionValidity" value="<?=$sessionValidity?>" />
<input type="hidden" name="merchantSig" value="<?=$merchantSig?>" />
<input type="hidden" name="shopperEmail" value="<?=$shopperEmail?>" />
<input type="hidden" name="shopperReference" value="<?=$shopperReference?>" />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</form>