-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8-confirm.php
More file actions
51 lines (36 loc) · 1.4 KB
/
8-confirm.php
File metadata and controls
51 lines (36 loc) · 1.4 KB
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
<?php
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();
use Qvickly\Api\Checkout\CheckoutAPI;
use function Qvickly\Api\Payment\Helpers\exampleCheckout;
use Qvickly\Api\Enums\PaymentMethod;
$checkoutAPI = new CheckoutAPI($_ENV['EID'], $_ENV['SECRET'], true, [
// 'BASE_URL' => 'https://api.development.billmate.se/',
// 'CHECKOUT_BASE_URL' => 'https://checkout.development.billmate.se/',
]);
echo "Create checkout\n";
$payload = exampleCheckout();
$checkout = $checkoutAPI->initCheckout($payload);
echo "Step 1\n";
$personalInfo = $checkoutAPI->step1($checkout['hash'], [
'pno' => $_ENV['PNO'],
'email' => $_ENV['EMAIL'],
'type' => 'person',
'zip' => $_ENV['ZIP'],
'phonenumber' => $_ENV['PHONENUMBER'],
]);
echo "Payment plans\n";
$paymentplans = $checkoutAPI->getpaymentplans($checkout['hash']);
echo "Payment methods\n";
$paymentMethods = $checkoutAPI->getPaymentMethods($checkout['hash']);
echo "Update payment method\n";
$paymentMethod = $checkoutAPI->updatePaymentMethod($checkout['hash'], PaymentMethod::CARD->value);
echo "Get payment\n";
$get = $checkoutAPI->get($checkout['hash']);
echo "Confirm payment\n";
$confirm = $checkoutAPI->confirm($checkout['hash'], $get);
echo json_encode($confirm, JSON_PRETTY_PRINT) . "\n";
echo "URL to use: " . $confirm['url'] . "\n";