1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
<?php
defined( 'ABSPATH' ) || exit();
trait WC_Stripe_Payment_Intent_Trait {
public function get_payment_object() {
return WC_Stripe_Payment_Factory::load( 'payment_intent', $this, WC_Stripe_Gateway::load() );
}
public function get_payment_method_type() {
return $this->payment_method_type;
}
public function get_confirmation_method( $order ) {
return 'manual';
}
public function get_payment_intent_checkout_url( $intent, $order, $type = 'intent' ) {
global $wp;
$args = array(
'type' => $type,
'client_secret' => $intent->client_secret,
'order_id' => $order->get_id(),
'order_key' => $order->get_order_key(),
'gateway_id' => $this->id,
'status' => $intent->status,
'pm' => $intent->payment_method,
'entropy' => rand( 0, 999999 )
);
if ( ! empty( $wp->query_vars['order-pay'] ) ) {
$args['save_method'] = ! empty( $_POST[ $this->save_source_key ] );
}
return sprintf( '#response=%s', rawurlencode( base64_encode( wp_json_encode( $args ) ) ) );
}
public function get_payment_intent_confirmation_args( $intent, $order ) {
return array();
}
}
trait WC_Stripe_Payment_Charge_Trait {
public function get_payment_object() {
return WC_Stripe_Payment_Factory::load( 'charge', $this, WC_Stripe_Gateway::load() );
}
}
trait WC_Stripe_Local_Payment_Charge_Trait {
public function get_payment_object() {
return WC_Stripe_Payment_Factory::load( 'local_charge', $this, WC_Stripe_Gateway::load() );
}
}
trait WC_Stripe_Local_Payment_Intent_Trait {
use WC_Stripe_Payment_Intent_Trait;
public function get_payment_intent_checkout_url( $intent, $order, $type = 'intent' ) {
return sprintf(
'#response=%s',
rawurlencode( base64_encode(
wp_json_encode(
array(
'client_secret' => $intent->client_secret,
'gateway_id' => $this->id,
'return_url' => $this->get_local_payment_return_url( $order ),
'order_received_url' => $this->get_return_url( $order ),
'entropy' => rand(
0,
999999
),
)
)
) )
);
}
public function get_confirmation_method( $order ) {
return 'automatic';
}
public function get_payment_intent_confirmation_args( $intent, $order ) {
return array(
'return_url' => $this->get_local_payment_return_url( $order )
);
}
}