Skip to content

Commit

Permalink
Updated examples for CheckoutAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
codedeviate committed Jul 16, 2024
1 parent efb58c2 commit d59b4ce
Show file tree
Hide file tree
Showing 17 changed files with 697 additions and 7 deletions.
18 changes: 16 additions & 2 deletions Writerside/hi.tree
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<toc-element topic="Checkout-Functions.md">
<toc-element topic="initCheckout.md"/>
<toc-element topic="updateCheckout.md"/>
<toc-element topic="version.md"/>
<toc-element topic="reset.md"/>
<toc-element topic="isPaid.md"/>
<toc-element topic="checkoutStatus.md"/>
Expand Down Expand Up @@ -134,13 +135,26 @@
<toc-element topic="terms.md"/>
<toc-element topic="isRedirectedOnSuccess.md"/>
</toc-element>
<toc-element topic="CheckoutAPI-Examples.md">
<toc-element topic="Init-checkout.md"/>
<toc-element topic="Update-checkout.md"/>
<toc-element topic="getCheckoutVersion.md"/>
<toc-element topic="createCheckout.md"/>
<toc-element topic="setPersonalInformation.md"/>
<toc-element topic="CheckoutAPI-Example-updateShippingAddress.md"/>
<toc-element topic="CheckoutAPI-Example-updateBillingAddress.md"/>
<toc-element topic="CheckoutAPI-Example-getpaymentplans.md"/>
<toc-element topic="CheckoutAPI-Example-getPaymentMethods.md"/>
<toc-element topic="CheckoutAPI-Example-setPaymentMethod.md"/>
<toc-element topic="CheckoutAPI-Example-get.md"/>
<toc-element topic="CheckoutAPI-Example-validate.md"/>
<toc-element topic="CheckoutAPI-Example-confirm.md"/>
</toc-element>
<toc-element topic="Accept-URL.md"/>
<toc-element topic="Callback-URL.md"/>
<toc-element topic="Cancel-URL.md"/>
<toc-element topic="Example-flow.md"/>
<toc-element topic="Checkout-Examples.md">
<toc-element topic="Update-checkout.md"/>
<toc-element topic="Init-checkout.md"/>
</toc-element>
<toc-element topic="Javascript-events.md">
<toc-element topic="update.md"/>
Expand Down
67 changes: 67 additions & 0 deletions Writerside/topics/CheckoutAPI-Example-confirm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# confirm

<include from="Snippets-CheckoutAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?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);

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";
]]>
</code-block>

Full example can be found [here](https://github.com/Billmate/qvickly-php-module/blob/main/examples/CheckoutAPI/8-confirm.php)

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>
</tabs>

<include from="Snippets-Examples.md" element-id="snippet-footer"></include>
63 changes: 63 additions & 0 deletions Writerside/topics/CheckoutAPI-Example-get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# get

<include from="Snippets-CheckoutAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?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);

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 json_encode($get, JSON_PRETTY_PRINT) . "\n";

echo "URL to use: " . $paymentMethod['url'] . "\n";
]]>
</code-block>

Full example can be found [here](https://github.com/Billmate/qvickly-php-module/blob/main/examples/CheckoutAPI/6-get.php)

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>
</tabs>

<include from="Snippets-Examples.md" element-id="snippet-footer"></include>
58 changes: 58 additions & 0 deletions Writerside/topics/CheckoutAPI-Example-getPaymentMethods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# getPaymentMethods

<include from="Snippets-CheckoutAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?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);

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 json_encode($paymentMethods, JSON_PRETTY_PRINT) . "\n";

echo "URL to use: " . $checkout['url'] . "\n";
]]>
</code-block>

Full example can be found [here](https://github.com/Billmate/qvickly-php-module/blob/main/examples/CheckoutAPI/4-getPaymentMethods.php)

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>
</tabs>

<include from="Snippets-Examples.md" element-id="snippet-footer"></include>
55 changes: 55 additions & 0 deletions Writerside/topics/CheckoutAPI-Example-getpaymentplans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# getpaymentplans

<include from="Snippets-CheckoutAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?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);

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 json_encode($paymentplans, JSON_PRETTY_PRINT) . "\n";

echo "URL to use: " . $checkout['url'] . "\n";
]]>
</code-block>

Full example can be found [here](https://github.com/Billmate/qvickly-php-module/blob/main/examples/CheckoutAPI/3-getpaymentplans.php)

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>
</tabs>

<include from="Snippets-Examples.md" element-id="snippet-footer"></include>
61 changes: 61 additions & 0 deletions Writerside/topics/CheckoutAPI-Example-setPaymentMethod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# setPaymentMethod

<include from="Snippets-CheckoutAPI.md" element-id="snippet-header" />

<tabs>
<tab title="%code-php%">
<code-block lang="php">
<![CDATA[
<?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);

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 json_encode($paymentMethod, JSON_PRETTY_PRINT) . "\n";

echo "URL to use: " . $paymentMethod['url'] . "\n";
]]>
</code-block>

Full example can be found [here](https://github.com/Billmate/qvickly-php-module/blob/main/examples/CheckoutAPI/5-setPaymentMethod.php)

<include from="Snippets-PHP-Module.md" element-id="snippet-composer-require" />

</tab>
</tabs>

<include from="Snippets-Examples.md" element-id="snippet-footer"></include>
Loading

0 comments on commit d59b4ce

Please sign in to comment.