-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-test-ingenico-approve.php
45 lines (32 loc) · 1.78 KB
/
03-test-ingenico-approve.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
<?php
use Ingenico\Connect\Sdk\Client as ClientAlias;
use Ingenico\Connect\Sdk\Communicator as CommunicatorAlias;
use Ingenico\Connect\Sdk\CommunicatorConfiguration as CommunicatorConfigurationAlias;
use Ingenico\Connect\Sdk\DefaultConnection as DefaultConnectionAlias;
use Ingenico\Connect\Sdk\Domain\Hostedcheckout\CreateHostedCheckoutRequest;
use Ingenico\Connect\Sdk\Domain\Payment\Definitions\Order as OrderAlias;
require_once 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$logFile = fopen('hosted-checkout-test.log','a');
$communicatorConfiguration =
new CommunicatorConfigurationAlias(
$_ENV['API_KEY'], $_ENV['API_SECRET'], 'https://eu.sandbox.api-ingenico.com', 'GSped'
);
$connection = new DefaultConnectionAlias();
$communicator = new CommunicatorAlias($connection, $communicatorConfiguration);
$client = new ClientAlias($communicator);
$client->setClientMetaInfo(json_encode(['msg'=>"consumer specific JSON meta info"]));
$client->enableLogging(new \Ingenico\Connect\Sdk\ResourceLogger($logFile));
$references = new \Ingenico\Connect\Sdk\Domain\Payment\Definitions\OrderReferencesApprovePayment();
$references->merchantReference = "XXX";
$order = new \Ingenico\Connect\Sdk\Domain\Payment\Definitions\OrderApprovePayment();
$order->references = $references;
$body = new \Ingenico\Connect\Sdk\Domain\Payment\ApprovePaymentRequest();
$body->directDebitPaymentMethodSpecificInput = new
\Ingenico\Connect\Sdk\Domain\Payment\Definitions\ApprovePaymentDirectDebitPaymentMethodSpecificInput();
$body->directDebitPaymentMethodSpecificInput->dateCollect = \Carbon\Carbon::now()->format('Ymd');
$body->order = $order;
$body->amount = 3500;
$response = $client->merchant("1221")->payments()->approve($argv[1], $body);
var_dump($response->toJson());