mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Add non payment gateway items
This commit is contained in:
parent
5243ef10db
commit
afad57da5d
3 changed files with 222 additions and 68 deletions
|
@ -39,8 +39,20 @@ const useHooks = () => {
|
||||||
|
|
||||||
// Persistent accessors.
|
// Persistent accessors.
|
||||||
const sampleValue = usePersistent( 'sampleValue' );
|
const sampleValue = usePersistent( 'sampleValue' );
|
||||||
|
|
||||||
|
// PayPal checkout.
|
||||||
const paypal = usePersistent( 'ppcp-gateway' );
|
const paypal = usePersistent( 'ppcp-gateway' );
|
||||||
|
const venmo = usePersistent( 'venmo' );
|
||||||
|
const payLater = usePersistent( 'pay-later' );
|
||||||
|
const creditCard = usePersistent( 'ppcp-card-button-gateway' );
|
||||||
|
|
||||||
|
// Online card Payments.
|
||||||
const advancedCreditCard = usePersistent( 'ppcp-credit-card-gateway' );
|
const advancedCreditCard = usePersistent( 'ppcp-credit-card-gateway' );
|
||||||
|
const fastlane = usePersistent( 'ppcp-axo-gateway' );
|
||||||
|
const applePay = usePersistent( 'ppcp-applepay' );
|
||||||
|
const googlePay = usePersistent( 'ppcp-googlepay' );
|
||||||
|
|
||||||
|
// Alternative payment methods.
|
||||||
const bancontact = usePersistent( 'ppcp-bancontact' );
|
const bancontact = usePersistent( 'ppcp-bancontact' );
|
||||||
const blik = usePersistent( 'ppcp-blik' );
|
const blik = usePersistent( 'ppcp-blik' );
|
||||||
const eps = usePersistent( 'ppcp-eps' );
|
const eps = usePersistent( 'ppcp-eps' );
|
||||||
|
@ -58,7 +70,13 @@ const useHooks = () => {
|
||||||
sampleValue,
|
sampleValue,
|
||||||
setSampleValue,
|
setSampleValue,
|
||||||
paypal,
|
paypal,
|
||||||
|
venmo,
|
||||||
|
payLater,
|
||||||
|
creditCard,
|
||||||
advancedCreditCard,
|
advancedCreditCard,
|
||||||
|
fastlane,
|
||||||
|
applePay,
|
||||||
|
googlePay,
|
||||||
bancontact,
|
bancontact,
|
||||||
blik,
|
blik,
|
||||||
eps,
|
eps,
|
||||||
|
@ -88,8 +106,13 @@ export const useSampleValue = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const usePaymentMethodsPayPalCheckout = () => {
|
export const usePaymentMethodsPayPalCheckout = () => {
|
||||||
const { paypal } = useHooks();
|
const { paypal, venmo, payLater, creditCard } = useHooks();
|
||||||
const paymentMethodsPayPalCheckout = [ paypal ];
|
const paymentMethodsPayPalCheckout = [
|
||||||
|
paypal,
|
||||||
|
venmo,
|
||||||
|
payLater,
|
||||||
|
creditCard,
|
||||||
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
paymentMethodsPayPalCheckout,
|
paymentMethodsPayPalCheckout,
|
||||||
|
@ -97,8 +120,13 @@ export const usePaymentMethodsPayPalCheckout = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const usePaymentMethodsOnlineCardPayments = () => {
|
export const usePaymentMethodsOnlineCardPayments = () => {
|
||||||
const { advancedCreditCard } = useHooks();
|
const { advancedCreditCard, fastlane, applePay, googlePay } = useHooks();
|
||||||
const paymentMethodsOnlineCardPayments = [ advancedCreditCard ];
|
const paymentMethodsOnlineCardPayments = [
|
||||||
|
advancedCreditCard,
|
||||||
|
fastlane,
|
||||||
|
applePay,
|
||||||
|
googlePay,
|
||||||
|
];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
paymentMethodsOnlineCardPayments,
|
paymentMethodsOnlineCardPayments,
|
||||||
|
|
|
@ -20,6 +20,8 @@ const defaultTransient = Object.freeze( {
|
||||||
// Persistent: Values that are loaded from the DB.
|
// Persistent: Values that are loaded from the DB.
|
||||||
const defaultPersistent = Object.freeze( {
|
const defaultPersistent = Object.freeze( {
|
||||||
'ppcp-gateway': {},
|
'ppcp-gateway': {},
|
||||||
|
venmo: {},
|
||||||
|
'pay-later': {},
|
||||||
'ppcp-card-button-gateway': {},
|
'ppcp-card-button-gateway': {},
|
||||||
'ppcp-credit-card-gateway': {},
|
'ppcp-credit-card-gateway': {},
|
||||||
'ppcp-axo-gateway': {},
|
'ppcp-axo-gateway': {},
|
||||||
|
|
|
@ -46,67 +46,184 @@ class PaymentRestEndpoint extends RestEndpoint {
|
||||||
/**
|
/**
|
||||||
* Field mapping for request to profile transformation.
|
* Field mapping for request to profile transformation.
|
||||||
*
|
*
|
||||||
* @var array
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
private array $gateways = array(
|
protected function gateways():array {
|
||||||
PayPalGateway::ID => array(
|
return array(
|
||||||
'id' => 'paypal',
|
// PayPal checkout.
|
||||||
'icon' => 'payment-method-paypal',
|
PayPalGateway::ID => array(
|
||||||
),
|
'id' => 'paypal',
|
||||||
CardButtonGateway::ID => array(
|
'title' => __( 'PayPal', 'woocommerce-paypal-payments' ),
|
||||||
'icon' => 'payment-method-cards',
|
'description' => __(
|
||||||
),
|
'Our all-in-one checkout solution lets you offer PayPal, Venmo, Pay Later options, and more to help maximize conversion.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-paypal',
|
||||||
|
),
|
||||||
|
'venmo' => array(
|
||||||
|
'id' => 'venmo',
|
||||||
|
'title' => __( 'Venmo', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'Offer Venmo at checkout to millions of active users.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-venmo',
|
||||||
|
),
|
||||||
|
'pay-later' => array(
|
||||||
|
'id' => 'paypal_credit',
|
||||||
|
'title' => __( 'Pay Later', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'Get paid in full at checkout while giving your customers the flexibility to pay in installments over time with no late fees.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-paypal',
|
||||||
|
),
|
||||||
|
CardButtonGateway::ID => array(
|
||||||
|
'id' => 'credit_and_debit_card_payments',
|
||||||
|
'title' => __(
|
||||||
|
'Credit and debit card payments',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'description' => __(
|
||||||
|
"Accept all major credit and debit cards - even if your customer doesn't have a PayPal account.",
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-cards',
|
||||||
|
),
|
||||||
|
|
||||||
CreditCardGateway::ID => array(
|
// Online card Payments.
|
||||||
'icon' => 'payment-method-advanced-cards',
|
CreditCardGateway::ID => array(
|
||||||
),
|
'id' => 'advanced_credit_and_debit_card_payments',
|
||||||
AxoGateway::ID => array(
|
'title' => __(
|
||||||
'icon' => 'payment-method-fastlane',
|
'Advanced Credit and Debit Card Payments',
|
||||||
),
|
'woocommerce-paypal-payments'
|
||||||
ApplePayGateway::ID => array(
|
),
|
||||||
'icon' => 'payment-method-apple-pay',
|
'description' => __(
|
||||||
),
|
"Present custom credit and debit card fields to your payers so they can pay with credit and debit cards using your site's branding.",
|
||||||
GooglePayGateway::ID => array(
|
'woocommerce-paypal-payments'
|
||||||
'icon' => 'payment-method-google-pay',
|
),
|
||||||
),
|
'icon' => 'payment-method-advanced-cards',
|
||||||
|
),
|
||||||
|
AxoGateway::ID => array(
|
||||||
|
'id' => 'fastlane',
|
||||||
|
'title' => __( 'Fastlane by PayPal', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
"Tap into the scale and trust of PayPal's customer network to recognize shoppers and make guest checkout more seamless than ever.",
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-fastlane',
|
||||||
|
),
|
||||||
|
ApplePayGateway::ID => array(
|
||||||
|
'id' => 'apple_pay',
|
||||||
|
'title' => __( 'Apple Pay', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'Allow customers to pay via their Apple Pay digital wallet.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-apple-pay',
|
||||||
|
),
|
||||||
|
GooglePayGateway::ID => array(
|
||||||
|
'id' => 'google_pay',
|
||||||
|
'title' => __( 'Google Pay', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'Allow customers to pay via their Google Pay digital wallet.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-google-pay',
|
||||||
|
),
|
||||||
|
|
||||||
BancontactGateway::ID => array(
|
// Alternative payment methods.
|
||||||
'icon' => 'payment-method-bancontact',
|
BancontactGateway::ID => array(
|
||||||
),
|
'id' => 'bancontact',
|
||||||
BlikGateway::ID => array(
|
'title' => __( 'Bancontact', 'woocommerce-paypal-payments' ),
|
||||||
'icon' => 'payment-method-blik',
|
'description' => __(
|
||||||
),
|
'Bancontact is the most widely used, accepted and trusted electronic payment method in Belgium. Bancontact makes it possible to pay directly through the online payment systems of all major Belgian banks.',
|
||||||
EPSGateway::ID => array(
|
'woocommerce-paypal-payments'
|
||||||
'icon' => 'payment-method-eps',
|
),
|
||||||
),
|
'icon' => 'payment-method-bancontact',
|
||||||
IDealGateway::ID => array(
|
),
|
||||||
'icon' => 'payment-method-ideal',
|
BlikGateway::ID => array(
|
||||||
),
|
'id' => 'blik',
|
||||||
MyBankGateway::ID => array(
|
'title' => __( 'BLIK', 'woocommerce-paypal-payments' ),
|
||||||
'icon' => 'payment-method-mybank',
|
'description' => __(
|
||||||
),
|
'A widely used mobile payment method in Poland, allowing Polish customers to pay directly via their banking apps. Transactions are processed in PLN.',
|
||||||
P24Gateway::ID => array(
|
'woocommerce-paypal-payments'
|
||||||
'icon' => 'payment-method-przelewy24',
|
),
|
||||||
),
|
'icon' => 'payment-method-blik',
|
||||||
TrustlyGateway::ID => array(
|
),
|
||||||
'icon' => 'payment-method-trustly',
|
EPSGateway::ID => array(
|
||||||
),
|
'id' => 'eps',
|
||||||
MultibancoGateway::ID => array(
|
'title' => __( 'eps', 'woocommerce-paypal-payments' ),
|
||||||
'icon' => 'payment-method-multibanco',
|
'description' => __(
|
||||||
),
|
'An online payment method in Austria, enabling Austrian buyers to make secure payments directly through their bank accounts. Transactions are processed in EUR.',
|
||||||
PayUponInvoiceGateway::ID => array(
|
'woocommerce-paypal-payments'
|
||||||
'icon' => 'payment-method-multibanco',
|
),
|
||||||
),
|
'icon' => 'payment-method-eps',
|
||||||
OXXO::ID => array(
|
),
|
||||||
'icon' => 'payment-method-multibanco',
|
IDealGateway::ID => array(
|
||||||
),
|
'id' => 'ideal',
|
||||||
);
|
'title' => __( 'iDEAL', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
/**
|
'iDEAL is a payment method in the Netherlands that allows buyers to select their issuing bank from a list of options.',
|
||||||
* Constructor.
|
'woocommerce-paypal-payments'
|
||||||
*/
|
),
|
||||||
public function __construct() {
|
'icon' => 'payment-method-ideal',
|
||||||
// Todo: Add DI instead of using `WC()->payment_gateways->payment_gateways()`?
|
),
|
||||||
|
MyBankGateway::ID => array(
|
||||||
|
'id' => 'mybank',
|
||||||
|
'title' => __( 'MyBank', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'A European online banking payment solution primarily used in Italy, enabling customers to make secure bank transfers during checkout. Transactions are processed in EUR.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-mybank',
|
||||||
|
),
|
||||||
|
P24Gateway::ID => array(
|
||||||
|
'id' => 'przelewy24',
|
||||||
|
'title' => __( 'Przelewy24', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'A popular online payment gateway in Poland, offering various payment options for Polish customers. Transactions can be processed in PLN or EUR.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-przelewy24',
|
||||||
|
),
|
||||||
|
TrustlyGateway::ID => array(
|
||||||
|
'id' => 'trustly',
|
||||||
|
'title' => __( 'Trustly', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'A European payment method that allows buyers to make payments directly from their bank accounts, suitable for customers across multiple European countries. Supported currencies include EUR, DKK, SEK, GBP, and NOK.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-trustly',
|
||||||
|
),
|
||||||
|
MultibancoGateway::ID => array(
|
||||||
|
'id' => 'multibanco',
|
||||||
|
'title' => __( 'Multibanco', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'An online payment method in Portugal, enabling Portuguese buyers to make secure payments directly through their bank accounts. Transactions are processed in EUR.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => 'payment-method-multibanco',
|
||||||
|
),
|
||||||
|
PayUponInvoiceGateway::ID => array(
|
||||||
|
'id' => 'pui',
|
||||||
|
'title' => __( 'Pay upon Invoice', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'Pay upon Invoice is an invoice payment method in Germany. It is a local buy now, pay later payment method that allows the buyer to place an order, receive the goods, try them, verify they are in good order, and then pay the invoice within 30 days.',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => '',
|
||||||
|
),
|
||||||
|
OXXO::ID => array(
|
||||||
|
'id' => 'oxxo',
|
||||||
|
'title' => __( 'OXXO', 'woocommerce-paypal-payments' ),
|
||||||
|
'description' => __(
|
||||||
|
'OXXO is a Mexican chain of convenience stores. *Get PayPal account permission to use OXXO payment functionality by contacting us at (+52) 800–925–0304',
|
||||||
|
'woocommerce-paypal-payments'
|
||||||
|
),
|
||||||
|
'icon' => '',
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -153,13 +270,20 @@ class PaymentRestEndpoint extends RestEndpoint {
|
||||||
* @return WP_REST_Response The current payment methods details.
|
* @return WP_REST_Response The current payment methods details.
|
||||||
*/
|
*/
|
||||||
public function get_details() : WP_REST_Response {
|
public function get_details() : WP_REST_Response {
|
||||||
// Todo: Change this to DI?
|
|
||||||
$all_gateways = WC()->payment_gateways->payment_gateways();
|
$all_gateways = WC()->payment_gateways->payment_gateways();
|
||||||
|
|
||||||
$gateway_settings = array();
|
$gateway_settings = array();
|
||||||
|
|
||||||
foreach ( $this->gateways as $key => $value ) {
|
foreach ( $this->gateways() as $key => $value ) {
|
||||||
if ( ! isset( $all_gateways[ $key ] ) ) {
|
if ( ! isset( $all_gateways[ $key ] ) ) {
|
||||||
|
$gateway_settings[ $key ] = array(
|
||||||
|
'id' => $this->gateways()[ $key ]['id'] ?? '',
|
||||||
|
'title' => $this->gateways()[ $key ]['title'] ?? '',
|
||||||
|
'description' => $this->gateways()[ $key ]['description'] ?? '',
|
||||||
|
'enabled' => false,
|
||||||
|
'icon' => $this->gateways()[ $key ]['icon'] ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +291,11 @@ class PaymentRestEndpoint extends RestEndpoint {
|
||||||
|
|
||||||
$gateway_settings[ $key ] = array(
|
$gateway_settings[ $key ] = array(
|
||||||
'enabled' => 'yes' === $gateway->enabled,
|
'enabled' => 'yes' === $gateway->enabled,
|
||||||
'title' => $gateway->get_title(),
|
'title' => $this->gateways()[ $key ]['title'] ?? $gateway->get_title(),
|
||||||
'description' => $gateway->get_description(),
|
'description' => $this->gateways()[ $key ]['description'] ?? $gateway->get_description(),
|
||||||
'method_title' => $gateway->get_method_title(),
|
'method_title' => $gateway->get_method_title(),
|
||||||
'id' => $this->gateways[ $key ]['id'] ?? $key,
|
'id' => $this->gateways()[ $key ]['id'] ?? $key,
|
||||||
'icon' => $this->gateways[ $key ]['icon'] ?? '',
|
'icon' => $this->gateways()[ $key ]['icon'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue