| @@ 341-359 (lines=19) @@ | ||
| 338 | * @param array $payment_meta associative array of meta data required for automatic payments |
|
| 339 | * @return array |
|
| 340 | */ |
|
| 341 | public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { |
|
| 342 | if ( $this->id === $payment_method_id ) { |
|
| 343 | ||
| 344 | if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) { |
|
| 345 | throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) ); |
|
| 346 | } elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) { |
|
| 347 | throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) ); |
|
| 348 | } |
|
| 349 | ||
| 350 | if ( |
|
| 351 | ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
| 352 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) ) |
|
| 353 | && ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
| 354 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) { |
|
| 355 | ||
| 356 | throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) ); |
|
| 357 | } |
|
| 358 | } |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * Render the payment method used for a subscription in the "My Subscriptions" table |
|
| @@ 387-405 (lines=19) @@ | ||
| 384 | * @param array $payment_meta associative array of meta data required for automatic payments |
|
| 385 | * @return array |
|
| 386 | */ |
|
| 387 | public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { |
|
| 388 | if ( $this->id === $payment_method_id ) { |
|
| 389 | ||
| 390 | if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) { |
|
| 391 | throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) ); |
|
| 392 | } elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) { |
|
| 393 | throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) ); |
|
| 394 | } |
|
| 395 | ||
| 396 | if ( |
|
| 397 | ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
| 398 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) ) |
|
| 399 | && ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
| 400 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) { |
|
| 401 | ||
| 402 | throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) ); |
|
| 403 | } |
|
| 404 | } |
|
| 405 | } |
|
| 406 | ||
| 407 | /** |
|
| 408 | * Render the payment method used for a subscription in the "My Subscriptions" table |
|