Skip to content

Commit f071be7

Browse files
authored
feat(php): add PHP documentation and code samples (#5)
* feat(php): add PHP documentation and code samples * triv: add google and apple pay section * feat: add i18n files * feat: add work_flow distpach event for deploys * triv: add custom branch to allowed deploys * feat: translate all pages to sk * feat: update php docs after refactor
1 parent 3b1fedc commit f071be7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3394
-11
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Review gh actions docs if you want to further define triggers, paths, etc
88
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
99

10+
1011
jobs:
1112
build:
1213
name: Build Docusaurus
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment
9+
10+
$response = $tatrapayplus_api->cancelPaymentIntent($payment_id);
11+
$response["response"]->getStatusCode(); // 200 or 201 = success
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
use Tatrapayplus\TatrapayplusApiClient\Model\CardPayUpdateInstruction;
4+
5+
$tatrapayplus_api = new TatraPayPlusAPIApi(
6+
"your-client-id",
7+
"your-client-secret",
8+
);
9+
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment
10+
$chargeback_data = new CardPayUpdateInstruction([
11+
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CHARGEBACK,
12+
"amount" => 3.0,
13+
]);
14+
15+
$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $chargeback_data);
16+
$response["response"]->getStatusCode(); // 200 or 201 = success
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
use Tatrapayplus\TatrapayplusApiClient\Model\CardPayUpdateInstruction;
4+
5+
$tatrapayplus_api = new TatraPayPlusAPIApi(
6+
"your-client-id",
7+
"your-client-secret",
8+
);
9+
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment
10+
11+
$pre_authorization_data = new CardPayUpdateInstruction([
12+
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CANCEL_PRE_AUTHORIZATION,
13+
]);
14+
$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $pre_authorization_data);
15+
16+
// or
17+
18+
$pre_authorization_data = new CardPayUpdateInstruction([
19+
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CONFIRM_PRE_AUTHORIZATION,
20+
]);
21+
$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $pre_authorization_data);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
9+
$address = new Tatrapayplus\TatrapayplusApiClient\Model\Address([
10+
"street_name" => "TestStreet",
11+
"building_number" => "12",
12+
"town_name" => "Town",
13+
"post_code" => "97405",
14+
"country" => "SK",
15+
]);
16+
$initiate_payment_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiatePaymentRequest([
17+
"base_payment" => new Tatrapayplus\TatrapayplusApiClient\Model\BasePayment([
18+
"instructed_amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
19+
"amount_value" => 10.0,
20+
"currency" => "EUR",
21+
]),
22+
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
23+
"variable_symbol" => "ORDER123456",
24+
]),
25+
]),
26+
"bank_transfer" => new Tatrapayplus\TatrapayplusApiClient\Model\BankTransfer(),
27+
"user_data" => new Tatrapayplus\TatrapayplusApiClient\Model\UserData([
28+
"first_name" => "Janko",
29+
"last_name" => "Hrasko",
30+
"email" => "janko.hrasko@example.com",
31+
]),
32+
"card_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\CardDetail([
33+
"card_holder" => "Janko Hrasko",
34+
"billing_address" => $address,
35+
"shipping_address" => $address,
36+
]),
37+
"pay_later" => new Tatrapayplus\TatrapayplusApiClient\Model\PayLater([
38+
"order" => new Tatrapayplus\TatrapayplusApiClient\Model\Order([
39+
"order_no" => "ORDER123456",
40+
"order_items" => [
41+
new Tatrapayplus\TatrapayplusApiClient\Model\OrderItem([
42+
"quantity" => 1.0,
43+
"total_item_price" => 10.0,
44+
"item_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetail([
45+
"item_detail_en" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetailLangUnit([
46+
"item_name" => "Product 1",
47+
]),
48+
"item_detail_sk" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetailLangUnit([
49+
"item_name" => "Produkt 1",
50+
]),
51+
]),
52+
]),
53+
],
54+
]),
55+
]),
56+
]);
57+
58+
$response = $tatrapayplus_api->initiatePayment(
59+
"redirect uri",
60+
$initiate_payment_request,
61+
);
62+
$response["object"]->getPaymentId(); // newly created payment ID
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
9+
$initiate_transaction_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiateDirectTransactionRequest([
10+
"amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
11+
"amount_value" => 10,
12+
"currency" => "EUR",
13+
]),
14+
"is_pre_authorization" => true,
15+
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
16+
"variable_symbol" => "123",
17+
]),
18+
"tds_data" => new Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionTDSData([
19+
"card_holder" => "Janko Hraško",
20+
"email" => "janko.hrasko@example.com",
21+
]),
22+
"ipsp_data" => new Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData([
23+
"sub_merchant_id" => "12345",
24+
"name" => "Test 123",
25+
"location" => "Test 123",
26+
"country" => "SK",
27+
]),
28+
"token" => new Tatrapayplus\TatrapayplusApiClient\Model\Token([
29+
"google_pay_token" => "ABC12345"
30+
]),
31+
]);
32+
33+
$response = $tatrapayplus_api->initiateDirectTransaction(
34+
"redirect uri",
35+
$initiate_transaction_request,
36+
);
37+
38+
$response["object"]->getPaymentId(); // newly created payment ID
39+
$response["object"]->getRedirectFormHtml(); // HTML form
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
9+
$initiate_payment_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiatePaymentRequest([
10+
"base_payment" => new Tatrapayplus\TatrapayplusApiClient\Model\BasePayment([
11+
"instructed_amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
12+
"amount_value" => 10.0,
13+
"currency" => "EUR",
14+
]),
15+
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
16+
"variable_symbol" => "ORDER123456",
17+
]),
18+
]),
19+
"bank_transfer" => new Tatrapayplus\TatrapayplusApiClient\Model\BankTransfer(),
20+
"card_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\CardDetail([
21+
"card_holder" => "Janko Hrasko",
22+
"is_pre_authorization" => true,
23+
]),
24+
]);
25+
26+
$response = $tatrapayplus_api->initiatePayment(
27+
"redirect uri",
28+
$initiate_payment_request,
29+
);
30+
$response["object"]->getPaymentId();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
9+
$available_methods = $tatrapayplus_api->getAvailableMethods(
10+
total_amount: 100,
11+
currency: "EUR",
12+
country: "SK"
13+
);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
4+
$tatrapayplus_api = new TatraPayPlusAPIApi(
5+
"your-client-id",
6+
"your-client-secret",
7+
);
8+
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment
9+
10+
[$simple_status, $response] = $tatrapayplus_api->getPaymentIntentStatus($payment_id);
11+
12+
$response_obj = $response['object'];
13+
$status = $response_obj->getStatus();
14+
$payment_method = $response_obj->getSelectedPaymentMethod();
15+
$authorization_status = $response_obj->getAuthorizationStatus();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
3+
use Tatrapayplus\TatrapayplusApiClient\Model\AppearanceRequest;
4+
use Tatrapayplus\TatrapayplusApiClient\Model\ColorAttribute;
5+
6+
$tatrapayplus_api = new TatraPayPlusAPIApi(
7+
"your-client-id",
8+
"your-client-secret",
9+
);
10+
$appearance_request = new AppearanceRequest([
11+
"theme" => AppearanceRequest::THEME_SYSTEM,
12+
"tint_on_accent" => new ColorAttribute([
13+
"color_dark_mode" => "#fff",
14+
"color_light_mode" => "#fff",
15+
]),
16+
"tint_accent" => new ColorAttribute([
17+
"color_dark_mode" => "#fff",
18+
"color_light_mode" => "#fff",
19+
]),
20+
"surface_accent" => new ColorAttribute([
21+
"color_dark_mode" => "#fff",
22+
"color_light_mode" => "#fff",
23+
]),
24+
]);
25+
26+
$response = $tatrapayplus_api->setAppearance($appearance_request);

0 commit comments

Comments
 (0)