-
Notifications
You must be signed in to change notification settings - Fork 86
/
OrderCreate.php
123 lines (105 loc) · 3.82 KB
/
OrderCreate.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* OpenPayU Examples
*
* @copyright Copyright (c) PayU
* http://www.payu.com
* http://developers.payu.com
*/
require_once realpath(dirname(__FILE__)) . '/../../../lib/openpayu.php';
require_once realpath(dirname(__FILE__)) . '/../../config.php';
$order = array();
$order['notifyUrl'] = 'http://localhost'.dirname($_SERVER['REQUEST_URI']).'/OrderNotify.php';
$order['continueUrl'] = 'http://localhost'.dirname($_SERVER['REQUEST_URI']).'/../../layout/success.php';
$order['customerIp'] = '127.0.0.1';
$order['merchantPosId'] = OpenPayU_Configuration::getOauthClientId() ? OpenPayU_Configuration::getOauthClientId() : OpenPayU_Configuration::getMerchantPosId();
$order['description'] = 'New order';
$order['currencyCode'] = 'PLN';
$order['totalAmount'] = 3200;
$order['extOrderId'] = uniqid('', true);
$order['products'][0]['name'] = 'Product1';
$order['products'][0]['unitPrice'] = 1000;
$order['products'][0]['quantity'] = 1;
$order['products'][1]['name'] = 'Product2';
$order['products'][1]['unitPrice'] = 2200;
$order['products'][1]['quantity'] = 1;
$order['buyer']['email'] = 'test_buyer_email@payu.com';
$order['buyer']['phone'] = '123123123';
$order['buyer']['firstName'] = 'Jan';
$order['buyer']['lastName'] = 'Kowalski';
$order['buyer']['language'] = 'en';
/*~~~~~~~~ optional part DELIVERY data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//Add delivery informations
$order['buyer']['delivery']['recipientName'] = 'Robert Nowak';
$order['buyer']['delivery']['recipientEmail'] = 'test_buyer_email@payu.com';
$order['buyer']['delivery']['recipientPhone'] = '+48 456 123 789';
$order['buyer']['delivery']['street'] = 'Bar St. 155';
$order['buyer']['delivery']['postalBox'] = 'Warsaw';
$order['buyer']['delivery']['postalCode'] = '22-222';
$order['buyer']['delivery']['city'] = 'Warsaw';
$order['buyer']['delivery']['state'] = 'Masovian district';
$order['buyer']['delivery']['countryCode'] = 'PL';
?>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Create Order - OpenPayU v2</title>
<link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
<link rel="stylesheet" href="../../layout/css/style.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Create Order - OpenPayU v2</h1>
</div>
<?php try {
$response = OpenPayU_Order::create($order);
$status_desc = OpenPayU_Util::statusDesc($response->getStatus());
if ($response->getStatus() == 'SUCCESS') {
echo '<div class="alert alert-success">SUCCESS: ' . $status_desc;
echo '</div>';
} else {
echo '<div class="alert alert-warning">' . $response->getStatus() . ': ' . $status_desc;
echo '</div>';
}
} catch (OpenPayU_Exception $e) {
echo '<pre>';
var_dump((string)$e);
echo '</pre>';
}
?>
<h1>Request</h1>
<div id="unregisteredCardData">
<?php var_dump($order); ?>
</div>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th colspan="2">Important data from response</th>
</tr>
</thead>
<tbody>
<tr>
<td>Order status</td>
<td><?php echo $response->getStatus() ?></td>
</tr>
<?php if ($response->getStatus() == 'SUCCESS'): ?>
<tr>
<td>Order id</td>
<td><?php echo $response->getResponse()->orderId ?></td>
</tr>
<tr>
<td>Redirect Uri</td>
<td><a href="<?php echo $response->getResponse()->redirectUri ?>"><?php echo $response->getResponse()->redirectUri ?></a>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<h1>Response</h1>
<div id="unregisteredCardData">
<?php var_dump($response); ?>
</div>
</div>
</html>