id"); } /** * @since 2.29.0 Return PaymentRefunded instead of a bool value * @since 2.20.0 * @inerhitDoc */ public function refundDonation(Donation $donation): PaymentRefunded { return new PaymentRefunded(); } /** * This method implementation is a sample that demonstrates how we can handle webhook notifications * * @since 4.5.0 */ public function webhookNotificationsListener() { try { $webhookNotification = give_clean($_REQUEST); /** * Allow developers to handle the webhook notification. * * @since 4.5.0 * * @param array $webhookNotification */ do_action('givewp_' . $this::id() . '_webhook_notification_handler', $webhookNotification); // We will handle recurring donations in a separate submodule. if (isset($webhookNotification['gatewayRecurringPayment']) && $webhookNotification['gatewayRecurringPayment']) { return; } if ( ! isset($webhookNotification['gatewayPaymentStatus']) && ! isset($webhookNotification['gatewayPaymentId'])) { return; } switch (strtolower($webhookNotification['gatewayPaymentStatus'])) { case 'complete': $this->webhook->events->paymentCompleted($webhookNotification['gatewayPaymentId']); break; case 'failed': $this->webhook->events->paymentFailed($webhookNotification['gatewayPaymentId']); break; case 'cancelled': $this->webhook->events->paymentCancelled($webhookNotification['gatewayPaymentId']); break; case 'refunded': $this->webhook->events->paymentRefunded($webhookNotification['gatewayPaymentId']); break; default: break; } } catch (Exception $e) { esc_html_e('Webhook Notification failed.', 'give'); PaymentGatewayLog::error( 'Webhook Notification failed. Error: ' . $e->getMessage() ); } exit(); } }