This class handles the PayPal button widget.
As of writing those lines, it only supports the legacy payments API of PayPal.
We planned on adding support for the Payments API
using the PHP || JavaScript SDKs but
unfortunately both of them where not suitable for our needs.
The fast & easy-to-use option, but lack the support of button styling.
Forces you to pass basic argument like currency
or locale
as a query parameter to the script ( See here ).
That means you are limited to a single currency type for each page.
You can style the button ( well, you use it with AJAX and you are not bounded to PayPal's style, so... ).
PayPal created a nice Checkout SDK which works well, but luckily for us, it doesn't support anything other than a simple checkout request. Hurray! 🎉
We tried extending the SDK to at least support subscriptions, but creating a subscription in PayPal is complicated for the goal of a simple widget:
You need to create a Product, attach to a Plan and finally pass it to a Subscription.
get_numeric_setting( $key, $min )
retrieves a value by key
from get_settings()
, and return it as a numeric value, or defaults to $min
if it's non-existent or invalid.
get_errors()
handles basic validations and returns an array of errors.
get_api_method()
&& render_legacy_form()
are leftovers from the time we tried using the Payments API
and might be used in the future if PayPal will provide a simpler API.