Skip to content

Commit

Permalink
Started to add examples to Checkout API and fix the documentation to …
Browse files Browse the repository at this point in the history
…match the reality
  • Loading branch information
codedeviate committed Jul 11, 2024
1 parent a3610b5 commit 86d1515
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Writerside/hi.tree
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@
<toc-element topic="Magento.md"/>
</toc-element>
<toc-element topic="API-Interaction.md">
<toc-element topic="API-Interaction-PHP.md"/>
<toc-element topic="API-Interaction-PHP.md">
<toc-element topic="Get-info-on-non-activated-invoices.md"/>
</toc-element>
</toc-element>
</instance-profile>
4 changes: 3 additions & 1 deletion Writerside/topics/API-Interaction-PHP.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# PHP

Start typing here...
Here you will find examples of how to interact with the Qvickly APIs using PHP.

The examples are simple and could be used as a starting point for your own implementation.
43 changes: 43 additions & 0 deletions Writerside/topics/Get-info-on-non-activated-invoices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Get info on non-activated invoices

In this example we will authenticate against the Auth API, fetch a list of invoices from the Portal API and then use the Payment API to get more information about the invoices.

The invoices we are looking for are invoices that are created, but not yet activated. We will use the `status`, `search` and `invoiceType` filters to find the invoices we are looking for. The number of invoices we want to fetch is limited to 5.

<code-block lang="php">
<![CDATA[
<?php
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';
use Dotenv\Dotenv;
use Qvickly\Api\Auth\AuthAPI;
use Qvickly\Api\Portal\PortalAPI;
use Qvickly\Api\Payment\PaymentAPI;
$dotenv = Dotenv::createImmutable(__DIR__ . '/../..');
$dotenv->load();

$authAPI = new AuthAPI();
$auth = $authAPI->login($_ENV['USERNAME'], $_ENV['PASSWORD']);

$portalAPI = new PortalAPI($auth);

$paymentAPI = new PaymentAPI($_ENV['EID'], $_ENV['SECRET']);

$invoices = $portalAPI->get('invoices?filter=status,search,invoiceType&status=created&search=tess&invoicetype=F&limit=5');

echo "Found " . count($invoices) . " invoices to activate.\n";

foreach($invoices as $invoice) {
echo "Fetching invoice {$invoice['invoiceid_real']}...\n";
$payment = $paymentAPI->getPaymentInfo([ 'number' => $invoice['invoiceid_real']]);
echo json_encode($payment, JSON_PRETTY_PRINT) . "\n\n";
}
]]>
</code-block>

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

4 changes: 2 additions & 2 deletions Writerside/topics/initCheckout.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ credentials
data
function

#### checkoutdata
#### CheckoutData
| Property | Required | Type | Description |
|----------------------|----------|---------|-----------------------------------------------------------------------------------|
| terms | false | string | Url to the terms and conditions page for the store. |
Expand Down Expand Up @@ -107,7 +107,7 @@ function
"test": "true"
},
"data": {
"checkoutdata":{
"CheckoutData":{
"terms": "http://qvickly.io/terms",
"privacyPolicy": "http://qvickly.io/privacy-policy",
"companyview": "false",
Expand Down
9 changes: 7 additions & 2 deletions Writerside/topics/isPaid.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ return by echo JSON string.

{type="narrow"}
Endpoint
: /ajax.php?isPaid
: /public/ajax.php?isPaid

Method
: GET
: POST

## Request

| Property | Type | Description |
|----------|--------|-------------|

## Repsonse

Expand Down

0 comments on commit 86d1515

Please sign in to comment.