PluginProbe
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe / trunk
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe vtrunk
4.17.3 trunk 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 4.10.0 4.11.1 4.12.2 4.14.1 4.14.2 4.14.3 4.15.0 4.16.0 All 59 releases
stripe / src / PaymentMethods / Collection.php

Collection.php in Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe trunk, at src/PaymentMethods/Collection.php

61 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Payment Methods: Collection
4 *
5 * @package SimplePay\Core\PaymentMethods
6 * @copyright Copyright (c) 2022, Sandhills Development, LLC
7 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
8 * @since 3.8.0
9 */
10
11 namespace SimplePay\Core\PaymentMethods;
12
13 use SimplePay\Core\Utils;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Collection class
21 *
22 * @since 3.8.0
23 */
24 class Collection extends Utils\Collection {
25
26 /**
27 * Adds a Payment Method to the registry.
28 *
29 * @since 3.8.0
30 *
31 * @param string $payment_method_id Payment Method ID.
32 * @param \SimplePay\Core\PaymentMethods\PaymentMethod $payment_method Payment Method.
33 * @return \WP_Error|true True on successful addition, otherwise a \WP_Error object.
34 */
35 public function add( $payment_method_id, $payment_method ) {
36 if ( empty( $payment_method_id ) ) {
37 return new \WP_Error(
38 'invalid_payment_method_id',
39 sprintf(
40 /* translators: %s Collection ID that could not be registered. */
41 __( 'The %s Payment Method already exists and cannot be added.', 'stripe' ),
42 $payment_method_id
43 )
44 );
45 }
46
47 if ( ! is_a( $payment_method, 'SimplePay\Core\PaymentMethods\PaymentMethod' ) ) {
48 return new \WP_Error(
49 'invalid_payment_method',
50 sprintf(
51 /* translators: %s Collection ID that could not be registered. */
52 __( 'The Payment Method is invalid.', 'stripe' ),
53 $payment_method
54 )
55 );
56 }
57
58 return $this->add_item( $payment_method_id, $payment_method );
59 }
60 }
61