Payments¶
The base plugin defines a single contract for generating payment links. Consuming plugins bind their own implementation to this interface.
PaymentHandlerInterface¶
Barberklingen\BasePlugin\Payments\Contracts\PaymentHandlerInterface
interface PaymentHandlerInterface {
public function create_payment_link(
WC_Order|WC_Subscription $entity,
array $args = []
): string;
}
create_payment_link() must return a URL that the customer can use to complete or retry payment for the given order or subscription.
Implementing the contract¶
use Barberklingen\BasePlugin\Payments\Contracts\PaymentHandlerInterface;
class QuickpayHandler implements PaymentHandlerInterface {
public function create_payment_link($entity, array $args = []): string {
// Call Quickpay API, return the payment URL
return 'https://payment.example.com/pay/' . $entity->get_id();
}
}
Register the implementation in your service provider: