PayPalStandardBillingFields.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\PayPalStandard\Views; |
| 4 | |
| 5 | use Give\Helpers\Form\Utils; |
| 6 | |
| 7 | /** |
| 8 | * This class handle donation form billing field markup for PayPal Standard. |
| 9 | * |
| 10 | * @since 2.22.2 |
| 11 | */ |
| 12 | class PayPalStandardBillingFields |
| 13 | { |
| 14 | /** |
| 15 | * @since 2.22.2 |
| 16 | * |
| 17 | * @param int $formId |
| 18 | * |
| 19 | * @return string |
| 20 | */ |
| 21 | public function __invoke(int $formId): string |
| 22 | { |
| 23 | ob_start(); |
| 24 | |
| 25 | if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
| 26 | give_default_cc_address_fields($formId); |
| 27 | } elseif (Utils::isLegacyForm($formId)) { |
| 28 | echo ''; |
| 29 | } else { |
| 30 | printf( |
| 31 | ' |
| 32 | <fieldset class="no-fields"> |
| 33 | <div style="display: flex; justify-content: center; margin-top: 20px;"> |
| 34 | %4$s |
| 35 | </div> |
| 36 | <p style="text-align: center;"><b>%1$s</b></p> |
| 37 | <p style="text-align: center;"><b>%2$s</b> %3$s</p> |
| 38 | </fieldset> |
| 39 | ', |
| 40 | esc_html__('Make your donation quickly and securely with PayPal', 'give'), |
| 41 | esc_html__('How it works:', 'give'), |
| 42 | esc_html__( |
| 43 | 'You will be redirected to PayPal to complete your donation with your debit card, credit card, or with your PayPal account. Once complete, you will be redirected back to this site to view your receipt.', |
| 44 | 'give' |
| 45 | ), |
| 46 | $this->getLogo() |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | return ob_get_clean(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Return paypal logo. |
| 55 | * |
| 56 | * @since 2.19.0 |
| 57 | * @since 2.19.4 Use correct logo path. |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | private function getLogo(): string |
| 62 | { |
| 63 | return file_get_contents( |
| 64 | GIVE_PLUGIN_DIR . 'src/PaymentGateways/Gateways/PayPalStandard/resources/templates/paypal-standard-logo.svg' |
| 65 | ); |
| 66 | } |
| 67 | } |
| 68 |