|
1 | | -# Generating a confirmation PDF for paid payment |
| 1 | +# Generating a Payment Confirmation PDF |
2 | 2 |
|
3 | | -If a merchant needs confirmation for someone that they received payment through our services. |
4 | | -They can generate a confirmation PDF document for payment in ThePay administration. |
| 3 | +Merchants can generate a payment confirmation PDF as proof that a specific payment was successfully received through ThePay. |
5 | 4 |
|
6 | | -The generating confirmation can be also integrated into merchant application as describe example below. |
| 5 | +This document can be generated manually in ThePay Administration, or automatically via API integration in your application. |
| 6 | + |
| 7 | +## API integration example |
| 8 | + |
| 9 | +To integrate payment confirmation generation into your application, you can use the following example: |
7 | 10 |
|
8 | 11 | ```php |
9 | 12 |
|
10 | 13 | /** @var \ThePay\ApiClient\TheClient $thePayClient */ |
11 | 14 |
|
12 | | -$payment = $thePayClient->getPayment('exampleUID'); |
13 | | -// make detection if payment was really paid |
14 | | -// and inform user that for not paid payment is confirmation unavailable, |
15 | | -// because call method generatePaymentConfirmationPdf for unpaid payments will fail |
16 | | -if($payment->wasPaid()) { |
| 15 | +$payment = $thePayClient->getPayment('uid123'); |
| 16 | + |
| 17 | +// Check if the payment has been successfully completed. |
| 18 | +// Confirmation can only be generated for paid payments. |
| 19 | +if ($payment->wasPaid()) { |
17 | 20 |
|
18 | | - // we recommend asking user for language of receiver who confirmation wants, so he can understand it, |
19 | | - // if we not support given language, we return confirmation in english |
| 21 | + // Optionally, ask the user to select the preferred language for the confirmation document. |
| 22 | + // If the specified language is not supported, the PDF will default to English. |
20 | 23 | $confirmationLanguageCode = 'cs'; |
21 | 24 |
|
22 | | - $confirmationPdfContent = $thePayClient->generatePaymentConfirmationPdf('exampleUID', $confirmationLanguageCode); |
| 25 | + // Generate the confirmation PDF |
| 26 | + $confirmationPdfContent = $thePayClient->generatePaymentConfirmationPdf('uid123', $confirmationLanguageCode); |
23 | 27 |
|
24 | 28 | header('Content-type:application/pdf'); |
25 | 29 |
|
|
0 commit comments