└── PHP-sample-code-PT2
├── Follow-up-transaction
├── Capture.php
├── Refund.php
├── Void.php
└── query-transaction.php
├── Hosted-payment-page
├── Create-Payment-Page-HostedPaymentPage.php
├── Create-payment-page-Tokenization-optional.php
├── Create-payment-page-Tokenization.php
└── create-payment-page-HostedPaymentPage-framed.php
├── Invoice
├── Cancel-invoice-Post.php
├── Cancel-invoice-Put.php
├── Create-invoice-with-token.php
├── Create-invoice.php
├── Get-invoice-status-with-Post.php
└── Get-invoice-status.php
├── Managed-Form - Payment-Request
├── Create-managed-Form-Payment-Request.php
└── Send-managed-form.php
├── Own-Form - Payment Request
└── Create-Own-Form - Payment-Request.php
├── Paytabs-plugin.php
├── Result.php
├── Token-based-transaction
├── Create-payment-with-token.php
├── Delete-token.php
└── query-token.php
└── Wallet-payments
├── Apple-pay.php
└── Samsung-pay.php
/PHP-sample-code-PT2/Follow-up-transaction/Capture.php:
--------------------------------------------------------------------------------
1 | "capture",
8 | "tran_class" => "ecom",
9 | "cart_id" => "cart_66666",
10 | "cart_currency" => "EGP",
11 | "cart_amount" => 130,
12 | "cart_description" => "shopping Cart",
13 | "tran_ref" => "TST2105400087083" //the Auth tran_ref you want to capture it
14 | ];
15 | $page = $plugin->send_api_request($request_url, $data);
16 | print_r($page);
17 | exit();
18 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Follow-up-transaction/Refund.php:
--------------------------------------------------------------------------------
1 | "refund",
8 | "tran_class" => "ecom",
9 | "cart_id" => "cart_66666",
10 | "cart_currency" => "EGP",
11 | "cart_amount" => 130,
12 | "cart_description" => "shopping Cart",
13 | "tran_ref" => "TST2105600089368" //the Capture tran_ref you want to refund it
14 | ];
15 | $page = $plugin->send_api_request($request_url, $data);
16 | print_r($page);
17 | exit();
18 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Follow-up-transaction/Void.php:
--------------------------------------------------------------------------------
1 | "void",
8 | "tran_class" => "ecom",
9 | "cart_id" => "cart_66666",
10 | "cart_currency" => "EGP",
11 | "cart_amount" => 130,
12 | "cart_description" => "shopping Cart",
13 | "tran_ref" => "TST2105400086891" //the Auth tran_ref you want to Void it
14 | ];
15 | $page = $plugin->send_api_request($request_url, $data);
16 | print_r($page);
17 | exit();
18 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Follow-up-transaction/query-transaction.php:
--------------------------------------------------------------------------------
1 | "TST2104800080101"
8 | ];
9 | $page = $plugin->send_api_request($request_url, $data);
10 | print_r($page);
11 | exit();
12 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Hosted-payment-page/Create-Payment-Page-HostedPaymentPage.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/request';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "cart_id" => "cart_11111",
11 | "cart_currency" => "EGP",
12 | "cart_amount" => 1000,
13 | "cart_description" => "Description of the items/services",
14 | "paypage_lang" => "en",
15 | "callback" => "https://webhook.site/730acce0-e54e-4522-8a45-f9b8e44624b6", // Nullable - Must be HTTPS, otherwise no post data from paytabs
16 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
17 | "customer_details" => [
18 | "name" => "first last",
19 | "email" => "email@domain.com",
20 | "phone" => "0522222222",
21 | "street1" => "address street",
22 | "city" => "dubai",
23 | "state" => "du",
24 | "country" => "AE",
25 | "zip" => "12345"
26 | ],
27 | "shipping_details" => [
28 | "name" => "name1 last1",
29 | "email" => "email1@domain.com",
30 | "phone" => "971555555555",
31 | "street1" => "street2",
32 | "city" => "dubai",
33 | "state" => "dubai",
34 | "country" => "AE",
35 | "zip" => "54321"
36 | ],
37 | "user_defined" => [
38 | "udf9" => "UDF9 Test9",
39 | "udf3" => "UDF3 Test3"
40 | ]
41 | ];
42 | $page = $plugin->send_api_request($request_url, $data);
43 | header('Location:' . $page['redirect_url']); /* Redirect browser */
44 | exit();
45 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Hosted-payment-page/Create-payment-page-Tokenization-optional.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/request';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "tokenise" => "2",
11 | "cart_id" => "cart_11111",
12 | "cart_currency" => "EGP",
13 | "cart_amount" => 1000,
14 | "cart_description" => "Description of the items/services",
15 | "paypage_lang" => "en",
16 | "show_save_card" => true,
17 | "callback" => "https://webhook.site/730acce0-e54e-4522-8a45-f9b8e44624b6", // Nullable - Must be HTTPS, otherwise no post data from paytabs
18 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
19 | "customer_details" => [
20 | "name" => "first last",
21 | "email" => "email@domain.com",
22 | "phone" => "0522222222",
23 | "street1" => "address street",
24 | "city" => "dubai",
25 | "state" => "du",
26 | "country" => "AE",
27 | "zip" => "12345"
28 | ],
29 | "shipping_details" => [
30 | "name" => "name1 last1",
31 | "email" => "email1@domain.com",
32 | "phone" => "971555555555",
33 | "street1" => "street2",
34 | "city" => "dubai",
35 | "state" => "dubai",
36 | "country" => "AE",
37 | "zip" => "54321"
38 | ]
39 | ];
40 | $page = $plugin->send_api_request($request_url, $data);
41 | header('Location:' . $page['redirect_url']); /* Redirect browser */
42 | exit();
43 |
44 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Hosted-payment-page/Create-payment-page-Tokenization.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/request';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "tokenise" => "2",
11 | "cart_id" => "cart_11111",
12 | "cart_currency" => "EGP",
13 | "cart_amount" => 1000,
14 | "cart_description" => "Description of the items/services",
15 | "paypage_lang" => "en",
16 | "show_save_card" => false,
17 | "callback" => "https://webhook.site/730acce0-e54e-4522-8a45-f9b8e44624b6", // Nullable - Must be HTTPS, otherwise no post data from paytabs
18 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
19 | "customer_details" => [
20 | "name" => "first last",
21 | "email" => "email@domain.com",
22 | "phone" => "0522222222",
23 | "street1" => "address street",
24 | "city" => "dubai",
25 | "state" => "du",
26 | "country" => "AE",
27 | "zip" => "12345"
28 | ],
29 | "shipping_details" => [
30 | "name" => "name1 last1",
31 | "email" => "email1@domain.com",
32 | "phone" => "971555555555",
33 | "street1" => "street2",
34 | "city" => "dubai",
35 | "state" => "dubai",
36 | "country" => "AE",
37 | "zip" => "54321"
38 | ]
39 | ];
40 |
41 | $page = $plugin->send_api_request($request_url, $data);
42 | header('Location:' . $page['redirect_url']); /* Redirect browser */
43 | exit();
44 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Hosted-payment-page/create-payment-page-HostedPaymentPage-framed.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/request';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "cart_id" => "cart_11111",
11 | "cart_currency" => "EGP",
12 | "cart_amount" => 1000,
13 | "cart_description" => "Description of the items/services",
14 | "paypage_lang" => "en",
15 | "callback" => "https://webhook.site/730acce0-e54e-4522-8a45-f9b8e44624b6", // Nullable - Must be HTTPS, otherwise no post data from paytabs
16 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
17 | "customer_details" => [
18 | "name" => "first last",
19 | "email" => "email@domain.com",
20 | "phone" => "0522222222",
21 | "street1" => "address street",
22 | "city" => "dubai",
23 | "state" => "du",
24 | "country" => "AE",
25 | "zip" => "12345"
26 | ],
27 | "shipping_details" => [
28 | "name" => "name1 last1",
29 | "email" => "email1@domain.com",
30 | "phone" => "971555555555",
31 | "street1" => "street2",
32 | "city" => "dubai",
33 | "state" => "dubai",
34 | "country" => "AE",
35 | "zip" => "54321"
36 | ],
37 | "framed" => true,
38 | "hide_shipping" => true
39 | ];
40 | $page = $plugin->send_api_request($request_url, $data);
41 |
42 | echo "";
43 | exit();
44 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Cancel-invoice-Post.php:
--------------------------------------------------------------------------------
1 | $invoice_id
9 | ];
10 |
11 | $page = $plugin->send_api_request($request_url, $data);
12 | print_r('the invoice details is');
13 | print_r('
');
14 | print_r($page);
15 |
16 | exit();
17 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Cancel-invoice-Put.php:
--------------------------------------------------------------------------------
1 | send_api_request($request_url, $data, $request_method);
11 | print_r('the request result is');
12 | print_r('
');
13 | print_r($page);
14 |
15 | exit();
16 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Create-invoice-with-token.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/new/invoice';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "tokenise" => 2,
11 | "cart_currency" => "EGP",
12 | "cart_amount" => "950",
13 | "cart_id" => "Test Cart",
14 | "cart_description" => "Test Description",
15 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
16 | "hide_shipping" => true,
17 | "invoice" => [
18 | "shipping_charges" => 0,
19 | "extra_charges" => 0,
20 | "extra_discount" => 0,
21 | "total" => 0,
22 | "line_items" => [
23 | [
24 | "sku" => "sku",
25 | "description" => "desc",
26 | "url" => "https://webhook.site/92ac6a52-256d-434b-bde8-94b1e73d3aa1",
27 | "unit_cost" => 950,
28 | "quantity" => 1,
29 | "net_total" => 950,
30 | "discount_rate" => 0,
31 | "discount_amount" => 0,
32 | "tax_rate" => 0,
33 | "tax_total" => 0,
34 | "total" => 950
35 | ]
36 | ]
37 | ]
38 | ];
39 | $page = $plugin->send_api_request($request_url, $data);
40 | print_r('your invoice id is' . $page['invoice_id']);
41 | print_r('
');
42 | print_r("go to your invoice");
43 |
44 | exit();
45 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Create-invoice.php:
--------------------------------------------------------------------------------
1 | getBaseUrl();
6 | $request_url = 'payment/new/invoice';
7 | $data = [
8 | "tran_type" => "sale",
9 | "tran_class" => "ecom",
10 | "cart_currency" => "EGP",
11 | "cart_amount" => "950",
12 | "cart_id" => "Test Cart",
13 | "cart_description" => "Test Description",
14 | "return" => $base_url."Result.php", // Must be HTTPS, otherwise no post data from paytabs , must be relative to your site URL
15 | "hide_shipping" => true,
16 | "invoice" => [
17 | "shipping_charges" => 0,
18 | "extra_charges" => 0,
19 | "extra_discount" => 0,
20 | "total" => 0,
21 | "line_items" => [
22 | [
23 | "sku" => "sku",
24 | "description" => "desc",
25 | "url" => "https://webhook.site/92ac6a52-256d-434b-bde8-94b1e73d3aa1",
26 | "unit_cost" => 950,
27 | "quantity" => 1,
28 | "net_total" => 950,
29 | "discount_rate" => 0,
30 | "discount_amount" => 0,
31 | "tax_rate" => 0,
32 | "tax_total" => 0,
33 | "total" => 950
34 | ]
35 | ]
36 | ]
37 | ];
38 | $page = $plugin->send_api_request($request_url, $data);
39 | print_r('your invoice id is' . $page['invoice_id']);
40 | print_r('
');
41 | print_r("go to your invoice");
42 |
43 | exit();
44 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Get-invoice-status-with-Post.php:
--------------------------------------------------------------------------------
1 | $invoice_id
9 | ];
10 |
11 | $page = $plugin->send_api_request($request_url, $data);
12 | print_r('the invoice details is');
13 | print_r('
');
14 | print_r($page);
15 |
16 | exit();
17 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Invoice/Get-invoice-status.php:
--------------------------------------------------------------------------------
1 | send_api_request($request_url, $data, $request_method);
11 | print_r('the invoice details is');
12 | print_r('
');
13 | print_r($page);
14 |
15 | exit();
16 |
--------------------------------------------------------------------------------
/PHP-sample-code-PT2/Managed-Form - Payment-Request/Create-managed-Form-Payment-Request.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |