PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.22
Timetics – Appointment Booking Calendar & Scheduling v1.0.22
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / core / integrations / stripe / stripe-payment.php

stripe-payment.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.22, at core/integrations/stripe/stripe-payment.php

60 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 * Class stripe payment
4 *
5 * @package Timetics
6 */
7 namespace Timetics\Core\Integrations\Stripe;
8
9 /**
10 * Class StripePayment
11 */
12 class StripePayment {
13 /**
14 * Store stripe paymentintent api url
15 *
16 * @var string
17 */
18 private $payment_intent_url = 'https://api.stripe.com/v1/payment_intents';
19
20 /**
21 * Create stripe paymentintent
22 *
23 * @param array $args Stripe payment details
24 *
25 * @return array
26 */
27 public function create_payment( $args = [] ) {
28 $defaults = [
29 'amount' => '',
30 'currency' => '',
31 ];
32
33 $args = wp_parse_args( $args, $defaults );
34
35 $url = $this->payment_intent_url;
36 $secret = timetics_get_option( 'stripe_secret_key' );
37 $args = build_query( $args ) . '&automatic_payment_methods[enabled]=true';
38 $params = [
39 'headers' => [
40 'Authorization' => 'Bearer ' . $secret,
41 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
42 ],
43 'body' => $args,
44 ];
45
46 $response = wp_remote_post( $url, $params );
47
48 if ( ! is_wp_error( $response ) ) {
49 return json_decode( wp_remote_retrieve_body( $response ), true );
50 }
51
52 /**
53 * Added temporary for leagacy sass. It will remove in future.
54 */
55 do_action( 'timetics/integrations/stripe/create_payment', $response );
56
57 return $response;
58 }
59 }
60