forked from ekyna/PayumMonetico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
66 lines (56 loc) · 1.65 KB
/
test.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
<?php
/*
* Use this script to test your credentials.
* 'php -S localhost:8000' to start a web server.
*/
require __DIR__ . '/bootstrap.php';
use Ekyna\Component\Payum\Monetico\MoneticoGatewayFactory;
use Ekyna\Component\Payum\Monetico\Request\PaymentForm;
use League\Uri\Http;
use Payum\Core\Model\Payment;
use Payum\Core\PayumBuilder;
use Payum\Core\Reply\HttpResponse;
$paymentClass = Payment::class;
$defaultConfig = [
'mode' => '',
'tpe' => '',
'key' => '',
'company' => '',
'debug' => true,
];
/** @var \Payum\Core\Payum $payum */
$payum = (new PayumBuilder())
->addDefaultStorages()
->addGatewayFactory('monetico', new MoneticoGatewayFactory($defaultConfig))
->addGateway('monetico', [
'factory' => 'monetico',
'sandbox' => true,
])
->getPayum();
/** @var \Payum\Core\Gateway $gateway */
$gateway = $payum->getGateway('monetico');
$uri = Http::createFromServer($_SERVER);
$request = new PaymentForm([
'date' => '25/08/2019:16:30:15',
'amount' => '24.80',
'currency' => 'EUR',
'reference' => '100008784',
'comment' => 'Commande 100008784',
'locale' => 'FR',
'email' => 'test@example.org',
'success_url' => (string)$uri->withPath('/done.php'),
'failure_url' => (string)$uri->withPath('/done.php'),
'context' => [
'billing' => [
"addressLine1" => "101 Rue de Roisel",
"city" => "Y",
"postalCode" => "80190",
"country" => "FR",
],
],
]);
try {
$gateway->execute($request);
} catch (HttpResponse $response) {
echo $response->getContent();
}