Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on


jobs:
build:
name: Build Docusaurus
Expand Down
11 changes: 11 additions & 0 deletions code_samples/php/v1.0.0/cancel_payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment

$response = $tatrapayplus_api->cancelPaymentIntent($payment_id);
$response["response"]->getStatusCode(); // 200 or 201 = success
16 changes: 16 additions & 0 deletions code_samples/php/v1.0.0/chargeback.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
use Tatrapayplus\TatrapayplusApiClient\Model\CardPayUpdateInstruction;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment
$chargeback_data = new CardPayUpdateInstruction([
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CHARGEBACK,
"amount" => 3.0,
]);

$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $chargeback_data);
$response["response"]->getStatusCode(); // 200 or 201 = success
21 changes: 21 additions & 0 deletions code_samples/php/v1.0.0/confirm_cancel_pre_authorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
use Tatrapayplus\TatrapayplusApiClient\Model\CardPayUpdateInstruction;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment

$pre_authorization_data = new CardPayUpdateInstruction([
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CANCEL_PRE_AUTHORIZATION,
]);
$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $pre_authorization_data);

// or

$pre_authorization_data = new CardPayUpdateInstruction([
"operation_type" => CardPayUpdateInstruction::OPERATION_TYPE_CONFIRM_PRE_AUTHORIZATION,
]);
$response = $tatrapayplus_api->updatePaymentIntent($payment_id, $pre_authorization_data);
62 changes: 62 additions & 0 deletions code_samples/php/v1.0.0/create_payment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);

$address = new Tatrapayplus\TatrapayplusApiClient\Model\Address([
"street_name" => "TestStreet",
"building_number" => "12",
"town_name" => "Town",
"post_code" => "97405",
"country" => "SK",
]);
$initiate_payment_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiatePaymentRequest([
"base_payment" => new Tatrapayplus\TatrapayplusApiClient\Model\BasePayment([
"instructed_amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
"amount_value" => 10.0,
"currency" => "EUR",
]),
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
"variable_symbol" => "ORDER123456",
]),
]),
"bank_transfer" => new Tatrapayplus\TatrapayplusApiClient\Model\BankTransfer(),
"user_data" => new Tatrapayplus\TatrapayplusApiClient\Model\UserData([
"first_name" => "Janko",
"last_name" => "Hrasko",
"email" => "janko.hrasko@example.com",
]),
"card_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\CardDetail([
"card_holder" => "Janko Hrasko",
"billing_address" => $address,
"shipping_address" => $address,
]),
"pay_later" => new Tatrapayplus\TatrapayplusApiClient\Model\PayLater([
"order" => new Tatrapayplus\TatrapayplusApiClient\Model\Order([
"order_no" => "ORDER123456",
"order_items" => [
new Tatrapayplus\TatrapayplusApiClient\Model\OrderItem([
"quantity" => 1.0,
"total_item_price" => 10.0,
"item_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetail([
"item_detail_en" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetailLangUnit([
"item_name" => "Product 1",
]),
"item_detail_sk" => new Tatrapayplus\TatrapayplusApiClient\Model\ItemDetailLangUnit([
"item_name" => "Produkt 1",
]),
]),
]),
],
]),
]),
]);

$response = $tatrapayplus_api->initiatePayment(
"redirect uri",
$initiate_payment_request,
);
$response["object"]->getPaymentId(); // newly created payment ID
39 changes: 39 additions & 0 deletions code_samples/php/v1.0.0/create_payment_direct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);

$initiate_transaction_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiateDirectTransactionRequest([
"amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
"amount_value" => 10,
"currency" => "EUR",
]),
"is_pre_authorization" => true,
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
"variable_symbol" => "123",
]),
"tds_data" => new Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionTDSData([
"card_holder" => "Janko Hraško",
"email" => "janko.hrasko@example.com",
]),
"ipsp_data" => new Tatrapayplus\TatrapayplusApiClient\Model\DirectTransactionIPSPData([
"sub_merchant_id" => "12345",
"name" => "Test 123",
"location" => "Test 123",
"country" => "SK",
]),
"token" => new Tatrapayplus\TatrapayplusApiClient\Model\Token([
"google_pay_token" => "ABC12345"
]),
]);

$response = $tatrapayplus_api->initiateDirectTransaction(
"redirect uri",
$initiate_transaction_request,
);

$response["object"]->getPaymentId(); // newly created payment ID
$response["object"]->getRedirectFormHtml(); // HTML form
30 changes: 30 additions & 0 deletions code_samples/php/v1.0.0/create_payment_pre_authorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);

$initiate_payment_request = new Tatrapayplus\TatrapayplusApiClient\Model\InitiatePaymentRequest([
"base_payment" => new Tatrapayplus\TatrapayplusApiClient\Model\BasePayment([
"instructed_amount" => new Tatrapayplus\TatrapayplusApiClient\Model\Amount([
"amount_value" => 10.0,
"currency" => "EUR",
]),
"end_to_end" => new Tatrapayplus\TatrapayplusApiClient\Model\E2e([
"variable_symbol" => "ORDER123456",
]),
]),
"bank_transfer" => new Tatrapayplus\TatrapayplusApiClient\Model\BankTransfer(),
"card_detail" => new Tatrapayplus\TatrapayplusApiClient\Model\CardDetail([
"card_holder" => "Janko Hrasko",
"is_pre_authorization" => true,
]),
]);

$response = $tatrapayplus_api->initiatePayment(
"redirect uri",
$initiate_payment_request,
);
$response["object"]->getPaymentId();
13 changes: 13 additions & 0 deletions code_samples/php/v1.0.0/get_available_payment_methods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);

$available_methods = $tatrapayplus_api->getAvailableMethods(
total_amount: 100,
currency: "EUR",
country: "SK"
);
15 changes: 15 additions & 0 deletions code_samples/php/v1.0.0/get_payment_status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$payment_id = 'b54afd37-5bb9-4080-9416-5ec450779087'; // Retrieved from initiatePayment

[$simple_status, $response] = $tatrapayplus_api->getPaymentIntentStatus($payment_id);

$response_obj = $response['object'];
$status = $response_obj->getStatus();
$payment_method = $response_obj->getSelectedPaymentMethod();
$authorization_status = $response_obj->getAuthorizationStatus();
26 changes: 26 additions & 0 deletions code_samples/php/v1.0.0/set_colors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
use Tatrapayplus\TatrapayplusApiClient\Model\AppearanceRequest;
use Tatrapayplus\TatrapayplusApiClient\Model\ColorAttribute;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$appearance_request = new AppearanceRequest([
"theme" => AppearanceRequest::THEME_SYSTEM,
"tint_on_accent" => new ColorAttribute([
"color_dark_mode" => "#fff",
"color_light_mode" => "#fff",
]),
"tint_accent" => new ColorAttribute([
"color_dark_mode" => "#fff",
"color_light_mode" => "#fff",
]),
"surface_accent" => new ColorAttribute([
"color_dark_mode" => "#fff",
"color_light_mode" => "#fff",
]),
]);

$response = $tatrapayplus_api->setAppearance($appearance_request);
13 changes: 13 additions & 0 deletions code_samples/php/v1.0.0/set_logo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
use Tatrapayplus\TatrapayplusApiClient\Api\TatraPayPlusAPIApi;
use Tatrapayplus\TatrapayplusApiClient\Model\AppearanceLogoRequest;

$tatrapayplus_api = new TatraPayPlusAPIApi(
"your-client-id",
"your-client-secret",
);
$logo_request = new AppearanceLogoRequest([
"logo_image" => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII",
]);

$response = $tatrapayplus_api->setLogo($logo_request);
34 changes: 34 additions & 0 deletions docs/libraries/php/v1.0.0/appearances.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import CodeBlock from '@theme/CodeBlock';

# Gateway appearances

Payment gateway can have custom colors and logo.

![Color guide](@site/docs/assets/color_guide_en.png)

:::warning

Gateway appearances can be change only in **PRODUCTION** mode.

:::

## Logo

import setLogo from '!!raw-loader!@site/code_samples/php/v1.0.0/set_logo.php';

<CodeBlock language="php">{setLogo}</CodeBlock>

## Colors

import setColors from '!!raw-loader!@site/code_samples/php/v1.0.0/set_colors.php';

<CodeBlock language="php">{setColors}</CodeBlock>


:::tip

Changes are reflected only in **new payments**. Refresh of page is not sufficient.

:::

<Button label="See full API reference" link="/docs/api/set-appearance"/>
19 changes: 19 additions & 0 deletions docs/libraries/php/v1.0.0/available_methods.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Button from '@site/src/components/Button';
import CodeBlock from '@theme/CodeBlock';
import getAvailablePaymentMethods from '!!raw-loader!@site/code_samples/php/v1.0.0/get_available_payment_methods.php';

# Getting available methods

In this payment gateway, user will select preferred payment option directly in payment gateway and **NOT in eshop**.
Therefor you want to inform customer about available payment methods and show different text or image based on certain conditions like:
- currency
- total amount
- country

For this purpose you can retrieve available payment methods with this helper:
<CodeBlock language="php">{getAvailablePaymentMethods}</CodeBlock>

Based on response from these functions you should display info to the user about available methods,
and then you should create payment.

<Button label="See full API reference" link="/docs/api/get-methods"/>
13 changes: 13 additions & 0 deletions docs/libraries/php/v1.0.0/cancel_payment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CodeBlock from '@theme/CodeBlock';

# Cancel payment

This operation can be used with any payment method, but only if it is in `authorization_status=NEW`.

In the case of payment method `PAY_LATER`, this method can also be used if `authorization_status=AUTH_DONE` and at the same time payment `status=CUSTOMER_CREATION_IN_PROGRESS`.

import cancelPayment from '!!raw-loader!@site/code_samples/php/v1.0.0/cancel_payment.php';

<CodeBlock language="php">{cancelPayment}</CodeBlock>

<Button label="See full API reference" link="/docs/api/cancel-payment-intent"/>
13 changes: 13 additions & 0 deletions docs/libraries/php/v1.0.0/chargeback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import CodeBlock from '@theme/CodeBlock';

# Chargeback

The merchant can also make a full or partial return of the transaction through CardPay.
Returns can only be made on successful payments, including completed pre-authorisations, as well as on payments on which a return has already been made, and the amount of the return must not exceed the original amount of the payment (in the case of a pre-authorisation, it is the amount with which the pre-authorisation was confirmed).


import chargeBack from '!!raw-loader!@site/code_samples/php/v1.0.0/chargeback.php';

<CodeBlock language="php">{chargeBack}</CodeBlock>

<Button label="See full API reference" link="/docs/api/cancel-payment-intent"/>
Loading