Skip to content
Merged
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
28 changes: 16 additions & 12 deletions doc/generate-payment-confirmation.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
# Generating a confirmation PDF for paid payment
# Generating a Payment Confirmation PDF

If a merchant needs confirmation for someone that they received payment through our services.
They can generate a confirmation PDF document for payment in ThePay administration.
Merchants can generate a payment confirmation PDF as proof that a specific payment was successfully received through ThePay.

The generating confirmation can be also integrated into merchant application as describe example below.
This document can be generated manually in ThePay Administration, or automatically via API integration in your application.

## API integration example

To integrate payment confirmation generation into your application, you can use the following example:

```php

/** @var \ThePay\ApiClient\TheClient $thePayClient */

$payment = $thePayClient->getPayment('exampleUID');
// make detection if payment was really paid
// and inform user that for not paid payment is confirmation unavailable,
// because call method generatePaymentConfirmationPdf for unpaid payments will fail
if($payment->wasPaid()) {
$payment = $thePayClient->getPayment('uid123');

// Check if the payment has been successfully completed.
// Confirmation can only be generated for paid payments.
if ($payment->wasPaid()) {

// we recommend asking user for language of receiver who confirmation wants, so he can understand it,
// if we not support given language, we return confirmation in english
// Optionally, ask the user to select the preferred language for the confirmation document.
// If the specified language is not supported, the PDF will default to English.
$confirmationLanguageCode = 'cs';

$confirmationPdfContent = $thePayClient->generatePaymentConfirmationPdf('exampleUID', $confirmationLanguageCode);
// Generate the confirmation PDF
$confirmationPdfContent = $thePayClient->generatePaymentConfirmationPdf('uid123', $confirmationLanguageCode);

header('Content-type:application/pdf');

Expand Down