PayPalWebhooks.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Route; |
| 4 | |
| 5 | use Give\Controller\PayPalWebhooks as Controller; |
| 6 | |
| 7 | class PayPalWebhooks implements Route { |
| 8 | /** |
| 9 | * @inheritDoc |
| 10 | */ |
| 11 | public function init() { |
| 12 | add_action( 'wp', [ $this, 'callController' ] ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Calls the corresponding controller for the route in the appropriate context |
| 17 | * |
| 18 | * @since 2.8.0 |
| 19 | */ |
| 20 | public function callController() { |
| 21 | if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] === 'paypal-commerce' ) { |
| 22 | give( Controller::class )->handle(); |
| 23 | |
| 24 | http_response_code( 200 ); |
| 25 | die(); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Returns the route URL |
| 31 | * |
| 32 | * @since 2.8.0 |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | public function getRouteUrl() { |
| 37 | return get_site_url( null, 'index.php?give-listener=paypal-commerce', 'https' ); |
| 38 | } |
| 39 | } |
| 40 |