Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php if (!defined("\x41\x42\x53\x50\x41\x54\110")) { die; } if (!class_exists("\115\145..

Decoded Output download

<?php 
 if (!defined("ABSPATH")) { die; } if (!class_exists("MeshCheckoutStripe")) { class MeshCheckoutStripe extends MeshCheckoutBase { private static $instance = null; private $table = "meshcheckout_orders"; private $gateway_url = ''; private $logger = null; public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } public function __construct() { $gateway_url = get_option("meshcheckout_connect_gateway"); $this->gateway_url = strpos($gateway_url, "localhost") > 0 || strpos($gateway_url, "work.dev") > 0 ? $gateway_url : $gateway_url . "/api"; } function success($token) { $trans = get_transient("mc_" . $token); delete_transient("mc_" . $token); if ($trans !== false && isset($trans["return_url"])) { $return_url = $trans["return_url"]; if (strpos($return_url, "mcpayment") !== false) { $return_url .= $token . "/"; } wp_redirect($return_url, 302); die; } else { header("HTTP/1.1 502 Bad Gateway"); die; } } function cancel($token) { $trans = get_transient("mc_" . $token); $cancel_return = $trans["cancel_return"]; if (strpos($cancel_return, "mcpayment") !== false) { $cancel_return .= $token . "/"; } if ($trans !== false) { wp_redirect($cancel_return, 302); die; } else { header("HTTP/1.1 502 Bad Gateway"); die; } } function webhook() { header("X-Frame-Options: ALLOWALL"); header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS"); header("Access-Control-Allow-Headers: X-Requested-With,Authorization,Content-Type"); header("Access-Control-Max-Age: 86400"); require MC_STRIPE_PATH . "autoload.php"; $payload = @file_get_contents("php://input"); $params = json_decode($payload, true); $sig_header = $_SERVER["HTTP_STRIPE_SIGNATURE"]; $secretKey = get_option("mc_stripe_secret"); $this->log("Stripe events"); $this->log("Stripe Sig: " . $sig_header); $event = null; try { $webhook = get_option("mc_stripe_webhook"); $stripe_secret = get_option("mc_stripe_secret"); $this->log("Stripe Webhook: " . $webhook); $this->log("Stripe Secret: " . $stripe_secret); $this->log("Stripe Payload: " . $payload); \Stripe\Stripe::setApiKey($stripe_secret); $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $webhook); $payment_intent = ''; if (isset($params["data"]) && isset($params["data"]["object"]) && isset($params["data"]["object"]["payment_intent"])) { $payment_intent = $params["data"]["object"]["payment_intent"]; } $this->log("PAYMENT_INTENT:" . $payment_intent); if (!empty($payment_intent)) { $payment_data = get_option($payment_intent); } switch ($event->type) { case "charge.captured": $this->log("charge.captured"); $event_data = array("id" => $params["data"]["object"]["id"], "balance_transaction" => $params["data"]["object"]["balance_transaction"], "customer" => $params["data"]["object"]["customer"], "receipt_url" => $params["data"]["object"]["receipt_url"], "refund_url" => $params["data"]["object"]["refunds"]["url"], "amount" => $params["data"]["object"]["amount"], "amount_captured" => $params["data"]["object"]["amount_captured"], "amount_refunded" => $params["data"]["object"]["amount_refunded"]); update_option($payment_intent . "_charge", $event_data); if ($params["data"]["object"]["captured"]) { $this->sendCompleted($payment_intent); } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => 1)))); break; case "charge.updated": $this->log("charge.updated"); $event_data = array("id" => $params["data"]["object"]["id"], "balance_transaction" => $params["data"]["object"]["balance_transaction"], "customer" => $params["data"]["object"]["customer"], "receipt_url" => $params["data"]["object"]["receipt_url"], "refund_url" => $params["data"]["object"]["refunds"]["url"], "amount" => $params["data"]["object"]["amount"], "amount_captured" => $params["data"]["object"]["amount_captured"], "amount_refunded" => $params["data"]["object"]["amount_refunded"]); update_option($payment_intent . "_charge", $event_data); $this->sendCompleted($payment_intent); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => 1)))); break; case "charge.succeeded": $this->log("charge.succeeded"); $event_data = array("id" => $params["data"]["object"]["id"], "balance_transaction" => $params["data"]["object"]["balance_transaction"], "customer" => $params["data"]["object"]["customer"], "receipt_url" => $params["data"]["object"]["receipt_url"], "refund_url" => $params["data"]["object"]["refunds"]["url"], "amount" => $params["data"]["object"]["amount"], "amount_captured" => $params["data"]["object"]["amount_captured"], "amount_refunded" => $params["data"]["object"]["amount_refunded"], "captured" => $params["data"]["object"]["captured"]); $this->log("save charge data"); update_option($payment_intent . "_charge", $event_data); $this->sendCompleted($payment_intent); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => 1)))); break; case "checkout.session.completed": $this->log("checkout.session.completed"); $event_data = array("id" => $params["data"]["object"]["id"], "payment_status" => $params["data"]["object"]["payment_status"], "customer" => $params["data"]["object"]["customer"], "customer_details" => $params["data"]["object"]["customer_details"], "amount_total" => $params["data"]["object"]["amount_total"], "amount_subtotal" => $params["data"]["object"]["amount_subtotal"]); $checkout_session_id = $params["data"]["object"]["id"]; $cs_data = get_option($checkout_session_id); $cs_data["payment_intent"] = $payment_intent; $this->log("checkout data"); update_option($payment_intent, $cs_data); update_option($payment_intent . "_csc", $event_data); update_option($checkout_session_id, $cs_data); $this->sendCompleted($payment_intent); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => 1)))); break; } } catch (\UnexpectedValueException $e) { $this->log("Invalid payload:" . $e->getMessage()); header("HTTP/1.1 400 Bad Request "); die; } catch (\Stripe\Exception\SignatureVerificationException $e) { $this->log("Invalid signature:" . $e->getMessage()); header("HTTP/1.1 400 Bad Request "); die; } $this->log("Passed signature verification!"); header("HTTP/1.1 200 OK"); } function create() { $params = json_decode(file_get_contents("php://input"), true); $this->log("create order:"); $this->log(json_encode($params, JSON_PRETTY_PRINT)); $publicKey = isset($params["public_key"]) && $params["public_key"] != '' ? trim($params["public_key"]) : ''; $secretKey = isset($params["secret_key"]) && $params["secret_key"] != '' ? trim($params["secret_key"]) : ''; $webhook = isset($params["webhook"]) && $params["webhook"] != '' ? trim($params["webhook"]) : ''; update_option("mc_stripe_public", $publicKey); update_option("mc_stripe_secret", $secretKey); update_option("mc_stripe_webhook", $webhook); $trans_key = "mc_" . $params["meshtoken"]; set_transient($trans_key, array("return_url" => $params["return_url"], "cancel_return" => $params["cancel_return"]), 7200); if (empty($secretKey)) { $this->log("Error: Secret key is empty"); return null; } try { require MC_STRIPE_PATH . "autoload.php"; $stripe = new \Stripe\StripeClient($secretKey); $requestParams = json_decode($params["data"], true); $checkout_session = $stripe->checkout->sessions->create($requestParams); $this->log(json_encode($checkout_session, JSON_PRETTY_PRINT)); $this->log("URL: {$checkout_session->url}\xa"); $this->log("Status: {$checkout_session->payment_status}
"); $this->log("Order ID: {$checkout_session->id}\xa"); $this->log(json_encode($checkout_session, JSON_PRETTY_PRINT)); $checkout_session["status"] = "CREATED"; $res_data = array("id" => $checkout_session->id, "created" => $checkout_session->created, "expires_at" => $checkout_session->expires_at, "payment_intent" => $checkout_session->payment_intent, "payment_method_types" => $checkout_session->payment_method_types, "payment_status" => $checkout_session->payment_status, "amount_total" => $checkout_session->amount_total, "amount_subtotal" => $checkout_session->amount_subtotal, "url" => $checkout_session->url, "status" => "CREATED"); $checkout_session_data = array("token" => $params["meshtoken"], "capture_method" => "automatic"); if (isset($requestParams["payment_intent_data"]) && isset($requestParams["payment_intent_data"]["capture_method"])) { $checkout_session_data["capture_method"] = "manual"; } update_option($checkout_session->id, $checkout_session_data); if (!empty($checkout_session->payment_intent)) { update_option($checkout_session->payment_intent, array("token" => $params["meshtoken"])); } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => 1, "redirect" => $checkout_session->url, "result" => $res_data)))); } catch (Exception $e) { $this->log("Error on request to Stripe: " . $e->getMessage()); return null; } $this->log("Not error but something wrong."); return null; } function sendCompleted($payment_intent) { $this->log("sendCompleted:" . $payment_intent); $payment = get_option($payment_intent); $csc = get_option($payment_intent . "_csc"); $charge = get_option($payment_intent . "_charge"); if (isset($payment["token"]) && !empty($payment["token"]) && isset($csc["id"]) && isset($charge["id"])) { $data = array("token" => $payment["token"], "payment_intent" => $payment_intent, "status" => "paid", "data" => json_encode(array("csc" => $csc, "charge" => $charge, "payment_intent" => $payment_intent))); if (isset($charge["captured"]) && !$charge["captured"]) { $data["status"] = "authorized"; } $gateway_url = str_replace("http://work.dev:8888/api", "http://localhost:8888", $this->gateway_url); $this->log("Data ready"); $this->log(rtrim($gateway_url, "/") . "/pay/stripe_update"); $this->log(json_encode($data, JSON_PRETTY_PRINT)); $response = wp_remote_request(rtrim($this->gateway_url, "/") . "/pay/stripe_update", array("reject_unsafe_urls" => false, "method" => "POST", "body" => $data, "timeout" => 30, "user-agent" => "SalesGen/1.0", "httpversion" => "1.1")); $this->log(json_encode($response, JSON_PRETTY_PRINT)); } else { $this->log("not enough data"); } } public function response($data) { if (isset($data["code"])) { header($data["code"]); } if (isset($data["body"])) { echo $data["body"]; } $this->log("Completed response:" . $data["code"]); die; } function checkout() { include_once MC_TEMPLATE_PATH . "stripe.php"; die; } function process_old() { require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("Process requested with data:" . json_encode($json_obj)); $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $intent = null; $last_intent = ''; try { $stripe = new \Stripe\StripeClient($secretKey); $paymentMethodId = $json_obj["payment_method_id"]; $totalPrice = $json_obj["total_price"]; $currency = $json_obj["currency"]; $customer = isset($json_obj["customer"]) ? $json_obj["customer"] : null; try { if (isset($json_obj["paymentintent"]) && $json_obj["paymentintent"] != '') { $last_intent = $json_obj["paymentintent"]; $intent = $stripe->paymentIntents->retrieve($json_obj["paymentintent"]); $this->log("Payment intents retrieve"); } elseif (isset($json_obj["payment_method_id"])) { $this->log("============== start new transaction ====================="); $this->log("Create payment intents"); $intent_data = isset($json_obj["intent_data"]) ? $json_obj["intent_data"] : array("amount" => $totalPrice, "currency" => $currency, "payment_method" => $paymentMethodId, "confirm" => true); if (!empty($customer) && (!isset($json_obj["lastintent"]) || isset($json_obj["lastintent"]) && $json_obj["lastintent"] == '')) { try { $this->log("Create customer"); $customerCreated = $stripe->customers->create($customer); $this->log("Customer created:" . json_encode($customerCreated)); $intent_data["customer"] = $customerCreated->id; } catch (Exception $e) { $this->log("Error in create customer:" . $e->getMessage()); $this->log(json_encode($e->getError())); $errorObj = $e->getError(); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("success" => false, "error" => $e->getMessage(), "intent" => $last_intent)); $this->log("Error response:" . $body); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } } $this->log("Params intent:" . json_encode($intent_data)); if (isset($json_obj["lastintent"]) && $json_obj["lastintent"] != '') { unset($intent_data["automatic_payment_methods"]); unset($intent_data["confirm"]); unset($intent_data["customer"]); $intentCurrentData = $stripe->paymentIntents->retrieve($json_obj["lastintent"]); $this->log("Current Intent Data:" . json_encode($intentCurrentData)); $stripe->paymentIntents->update($json_obj["lastintent"], $intent_data); $intent = $stripe->paymentIntents->confirm($json_obj["lastintent"], array("payment_method" => $paymentMethodId)); } else { $intent = $stripe->paymentIntents->create($intent_data); $this->log("Payment intents created:" . json_encode($intent)); } } } catch (Exception $e) { $this->log("Error in request to Stripe:" . $e->getMessage()); $errorObj = $e->getError(); $this->log("Stripe response:" . json_encode($errorObj)); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("success" => false, "error" => $e->getMessage(), "intent" => $last_intent)); $this->log("Error response:" . $body); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } if (in_array($intent->status, array("requires_action", "requires_source_action")) && $intent->next_action->type == "use_stripe_sdk") { $this->log("Payment need 3DS"); $body = json_encode(array("success" => true, "requires_action" => true, "payment_intent_client_secret" => $intent->client_secret, "intent" => $last_intent, "payment_data" => $intent)); } else { if ($intent->status == "succeeded") { $this->log("Payment intent succeeded"); $this->log(json_encode($intent)); $body = json_encode(array("success" => true, "intent" => $last_intent, "payment_data" => $intent)); } else { if ($intent->status == "requires_confirmation") { $this->log("Payment intent requires confirmation"); $body = json_encode(array("success" => true, "requires_confirmation" => true, "intent" => $last_intent, "payment_intent_client_secret" => $intent->client_secret, "payment_data" => $intent)); } else { $this->log("Invalid PaymentIntent status"); $body = json_encode(array("success" => false, "error" => "Invalid PaymentIntent status", "intent" => $intent != null ? $intent->id : '')); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } } } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); } catch (\Stripe\Exception\CardException $e) { $message_error = $e->getMessage(); $this->log("Error on create payment intents:" . $e->getMessage()); if (strpos($message_error, "Your card was declined") !== false) { $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $message_error, "intent" => $intent != null ? $intent->id : '')))); return; } if (strpos($message_error, "Your card does not support this type of purchase") !== false) { $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $message_error, "intent" => $intent != null ? $intent->id : '')))); return; } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $e->getMessage())))); } } function process() { require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("============== new request ====================="); $this->log("Process requested with data:" . json_encode($json_obj)); $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $intent = null; $last_intent = ''; try { $stripe = new \Stripe\StripeClient($secretKey); $paymentMethodId = $json_obj["payment_method_id"]; $totalPrice = $json_obj["total_price"]; $currency = $json_obj["currency"]; $customer = isset($json_obj["customer"]) ? $json_obj["customer"] : null; $payment_method_type = isset($json_obj["payment_method_type"]) ? $json_obj["payment_method_type"] : ''; try { $intent_data = isset($json_obj["intent_data"]) ? $json_obj["intent_data"] : array("amount" => $totalPrice, "currency" => $currency, "payment_method" => $paymentMethodId, "confirm" => true); $this->log("Params intent:" . json_encode($intent_data)); $intent_return_url = $intent_data["return_url"]; if (isset($json_obj["lastintent"]) && $json_obj["lastintent"] != '') { $this->log("Retrieve & update payment intents"); unset($intent_data["confirm"]); unset($intent_data["customer"]); $intentCurrentData = $stripe->paymentIntents->retrieve($json_obj["lastintent"]); $this->log("current intent Data:" . json_encode($intentCurrentData)); if ($intentCurrentData->status != "succeeded") { unset($intent_data["return_url"]); unset($intent_data["capture_method"]); unset($intent_data["confirm"]); unset($intent_data["confirmation_method"]); if ($intentCurrentData->status == "requires_action") { unset($intent_data["statement_descriptor"]); unset($intent_data["statement_descriptor_suffix"]); } if (isset($json_obj["checkonly"]) && $json_obj["checkonly"] == "yes") { if ($intentCurrentData->status == "requires_capture") { $this->log("Payment intent succeeded but need capture"); $this->log(json_encode($intentCurrentData)); $last_intent = $intentCurrentData->id; $body = json_encode(array("success" => true, "intent" => $last_intent, "payment_data" => $intentCurrentData, "payment_intent_client_secret" => $intentCurrentData->client_secret, "authorized" => true)); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } $this->log("Check status only"); $this->log("Payment Intent failed:" . $intentCurrentData->last_payment_error->message); $body = json_encode(array("success" => false, "error" => $intentCurrentData->last_payment_error->message, "intent" => $intentCurrentData != null ? $intentCurrentData->id : '')); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } $idata = $stripe->paymentIntents->update($json_obj["lastintent"], $intent_data); $this->log("IData:" . json_encode($idata)); $this->log("Payment intents updated"); $intent = $stripe->paymentIntents->retrieve($json_obj["lastintent"]); $this->log("Intent Data New:" . json_encode($intent)); if ($intent->status != "succeeded") { if (isset($json_obj["confirm_data"])) { $confirmData = $json_obj["confirm_data"]; $this->log("Confirm data from params gateway" . json_encode($confirmData)); } else { $confirmData = array("payment_method" => $paymentMethodId, "return_url" => $intent_return_url, "use_stripe_sdk" => true); } $intent = $stripe->paymentIntents->confirm($intent->id, $confirmData); } } else { $this->log("Payment intent succeeded"); $this->log(json_encode($intent)); $body = json_encode(array("success" => true, "intent" => $json_obj["lastintent"], "payment_data" => $intentCurrentData)); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } } else { $this->log("Create payment intents"); $intent = $stripe->paymentIntents->create($intent_data); $this->log("Payment intents created:" . json_encode($intent)); $last_intent = $intent->id; } } catch (Exception $e) { $this->log("Error in request to Stripe:" . $e->getMessage()); $errorObj = $e->getError(); $this->log("Stripe response:" . json_encode($errorObj)); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("success" => false, "error" => $e->getMessage(), "intent" => $last_intent)); $this->log("Error response:" . $body); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } if (isset($json_obj["return"]) && $intent) { set_transient($intent->id . "_return", $json_obj["return"], 7200); } if (isset($json_obj["cancel"]) && $intent) { set_transient($intent->id . "_cancel", $json_obj["cancel"], 7200); } if (in_array($intent->status, array("requires_action", "requires_source_action"))) { $this->log("Payment need 3DS"); $body = json_encode(array("success" => true, "requires_action" => true, "payment_intent_client_secret" => $intent->client_secret, "intent" => $last_intent, "payment_data" => $intent, "use_stripe_sdk" => $intent->next_action->type == "use_stripe_sdk", "next_action" => isset($intent->next_action) ? $intent->next_action : array())); } else { if ($intent->status == "succeeded") { $this->log("Payment intent succeeded"); $this->log(json_encode($intent)); $body = json_encode(array("success" => true, "intent" => $last_intent, "payment_data" => $intent)); } else { if ($intent->status == "requires_confirmation") { $this->log("Payment intent requires confirmation"); $body = json_encode(array("success" => true, "requires_action" => true, "payment_intent_client_secret" => $intent->client_secret, "intent" => $last_intent, "payment_data" => $intent)); } else { if ($intent->status == "requires_capture") { $this->log("Payment intent succeeded but need capture"); $this->log(json_encode($intent)); $body = json_encode(array("success" => true, "intent" => $last_intent, "payment_data" => $intent, "payment_intent_client_secret" => $intent->client_secret, "authorized" => true)); } else { $this->log("Invalid PaymentIntent status"); $body = json_encode(array("success" => false, "error" => "Invalid PaymentIntent status", "intent" => $intent != null ? $intent->id : '')); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); return; } } } } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => $body)); } catch (\Stripe\Exception\CardException $e) { $message_error = $e->getMessage(); $this->log("Error on create payment intents:" . $e->getMessage()); if (strpos($message_error, "Your card was declined") !== false) { $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $message_error, "intent" => $intent != null ? $intent->id : '')))); return; } if (strpos($message_error, "Your card does not support this type of purchase") !== false) { $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $message_error, "intent" => $intent != null ? $intent->id : '')))); return; } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $e->getMessage())))); } } function refund() { require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("Refund requested with data:" . json_encode($json_obj)); try { $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $payment_intent = isset($json_obj["paymentintent"]) && $json_obj["paymentintent"] != '' ? trim($json_obj["paymentintent"]) : ''; $charge_id = isset($json_obj["charge_id"]) && $json_obj["charge_id"] != '' ? trim($json_obj["charge_id"]) : ''; $reason = isset($json_obj["reason"]) && $json_obj["reason"] != '' ? trim($json_obj["reason"]) : ''; $amount = isset($json_obj["amount"]) && $json_obj["amount"] != '' ? intval($json_obj["amount"]) : 0; if ($amount > 0) { $stripe = new \Stripe\StripeClient($secretKey); $data_refund = array("charge" => $charge_id, "amount" => $amount); if (!empty($reason)) { $data_refund["reason"] = $reason; } $response = $stripe->refunds->create($data_refund); if (isset($response->status) && $response->status == "succeeded") { $this->log("Refund success"); $this->log("Refund response" . json_encode($response)); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => true, "status" => "succeeded", "refund" => $response)))); return; } } else { $this->log("Refund error: Amount is invalid"); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => "Amount is invalid")))); return; } } catch (Exception $e) { $this->log("Error in request to Stripe on refund:" . $e->getMessage()); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $e->getMessage())))); } } function create_webhook() { header("X-Frame-Options: ALLOWALL"); header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS"); header("Access-Control-Allow-Headers: X-Requested-With,Authorization,Content-Type"); header("Access-Control-Max-Age: 86400"); require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("Request create webhook:" . json_encode($json_obj)); try { $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $url = isset($json_obj["url"]) && $json_obj["url"] != '' ? trim($json_obj["url"]) : ''; $stripe = new \Stripe\StripeClient($secretKey); $webhooks = $stripe->webhookEndpoints->all(array("limit" => 100)); $this->log(json_encode($webhooks, JSON_PRETTY_PRINT)); if (is_object($webhooks) && isset($webhooks->data) && count($webhooks->data) > 0) { foreach ($webhooks->data as $_webhook) { if ($url == $_webhook->url) { $webhook = $stripe->webhookEndpoints->delete($_webhook->id); } } } $webhook = $stripe->webhookEndpoints->create(array("enabled_events" => array("charge.succeeded", "charge.failed", "charge.updated", "charge.captured", "checkout.session.async_payment_failed", "checkout.session.async_payment_succeeded", "checkout.session.completed", "checkout.session.expired"), "url" => $url)); update_option("mc_stripe_webhook", $webhook->secret); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => true, "status" => "succeeded", "webhook" => $webhook)))); return; } catch (Exception $e) { $this->log("Error in request to Stripe on create webhook:" . $e->getMessage()); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $e->getMessage())))); } } function capture() { require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("Capture requested with data:" . json_encode($json_obj)); try { $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $payment_intent = isset($json_obj["payment_intent"]) && $json_obj["payment_intent"] != '' ? trim($json_obj["payment_intent"]) : ''; if ($payment_intent != '') { if (strpos($payment_intent, "cs_") !== false) { $checkout_session = get_option($payment_intent); $this->log("checkout_session:" . json_encode($checkout_session)); if (isset($checkout_session["payment_intent"])) { $payment_intent = $checkout_session["payment_intent"]; } } $stripe = new \Stripe\StripeClient($secretKey); $response = $stripe->paymentIntents->capture($payment_intent); if (isset($response->status) && $response->status == "succeeded") { $this->log("Capture success"); $this->log("Capture success response" . json_encode($response)); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => true, "status" => $response->status, "data" => $response)))); return; } } else { $this->log("Capture error: Payment Intent empty"); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => "Payment Intent empty")))); return; } } catch (Exception $e) { $this->log("Error in request to Stripe on capture:" . $e->getMessage()); $msg = $e->getMessage(); $status = "failed"; if (strpos($msg, "has already been captured") !== false) { $status = "been_captured"; } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $msg, "status" => $status)))); } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => "Unknow error", "status" => "failed")))); } function void() { require MC_STRIPE_PATH . "autoload.php"; $input = file_get_contents("php://input"); $json_obj = json_decode($input, true); $this->log("Capture requested with data:" . json_encode($json_obj)); try { $publicKey = isset($json_obj["public_key"]) && $json_obj["public_key"] != '' ? trim($json_obj["public_key"]) : ''; $secretKey = isset($json_obj["secret_key"]) && $json_obj["secret_key"] != '' ? trim($json_obj["secret_key"]) : ''; $payment_intent = isset($json_obj["payment_intent"]) && $json_obj["payment_intent"] != '' ? trim($json_obj["payment_intent"]) : ''; if ($payment_intent != '') { $stripe = new \Stripe\StripeClient($secretKey); if (strpos($payment_intent, "cs_") !== false) { $checkout_session = get_option($payment_intent); if (isset($checkout_session["payment_intent"])) { $payment_intent = $checkout_session["payment_intent"]; } } $response = $stripe->paymentIntents->cancel($payment_intent); if (isset($response->status) && $response->status == "canceled") { $this->log("Cancel success"); $this->log("Response " . json_encode($response)); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => true, "status" => "canceled", "data" => $response)))); return; } } else { $this->log("Cancel error: Payment Intent empty"); $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => "Payment Intent empty")))); return; } } catch (Exception $e) { $this->log("Error in request to Stripe on cancel:" . $e->getMessage()); $msg = $e->getMessage(); $status = "failed"; $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => $msg, "status" => $status)))); } $this->response(array("code" => "HTTP/1.1 201 Created", "body" => json_encode(array("success" => false, "error" => "Unknow error", "status" => "failed")))); } } } ?>

Did this file decode correctly?

Original Code

<?php
 if (!defined("\x41\x42\x53\x50\x41\x54\110")) { die; } if (!class_exists("\115\145\163\150\x43\150\145\x63\153\x6f\165\164\123\164\x72\151\160\145")) { class MeshCheckoutStripe extends MeshCheckoutBase { private static $instance = null; private $table = "\155\x65\163\x68\143\x68\145\x63\x6b\x6f\x75\x74\x5f\x6f\x72\x64\x65\x72\x73"; private $gateway_url = ''; private $logger = null; public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } public function __construct() { $gateway_url = get_option("\x6d\x65\x73\150\x63\150\x65\143\x6b\x6f\x75\164\x5f\x63\x6f\x6e\156\x65\143\164\x5f\147\141\164\x65\167\x61\x79"); $this->gateway_url = strpos($gateway_url, "\154\x6f\143\141\154\150\x6f\163\164") > 0 || strpos($gateway_url, "\x77\157\162\x6b\56\x64\145\x76") > 0 ? $gateway_url : $gateway_url . "\57\x61\160\151"; } function success($token) { $trans = get_transient("\155\x63\x5f" . $token); delete_transient("\155\x63\137" . $token); if ($trans !== false && isset($trans["\x72\x65\x74\165\x72\156\x5f\x75\162\154"])) { $return_url = $trans["\x72\x65\x74\x75\162\x6e\137\165\162\x6c"]; if (strpos($return_url, "\x6d\x63\160\x61\171\x6d\x65\x6e\164") !== false) { $return_url .= $token . "\57"; } wp_redirect($return_url, 302); die; } else { header("\x48\x54\x54\x50\57\x31\x2e\x31\40\65\60\62\40\102\141\x64\40\x47\141\164\x65\167\141\171"); die; } } function cancel($token) { $trans = get_transient("\155\x63\137" . $token); $cancel_return = $trans["\x63\141\156\143\145\154\137\x72\145\x74\165\162\156"]; if (strpos($cancel_return, "\x6d\143\x70\x61\x79\155\x65\156\164") !== false) { $cancel_return .= $token . "\x2f"; } if ($trans !== false) { wp_redirect($cancel_return, 302); die; } else { header("\110\124\x54\x50\57\x31\56\61\40\x35\x30\x32\x20\102\141\144\x20\x47\x61\x74\x65\x77\x61\171"); die; } } function webhook() { header("\x58\55\106\162\x61\155\145\55\117\160\164\151\x6f\x6e\x73\x3a\x20\x41\x4c\114\117\127\101\114\x4c"); header("\x41\143\x63\145\x73\163\55\103\x6f\156\x74\162\157\154\x2d\101\154\x6c\x6f\x77\x2d\x4f\162\151\x67\x69\156\72\x20\52"); header("\101\x63\143\x65\x73\163\x2d\x43\x6f\x6e\x74\162\157\154\x2d\101\154\x6c\x6f\167\x2d\x4d\x65\x74\x68\x6f\144\x73\x3a\x20\120\x55\x54\54\x20\107\105\124\x2c\40\120\x4f\123\124\54\x20\104\x45\114\x45\x54\x45\x2c\x20\117\x50\124\111\x4f\116\x53"); header("\x41\143\143\x65\x73\x73\55\x43\157\156\x74\x72\157\154\55\x41\154\154\157\x77\x2d\110\145\141\144\145\162\x73\72\x20\130\55\x52\x65\161\x75\x65\163\164\145\144\55\x57\151\x74\150\x2c\101\165\x74\x68\x6f\x72\151\x7a\x61\164\151\x6f\156\x2c\103\157\x6e\164\x65\x6e\x74\55\124\x79\160\x65"); header("\101\143\x63\x65\163\x73\55\103\x6f\156\x74\162\157\x6c\55\115\x61\x78\x2d\x41\147\145\x3a\40\70\x36\64\x30\60"); require MC_STRIPE_PATH . "\141\x75\164\157\154\157\x61\x64\x2e\x70\150\160"; $payload = @file_get_contents("\160\x68\160\x3a\57\57\x69\156\160\165\164"); $params = json_decode($payload, true); $sig_header = $_SERVER["\110\x54\x54\x50\x5f\123\124\x52\111\x50\105\137\x53\111\107\116\101\124\125\x52\105"]; $secretKey = get_option("\x6d\x63\x5f\163\x74\x72\151\160\x65\137\x73\145\x63\x72\x65\x74"); $this->log("\123\x74\162\151\x70\x65\x20\x65\166\145\x6e\164\x73"); $this->log("\x53\x74\x72\151\x70\145\40\123\x69\x67\x3a\40" . $sig_header); $event = null; try { $webhook = get_option("\155\143\137\163\164\x72\151\160\x65\x5f\x77\x65\x62\150\157\x6f\153"); $stripe_secret = get_option("\155\143\x5f\x73\164\162\x69\160\145\137\x73\145\143\162\x65\164"); $this->log("\x53\164\x72\151\160\145\40\x57\145\x62\150\x6f\x6f\x6b\x3a\x20" . $webhook); $this->log("\123\x74\x72\x69\160\x65\40\x53\145\x63\162\145\164\72\x20" . $stripe_secret); $this->log("\123\x74\162\x69\160\145\40\x50\x61\171\154\x6f\141\x64\72\x20" . $payload); \Stripe\Stripe::setApiKey($stripe_secret); $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $webhook); $payment_intent = ''; if (isset($params["\x64\x61\164\141"]) && isset($params["\144\x61\x74\x61"]["\x6f\x62\152\145\x63\x74"]) && isset($params["\x64\141\x74\141"]["\157\142\x6a\x65\143\x74"]["\x70\141\x79\x6d\x65\156\164\x5f\151\x6e\x74\x65\x6e\164"])) { $payment_intent = $params["\144\x61\164\x61"]["\157\142\152\145\143\x74"]["\160\141\x79\155\x65\156\164\137\x69\x6e\164\145\156\x74"]; } $this->log("\120\x41\131\115\105\x4e\124\137\111\x4e\124\x45\x4e\x54\x3a" . $payment_intent); if (!empty($payment_intent)) { $payment_data = get_option($payment_intent); } switch ($event->type) { case "\x63\150\141\x72\147\145\56\x63\x61\x70\x74\x75\162\145\144": $this->log("\x63\150\141\162\147\x65\x2e\143\x61\160\x74\x75\162\x65\x64"); $event_data = array("\151\144" => $params["\144\141\164\141"]["\x6f\x62\x6a\x65\143\164"]["\151\x64"], "\142\141\x6c\x61\x6e\143\145\x5f\164\x72\x61\156\163\x61\143\164\151\x6f\x6e" => $params["\x64\x61\164\x61"]["\157\142\x6a\x65\x63\164"]["\142\141\x6c\141\156\143\x65\137\x74\162\141\x6e\x73\141\143\x74\151\157\156"], "\x63\x75\x73\x74\157\x6d\145\162" => $params["\x64\141\164\x61"]["\x6f\x62\x6a\x65\x63\164"]["\x63\165\x73\164\157\x6d\145\162"], "\162\145\143\x65\151\160\164\x5f\165\162\154" => $params["\144\x61\164\141"]["\x6f\x62\152\145\x63\x74"]["\162\145\143\x65\151\160\164\137\165\162\154"], "\x72\x65\x66\x75\x6e\144\137\x75\x72\x6c" => $params["\x64\141\164\x61"]["\157\x62\152\x65\143\164"]["\162\x65\146\x75\x6e\144\x73"]["\165\162\x6c"], "\x61\x6d\x6f\165\156\164" => $params["\x64\x61\164\141"]["\157\x62\152\145\143\x74"]["\141\x6d\157\x75\156\x74"], "\x61\155\x6f\165\x6e\x74\x5f\143\x61\160\164\165\x72\x65\x64" => $params["\x64\x61\x74\141"]["\x6f\x62\x6a\145\x63\x74"]["\141\x6d\x6f\x75\x6e\164\x5f\x63\x61\x70\x74\x75\x72\x65\144"], "\x61\x6d\x6f\165\156\164\137\x72\145\x66\165\x6e\144\x65\x64" => $params["\x64\141\x74\x61"]["\x6f\142\x6a\145\x63\x74"]["\141\x6d\157\165\x6e\x74\x5f\162\x65\x66\x75\156\144\145\144"]); update_option($payment_intent . "\137\x63\x68\141\162\x67\145", $event_data); if ($params["\144\141\164\141"]["\x6f\142\x6a\x65\143\164"]["\143\141\x70\x74\165\x72\x65\144"]) { $this->sendCompleted($payment_intent); } $this->response(array("\143\x6f\x64\x65" => "\110\124\x54\120\57\x31\x2e\x31\x20\x32\60\x31\x20\103\x72\145\x61\164\145\144", "\142\x6f\144\171" => json_encode(array("\163\x75\x63\143\145\x73\x73" => 1)))); break; case "\143\150\x61\162\147\x65\56\x75\160\144\141\164\145\x64": $this->log("\x63\150\x61\162\147\145\56\165\x70\144\x61\x74\x65\x64"); $event_data = array("\151\144" => $params["\x64\141\x74\x61"]["\x6f\x62\152\x65\143\x74"]["\151\144"], "\142\141\154\x61\156\143\145\137\x74\x72\141\156\x73\x61\x63\x74\x69\157\156" => $params["\x64\x61\x74\141"]["\157\142\152\145\x63\x74"]["\142\141\154\141\156\143\x65\x5f\x74\162\141\156\163\x61\143\164\x69\x6f\156"], "\x63\x75\163\x74\157\155\145\x72" => $params["\x64\141\164\141"]["\157\x62\x6a\145\x63\164"]["\143\x75\163\164\157\155\x65\x72"], "\x72\145\143\145\151\160\x74\x5f\x75\162\x6c" => $params["\x64\141\164\x61"]["\157\142\152\145\143\x74"]["\x72\x65\x63\x65\151\x70\x74\137\x75\162\x6c"], "\x72\145\x66\x75\156\x64\137\x75\162\x6c" => $params["\x64\141\x74\x61"]["\x6f\x62\152\145\143\x74"]["\162\145\x66\165\156\x64\163"]["\165\162\x6c"], "\x61\x6d\157\165\156\164" => $params["\144\141\x74\141"]["\157\142\x6a\x65\x63\164"]["\x61\x6d\x6f\165\x6e\x74"], "\x61\x6d\157\x75\156\x74\x5f\x63\x61\160\164\x75\x72\145\x64" => $params["\144\x61\164\x61"]["\x6f\x62\x6a\145\x63\164"]["\141\155\x6f\x75\x6e\x74\137\x63\141\x70\164\x75\x72\x65\144"], "\x61\x6d\157\165\156\x74\x5f\x72\145\x66\x75\x6e\x64\x65\144" => $params["\x64\x61\164\141"]["\157\x62\152\145\143\164"]["\x61\x6d\x6f\165\156\164\x5f\162\145\x66\x75\156\144\x65\144"]); update_option($payment_intent . "\x5f\x63\x68\141\x72\147\x65", $event_data); $this->sendCompleted($payment_intent); $this->response(array("\143\157\x64\x65" => "\110\124\x54\120\57\61\x2e\61\x20\62\60\61\x20\x43\162\x65\x61\x74\x65\144", "\142\157\x64\171" => json_encode(array("\x73\x75\143\143\145\x73\x73" => 1)))); break; case "\143\x68\141\x72\147\x65\x2e\163\x75\x63\143\x65\x65\x64\x65\x64": $this->log("\x63\x68\141\162\147\x65\56\x73\x75\143\143\x65\x65\144\x65\144"); $event_data = array("\151\144" => $params["\x64\141\164\141"]["\157\x62\152\145\x63\x74"]["\x69\144"], "\142\141\x6c\x61\x6e\x63\145\137\x74\x72\x61\x6e\163\141\143\164\151\x6f\x6e" => $params["\x64\x61\x74\x61"]["\157\x62\x6a\145\143\164"]["\x62\141\154\x61\x6e\x63\x65\137\164\x72\x61\x6e\163\141\x63\164\151\x6f\x6e"], "\143\x75\163\x74\157\155\x65\x72" => $params["\x64\x61\164\141"]["\157\142\152\145\143\x74"]["\143\165\163\x74\157\x6d\145\x72"], "\162\x65\x63\145\x69\x70\164\x5f\x75\x72\x6c" => $params["\144\x61\164\x61"]["\157\142\152\x65\x63\164"]["\x72\145\143\145\x69\x70\164\137\165\162\x6c"], "\x72\x65\146\x75\156\144\x5f\165\x72\x6c" => $params["\x64\x61\164\141"]["\x6f\x62\x6a\x65\143\x74"]["\162\x65\x66\x75\156\x64\x73"]["\x75\x72\154"], "\x61\x6d\157\x75\x6e\164" => $params["\144\141\164\x61"]["\x6f\142\152\145\143\x74"]["\141\155\x6f\165\x6e\x74"], "\141\x6d\157\x75\156\164\137\143\141\160\164\x75\x72\x65\x64" => $params["\144\141\164\x61"]["\x6f\142\x6a\x65\x63\x74"]["\x61\x6d\x6f\x75\156\164\x5f\143\141\x70\164\165\x72\x65\144"], "\x61\155\x6f\165\156\x74\137\x72\x65\146\165\x6e\x64\x65\x64" => $params["\144\141\164\141"]["\157\x62\152\x65\x63\x74"]["\x61\155\157\165\x6e\164\137\x72\x65\x66\x75\x6e\x64\x65\144"], "\143\141\x70\164\x75\162\x65\144" => $params["\144\141\x74\141"]["\157\x62\x6a\x65\x63\164"]["\143\x61\160\x74\165\162\145\x64"]); $this->log("\x73\141\x76\145\40\x63\150\141\162\x67\x65\x20\144\x61\x74\x61"); update_option($payment_intent . "\137\143\150\141\x72\147\145", $event_data); $this->sendCompleted($payment_intent); $this->response(array("\x63\157\x64\x65" => "\110\124\124\x50\x2f\x31\56\61\x20\62\60\61\40\x43\x72\145\x61\164\145\144", "\x62\x6f\x64\171" => json_encode(array("\163\165\x63\143\145\x73\x73" => 1)))); break; case "\x63\x68\145\143\153\157\165\x74\x2e\163\x65\x73\x73\x69\157\x6e\x2e\143\157\x6d\x70\x6c\145\164\145\x64": $this->log("\x63\x68\145\143\x6b\157\165\x74\56\163\145\163\x73\x69\x6f\156\56\x63\157\155\x70\x6c\x65\x74\145\x64"); $event_data = array("\151\144" => $params["\144\x61\x74\x61"]["\x6f\x62\x6a\145\143\x74"]["\x69\x64"], "\x70\141\171\x6d\x65\x6e\164\x5f\163\x74\141\x74\x75\x73" => $params["\x64\141\x74\141"]["\x6f\142\x6a\x65\x63\164"]["\160\141\x79\x6d\145\156\164\x5f\163\x74\x61\x74\165\163"], "\143\x75\x73\x74\157\x6d\x65\x72" => $params["\x64\141\x74\x61"]["\x6f\142\x6a\145\143\164"]["\143\x75\163\164\x6f\x6d\145\x72"], "\143\x75\163\x74\157\155\x65\162\137\144\145\164\141\151\154\x73" => $params["\x64\x61\x74\x61"]["\157\x62\152\x65\143\x74"]["\x63\165\163\164\x6f\155\x65\x72\137\144\145\x74\x61\151\x6c\x73"], "\141\155\x6f\x75\156\164\137\x74\157\x74\141\154" => $params["\x64\x61\164\x61"]["\157\x62\x6a\145\143\x74"]["\x61\x6d\x6f\x75\x6e\164\137\164\157\164\x61\x6c"], "\141\x6d\157\165\156\x74\x5f\163\165\x62\164\157\x74\141\154" => $params["\x64\141\x74\x61"]["\x6f\142\x6a\145\143\x74"]["\x61\155\157\165\156\164\137\163\x75\x62\164\x6f\x74\141\154"]); $checkout_session_id = $params["\x64\x61\164\x61"]["\157\142\x6a\145\143\164"]["\151\144"]; $cs_data = get_option($checkout_session_id); $cs_data["\x70\x61\171\x6d\145\156\x74\137\151\x6e\164\x65\x6e\x74"] = $payment_intent; $this->log("\x63\150\x65\x63\x6b\x6f\x75\164\40\144\x61\164\x61"); update_option($payment_intent, $cs_data); update_option($payment_intent . "\137\x63\163\143", $event_data); update_option($checkout_session_id, $cs_data); $this->sendCompleted($payment_intent); $this->response(array("\143\157\x64\x65" => "\x48\124\x54\x50\57\61\56\61\40\x32\x30\61\x20\103\x72\x65\141\164\x65\144", "\142\157\x64\171" => json_encode(array("\163\x75\143\143\145\163\x73" => 1)))); break; } } catch (\UnexpectedValueException $e) { $this->log("\x49\x6e\x76\x61\154\151\144\40\x70\x61\171\154\157\x61\144\72" . $e->getMessage()); header("\110\x54\x54\x50\x2f\x31\x2e\x31\x20\x34\x30\60\x20\x42\x61\x64\x20\122\145\x71\x75\x65\163\164\x20"); die; } catch (\Stripe\Exception\SignatureVerificationException $e) { $this->log("\x49\156\x76\141\154\x69\x64\40\163\x69\147\156\x61\164\165\x72\145\x3a" . $e->getMessage()); header("\110\x54\x54\120\57\x31\x2e\x31\x20\x34\x30\x30\40\102\141\144\x20\122\145\x71\x75\145\x73\x74\40"); die; } $this->log("\x50\141\163\163\145\144\40\163\151\147\156\x61\164\x75\162\x65\x20\166\145\x72\151\146\151\x63\141\x74\x69\x6f\156\41"); header("\110\x54\124\x50\57\x31\56\x31\40\x32\60\60\40\117\x4b"); } function create() { $params = json_decode(file_get_contents("\160\x68\160\72\57\57\151\x6e\x70\165\x74"), true); $this->log("\x63\x72\x65\141\x74\x65\40\157\x72\144\145\x72\x3a"); $this->log(json_encode($params, JSON_PRETTY_PRINT)); $publicKey = isset($params["\x70\165\142\x6c\151\x63\137\x6b\145\171"]) && $params["\x70\165\142\x6c\151\x63\137\x6b\145\171"] != '' ? trim($params["\160\165\142\x6c\151\x63\x5f\153\x65\x79"]) : ''; $secretKey = isset($params["\x73\x65\x63\162\145\164\x5f\x6b\145\171"]) && $params["\x73\145\x63\162\x65\164\137\x6b\145\x79"] != '' ? trim($params["\x73\145\143\162\145\x74\x5f\153\145\x79"]) : ''; $webhook = isset($params["\x77\x65\142\150\157\157\x6b"]) && $params["\167\x65\x62\x68\x6f\x6f\153"] != '' ? trim($params["\x77\x65\142\150\157\157\x6b"]) : ''; update_option("\155\143\137\x73\164\x72\x69\160\x65\137\160\165\142\154\x69\x63", $publicKey); update_option("\155\x63\137\x73\164\x72\151\160\145\137\x73\x65\143\162\x65\164", $secretKey); update_option("\155\143\137\163\x74\162\x69\160\x65\137\167\x65\x62\150\157\157\153", $webhook); $trans_key = "\155\x63\x5f" . $params["\155\145\163\x68\x74\x6f\153\145\x6e"]; set_transient($trans_key, array("\162\x65\x74\x75\162\x6e\137\165\162\154" => $params["\x72\x65\164\x75\162\156\x5f\x75\x72\x6c"], "\x63\141\156\x63\x65\x6c\x5f\x72\x65\164\x75\x72\x6e" => $params["\143\141\x6e\x63\x65\x6c\x5f\162\145\x74\165\x72\156"]), 7200); if (empty($secretKey)) { $this->log("\105\162\162\157\162\72\x20\123\145\x63\162\145\x74\x20\153\145\171\x20\x69\163\x20\145\155\x70\x74\171"); return null; } try { require MC_STRIPE_PATH . "\141\165\164\x6f\x6c\157\x61\x64\x2e\160\150\160"; $stripe = new \Stripe\StripeClient($secretKey); $requestParams = json_decode($params["\x64\x61\x74\141"], true); $checkout_session = $stripe->checkout->sessions->create($requestParams); $this->log(json_encode($checkout_session, JSON_PRETTY_PRINT)); $this->log("\125\x52\114\x3a\40{$checkout_session->url}\xa"); $this->log("\x53\164\x61\x74\x75\x73\72\x20{$checkout_session->payment_status}\12"); $this->log("\x4f\162\x64\145\x72\x20\x49\x44\72\x20{$checkout_session->id}\xa"); $this->log(json_encode($checkout_session, JSON_PRETTY_PRINT)); $checkout_session["\163\164\x61\x74\165\163"] = "\x43\x52\x45\101\124\105\104"; $res_data = array("\x69\x64" => $checkout_session->id, "\x63\x72\x65\141\x74\145\x64" => $checkout_session->created, "\x65\x78\160\151\162\145\x73\x5f\141\x74" => $checkout_session->expires_at, "\160\x61\171\155\145\x6e\x74\x5f\151\x6e\x74\x65\x6e\x74" => $checkout_session->payment_intent, "\160\141\171\x6d\145\156\164\137\x6d\145\x74\150\157\x64\137\164\171\160\145\163" => $checkout_session->payment_method_types, "\x70\x61\171\155\145\x6e\x74\x5f\163\x74\141\164\165\163" => $checkout_session->payment_status, "\141\155\157\165\x6e\164\x5f\x74\157\164\x61\154" => $checkout_session->amount_total, "\141\x6d\157\x75\x6e\x74\x5f\x73\165\x62\164\157\164\x61\154" => $checkout_session->amount_subtotal, "\165\162\154" => $checkout_session->url, "\163\x74\x61\164\x75\163" => "\x43\122\105\101\124\x45\x44"); $checkout_session_data = array("\164\157\153\145\156" => $params["\x6d\145\x73\x68\x74\x6f\x6b\145\x6e"], "\143\141\160\164\165\162\145\137\x6d\x65\x74\150\x6f\x64" => "\x61\x75\164\157\155\141\x74\x69\x63"); if (isset($requestParams["\x70\x61\171\x6d\x65\156\x74\137\151\156\x74\145\156\164\137\144\x61\x74\x61"]) && isset($requestParams["\160\141\x79\x6d\145\x6e\x74\x5f\x69\x6e\x74\x65\156\x74\137\144\x61\164\141"]["\x63\x61\160\x74\x75\x72\145\137\155\145\x74\150\x6f\144"])) { $checkout_session_data["\143\141\160\164\165\x72\x65\137\155\145\x74\x68\x6f\144"] = "\155\141\x6e\165\x61\154"; } update_option($checkout_session->id, $checkout_session_data); if (!empty($checkout_session->payment_intent)) { update_option($checkout_session->payment_intent, array("\x74\157\153\x65\x6e" => $params["\x6d\145\x73\150\164\x6f\x6b\x65\156"])); } $this->response(array("\x63\x6f\x64\145" => "\x48\x54\x54\x50\x2f\x31\56\61\x20\x32\x30\x31\40\103\162\145\x61\x74\x65\144", "\x62\157\x64\x79" => json_encode(array("\x73\165\x63\143\x65\x73\163" => 1, "\162\145\144\x69\162\145\143\164" => $checkout_session->url, "\162\145\x73\x75\154\x74" => $res_data)))); } catch (Exception $e) { $this->log("\x45\162\162\x6f\x72\x20\x6f\156\x20\x72\145\x71\165\145\x73\x74\40\x74\x6f\40\123\164\x72\151\x70\145\72\x20" . $e->getMessage()); return null; } $this->log("\116\157\x74\x20\145\162\x72\157\x72\40\x62\x75\x74\40\x73\157\x6d\x65\x74\150\x69\156\147\x20\x77\162\x6f\156\x67\56"); return null; } function sendCompleted($payment_intent) { $this->log("\163\145\x6e\x64\x43\x6f\155\x70\x6c\x65\x74\145\x64\x3a" . $payment_intent); $payment = get_option($payment_intent); $csc = get_option($payment_intent . "\137\x63\163\x63"); $charge = get_option($payment_intent . "\137\143\150\141\162\x67\x65"); if (isset($payment["\x74\x6f\x6b\145\156"]) && !empty($payment["\164\x6f\153\145\x6e"]) && isset($csc["\x69\144"]) && isset($charge["\x69\144"])) { $data = array("\164\157\153\145\x6e" => $payment["\164\x6f\x6b\x65\x6e"], "\160\141\x79\155\145\x6e\x74\137\x69\156\x74\x65\156\164" => $payment_intent, "\163\164\x61\x74\x75\x73" => "\x70\141\151\x64", "\x64\141\164\141" => json_encode(array("\x63\163\x63" => $csc, "\143\x68\x61\162\x67\145" => $charge, "\x70\x61\171\155\145\156\164\x5f\151\156\x74\x65\x6e\x74" => $payment_intent))); if (isset($charge["\143\x61\x70\x74\x75\162\145\x64"]) && !$charge["\x63\141\160\164\x75\x72\145\144"]) { $data["\163\x74\141\164\165\163"] = "\x61\165\x74\x68\x6f\162\151\172\145\144"; } $gateway_url = str_replace("\150\x74\x74\x70\x3a\x2f\x2f\x77\157\x72\x6b\56\x64\x65\166\72\70\x38\70\70\57\x61\x70\x69", "\x68\x74\x74\160\72\x2f\57\x6c\x6f\143\141\x6c\x68\x6f\x73\x74\72\x38\x38\70\70", $this->gateway_url); $this->log("\104\141\x74\x61\x20\x72\145\x61\x64\x79"); $this->log(rtrim($gateway_url, "\x2f") . "\x2f\160\x61\x79\57\163\164\162\151\160\x65\x5f\165\x70\144\141\x74\x65"); $this->log(json_encode($data, JSON_PRETTY_PRINT)); $response = wp_remote_request(rtrim($this->gateway_url, "\x2f") . "\57\x70\x61\171\57\163\164\162\x69\160\x65\x5f\165\x70\x64\x61\164\x65", array("\162\x65\152\145\x63\x74\137\x75\x6e\163\141\146\x65\137\165\x72\x6c\x73" => false, "\x6d\x65\164\x68\x6f\x64" => "\x50\x4f\x53\x54", "\x62\157\x64\171" => $data, "\164\151\155\x65\157\165\164" => 30, "\x75\x73\145\x72\x2d\141\x67\x65\156\x74" => "\123\x61\x6c\x65\163\x47\145\156\57\x31\56\60", "\x68\x74\x74\x70\x76\145\x72\163\151\x6f\156" => "\x31\x2e\61")); $this->log(json_encode($response, JSON_PRETTY_PRINT)); } else { $this->log("\x6e\157\x74\x20\145\x6e\157\165\x67\150\40\x64\141\x74\x61"); } } public function response($data) { if (isset($data["\x63\157\x64\x65"])) { header($data["\143\x6f\144\145"]); } if (isset($data["\142\x6f\x64\171"])) { echo $data["\x62\x6f\x64\x79"]; } $this->log("\103\x6f\155\160\154\145\x74\x65\144\40\162\145\163\160\157\156\x73\145\72" . $data["\143\x6f\x64\x65"]); die; } function checkout() { include_once MC_TEMPLATE_PATH . "\163\164\162\x69\x70\145\x2e\160\x68\160"; die; } function process_old() { require MC_STRIPE_PATH . "\141\x75\164\157\154\157\x61\144\x2e\x70\x68\x70"; $input = file_get_contents("\x70\x68\160\x3a\57\x2f\151\x6e\x70\165\x74"); $json_obj = json_decode($input, true); $this->log("\x50\162\x6f\x63\x65\163\x73\x20\162\x65\x71\165\x65\x73\x74\x65\144\40\x77\151\164\150\40\144\x61\x74\x61\72" . json_encode($json_obj)); $publicKey = isset($json_obj["\x70\x75\x62\154\151\x63\x5f\x6b\x65\171"]) && $json_obj["\x70\x75\x62\x6c\151\x63\137\x6b\145\171"] != '' ? trim($json_obj["\x70\x75\142\x6c\151\143\x5f\153\x65\x79"]) : ''; $secretKey = isset($json_obj["\x73\145\143\x72\x65\164\x5f\153\x65\x79"]) && $json_obj["\163\x65\143\162\145\x74\137\153\x65\x79"] != '' ? trim($json_obj["\x73\145\143\162\145\164\x5f\153\145\x79"]) : ''; $intent = null; $last_intent = ''; try { $stripe = new \Stripe\StripeClient($secretKey); $paymentMethodId = $json_obj["\x70\141\x79\155\145\x6e\164\x5f\155\x65\x74\x68\157\x64\x5f\151\x64"]; $totalPrice = $json_obj["\164\x6f\x74\x61\x6c\x5f\x70\162\x69\x63\145"]; $currency = $json_obj["\x63\165\162\x72\x65\x6e\x63\x79"]; $customer = isset($json_obj["\x63\165\x73\x74\x6f\x6d\145\x72"]) ? $json_obj["\143\165\x73\x74\x6f\x6d\145\x72"] : null; try { if (isset($json_obj["\x70\x61\171\x6d\145\x6e\x74\x69\156\x74\145\156\x74"]) && $json_obj["\160\x61\x79\x6d\145\156\x74\x69\156\164\x65\156\164"] != '') { $last_intent = $json_obj["\160\141\x79\155\x65\156\164\x69\156\164\145\156\x74"]; $intent = $stripe->paymentIntents->retrieve($json_obj["\x70\x61\x79\x6d\x65\x6e\x74\151\156\x74\x65\156\164"]); $this->log("\x50\141\171\x6d\145\156\x74\40\x69\156\164\145\156\164\x73\x20\x72\x65\x74\162\x69\x65\166\145"); } elseif (isset($json_obj["\x70\141\x79\x6d\x65\156\164\137\x6d\145\164\x68\157\x64\x5f\x69\x64"])) { $this->log("\x3d\x3d\75\75\75\75\75\75\x3d\x3d\75\75\x3d\75\40\x73\x74\141\162\164\40\x6e\145\x77\x20\x74\162\141\x6e\x73\x61\x63\x74\x69\157\x6e\40\x3d\x3d\x3d\75\75\x3d\x3d\75\x3d\75\x3d\75\75\75\75\x3d\x3d\x3d\75\75\x3d"); $this->log("\103\162\x65\x61\164\145\40\160\x61\x79\155\x65\156\164\x20\151\x6e\x74\145\156\x74\163"); $intent_data = isset($json_obj["\151\156\x74\145\156\x74\137\x64\x61\164\x61"]) ? $json_obj["\151\x6e\164\145\156\x74\x5f\x64\141\x74\x61"] : array("\x61\x6d\157\x75\x6e\x74" => $totalPrice, "\x63\x75\162\x72\x65\156\x63\x79" => $currency, "\160\x61\171\155\x65\x6e\x74\x5f\x6d\x65\x74\x68\x6f\144" => $paymentMethodId, "\x63\x6f\x6e\x66\151\162\x6d" => true); if (!empty($customer) && (!isset($json_obj["\x6c\141\163\164\151\156\x74\x65\x6e\x74"]) || isset($json_obj["\x6c\141\163\x74\151\156\x74\145\156\164"]) && $json_obj["\x6c\141\163\x74\151\156\164\x65\x6e\164"] == '')) { try { $this->log("\103\162\145\x61\x74\145\40\x63\165\x73\164\157\x6d\145\x72"); $customerCreated = $stripe->customers->create($customer); $this->log("\x43\x75\x73\164\x6f\155\x65\162\40\x63\x72\145\x61\x74\145\x64\x3a" . json_encode($customerCreated)); $intent_data["\143\x75\163\x74\157\155\x65\x72"] = $customerCreated->id; } catch (Exception $e) { $this->log("\105\x72\x72\x6f\162\x20\x69\x6e\x20\x63\162\x65\x61\164\145\x20\x63\165\163\164\x6f\155\145\x72\x3a" . $e->getMessage()); $this->log(json_encode($e->getError())); $errorObj = $e->getError(); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("\163\x75\143\143\x65\x73\x73" => false, "\145\x72\x72\x6f\162" => $e->getMessage(), "\151\x6e\x74\145\156\x74" => $last_intent)); $this->log("\x45\162\x72\x6f\162\40\x72\145\x73\x70\x6f\156\x73\145\x3a" . $body); $this->response(array("\143\157\144\145" => "\x48\x54\124\120\57\x31\56\x31\40\62\x30\61\40\x43\162\145\141\164\145\144", "\142\157\x64\171" => $body)); return; } } $this->log("\120\141\x72\x61\x6d\163\40\x69\x6e\164\x65\156\164\x3a" . json_encode($intent_data)); if (isset($json_obj["\x6c\x61\163\x74\151\x6e\164\x65\x6e\164"]) && $json_obj["\x6c\x61\x73\164\151\156\164\x65\156\x74"] != '') { unset($intent_data["\x61\165\164\157\x6d\x61\164\x69\143\x5f\160\x61\171\x6d\145\156\164\137\155\x65\x74\x68\157\x64\x73"]); unset($intent_data["\143\157\156\x66\x69\x72\x6d"]); unset($intent_data["\143\165\163\x74\157\155\145\162"]); $intentCurrentData = $stripe->paymentIntents->retrieve($json_obj["\x6c\x61\163\164\x69\156\164\x65\156\x74"]); $this->log("\103\x75\162\x72\145\156\164\x20\x49\x6e\164\145\x6e\164\40\x44\x61\x74\141\72" . json_encode($intentCurrentData)); $stripe->paymentIntents->update($json_obj["\154\141\163\x74\151\156\x74\x65\x6e\x74"], $intent_data); $intent = $stripe->paymentIntents->confirm($json_obj["\154\141\x73\164\151\x6e\164\145\156\164"], array("\x70\x61\x79\x6d\x65\156\164\137\x6d\145\164\150\157\144" => $paymentMethodId)); } else { $intent = $stripe->paymentIntents->create($intent_data); $this->log("\x50\141\171\155\145\x6e\164\40\x69\x6e\x74\x65\156\x74\163\x20\143\162\x65\141\164\145\144\72" . json_encode($intent)); } } } catch (Exception $e) { $this->log("\105\x72\x72\157\x72\40\x69\x6e\40\x72\x65\161\x75\x65\163\164\x20\164\157\x20\123\164\162\x69\x70\145\72" . $e->getMessage()); $errorObj = $e->getError(); $this->log("\x53\164\x72\151\x70\x65\40\x72\x65\x73\160\x6f\x6e\163\x65\72" . json_encode($errorObj)); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("\163\165\x63\x63\x65\163\163" => false, "\x65\162\162\x6f\x72" => $e->getMessage(), "\151\x6e\x74\x65\156\164" => $last_intent)); $this->log("\x45\x72\162\157\x72\x20\x72\x65\x73\160\157\156\x73\x65\72" . $body); $this->response(array("\x63\157\144\145" => "\x48\124\x54\120\57\61\x2e\x31\x20\x32\x30\x31\x20\x43\162\x65\141\x74\x65\x64", "\x62\x6f\x64\171" => $body)); return; } if (in_array($intent->status, array("\x72\x65\x71\x75\151\x72\x65\163\137\x61\143\164\x69\157\x6e", "\162\145\x71\x75\x69\x72\145\163\137\x73\157\165\162\x63\x65\137\141\x63\x74\x69\x6f\156")) && $intent->next_action->type == "\165\x73\x65\137\163\x74\162\x69\x70\x65\x5f\163\x64\x6b") { $this->log("\x50\141\171\155\145\x6e\x74\x20\x6e\145\x65\144\x20\x33\x44\x53"); $body = json_encode(array("\163\x75\143\x63\145\x73\163" => true, "\162\145\x71\165\x69\162\145\x73\137\141\x63\164\x69\x6f\156" => true, "\160\141\x79\155\145\x6e\x74\x5f\x69\x6e\164\x65\156\164\x5f\143\x6c\151\145\x6e\x74\137\x73\x65\143\162\145\164" => $intent->client_secret, "\x69\156\x74\x65\x6e\x74" => $last_intent, "\160\x61\171\x6d\145\156\164\x5f\144\141\164\x61" => $intent)); } else { if ($intent->status == "\163\x75\x63\143\145\145\144\x65\x64") { $this->log("\x50\x61\171\x6d\x65\x6e\x74\x20\x69\156\164\x65\x6e\x74\x20\163\165\x63\143\x65\145\x64\x65\144"); $this->log(json_encode($intent)); $body = json_encode(array("\163\x75\x63\143\x65\163\x73" => true, "\x69\x6e\x74\145\x6e\x74" => $last_intent, "\160\141\171\x6d\x65\x6e\x74\x5f\144\x61\x74\141" => $intent)); } else { if ($intent->status == "\162\145\161\165\x69\162\145\163\x5f\143\x6f\x6e\146\151\x72\x6d\x61\x74\151\157\156") { $this->log("\x50\141\171\155\145\156\164\40\151\156\164\145\156\164\x20\x72\145\x71\165\x69\x72\145\x73\40\143\157\156\x66\151\x72\x6d\141\164\x69\157\156"); $body = json_encode(array("\163\165\143\x63\x65\163\x73" => true, "\x72\x65\x71\x75\x69\162\145\163\x5f\143\x6f\x6e\146\x69\162\155\141\x74\x69\157\x6e" => true, "\151\156\x74\x65\156\164" => $last_intent, "\x70\141\171\x6d\x65\x6e\164\x5f\x69\156\x74\x65\x6e\164\137\143\x6c\x69\145\x6e\164\137\163\x65\x63\x72\x65\164" => $intent->client_secret, "\x70\141\171\155\145\156\164\137\144\x61\x74\141" => $intent)); } else { $this->log("\x49\156\x76\x61\154\x69\144\40\120\x61\x79\155\145\x6e\x74\111\156\164\x65\156\164\40\x73\164\141\x74\x75\x73"); $body = json_encode(array("\163\165\143\x63\x65\163\x73" => false, "\145\162\x72\157\162" => "\111\x6e\166\141\x6c\x69\x64\40\x50\x61\171\x6d\x65\156\x74\111\156\x74\145\x6e\164\x20\163\x74\x61\164\x75\x73", "\151\x6e\x74\145\156\164" => $intent != null ? $intent->id : '')); $this->response(array("\x63\157\x64\x65" => "\110\124\124\x50\57\61\x2e\x31\x20\x32\x30\61\x20\103\162\x65\x61\164\x65\x64", "\142\157\144\x79" => $body)); return; } } } $this->response(array("\143\x6f\x64\x65" => "\x48\x54\x54\120\57\x31\56\x31\x20\x32\60\x31\40\x43\162\x65\141\164\x65\x64", "\142\x6f\x64\171" => $body)); } catch (\Stripe\Exception\CardException $e) { $message_error = $e->getMessage(); $this->log("\x45\162\162\157\162\40\x6f\x6e\40\143\162\145\141\x74\x65\40\x70\141\x79\155\x65\156\164\x20\x69\x6e\164\145\156\x74\x73\x3a" . $e->getMessage()); if (strpos($message_error, "\131\157\165\162\x20\143\141\x72\144\x20\167\x61\x73\40\144\145\143\154\x69\x6e\x65\x64") !== false) { $this->response(array("\x63\x6f\144\145" => "\x48\x54\x54\x50\57\x31\56\x31\40\x32\60\x31\40\103\162\x65\141\164\145\x64", "\142\157\144\x79" => json_encode(array("\163\x75\143\143\145\163\163" => false, "\x65\x72\x72\x6f\162" => $message_error, "\151\x6e\164\x65\156\x74" => $intent != null ? $intent->id : '')))); return; } if (strpos($message_error, "\x59\157\165\162\40\143\141\162\144\40\144\157\145\x73\x20\156\x6f\164\x20\x73\165\160\x70\157\162\164\x20\x74\150\x69\x73\x20\x74\171\160\x65\40\157\x66\x20\160\165\162\143\x68\141\163\145") !== false) { $this->response(array("\143\x6f\x64\145" => "\110\x54\124\x50\x2f\61\56\61\40\x32\60\x31\x20\103\162\x65\141\x74\145\x64", "\x62\157\x64\x79" => json_encode(array("\163\x75\143\143\145\x73\x73" => false, "\x65\x72\x72\157\x72" => $message_error, "\151\156\164\x65\156\x74" => $intent != null ? $intent->id : '')))); return; } $this->response(array("\143\157\144\145" => "\110\124\124\x50\57\x31\x2e\61\40\62\60\61\40\103\x72\x65\141\x74\145\144", "\x62\157\x64\x79" => json_encode(array("\163\x75\x63\x63\145\163\163" => false, "\145\162\x72\157\x72" => $e->getMessage())))); } } function process() { require MC_STRIPE_PATH . "\x61\165\x74\157\154\157\141\x64\56\160\x68\160"; $input = file_get_contents("\x70\x68\x70\x3a\x2f\57\x69\156\x70\x75\164"); $json_obj = json_decode($input, true); $this->log("\x3d\75\75\x3d\75\75\x3d\75\x3d\x3d\x3d\75\75\x3d\40\156\145\x77\x20\x72\145\161\x75\x65\163\x74\x20\75\75\x3d\x3d\75\75\75\75\75\x3d\x3d\x3d\75\75\75\x3d\75\x3d\75\x3d\75"); $this->log("\120\x72\157\143\145\x73\163\40\x72\x65\x71\165\x65\x73\164\x65\x64\x20\x77\151\x74\x68\x20\144\141\164\141\72" . json_encode($json_obj)); $publicKey = isset($json_obj["\x70\165\142\x6c\151\x63\x5f\x6b\x65\171"]) && $json_obj["\160\x75\x62\154\151\x63\x5f\x6b\145\171"] != '' ? trim($json_obj["\x70\x75\x62\154\x69\143\x5f\x6b\x65\x79"]) : ''; $secretKey = isset($json_obj["\x73\145\x63\x72\145\x74\137\x6b\145\x79"]) && $json_obj["\163\145\143\162\x65\x74\x5f\153\145\171"] != '' ? trim($json_obj["\163\x65\143\162\145\164\x5f\153\145\171"]) : ''; $intent = null; $last_intent = ''; try { $stripe = new \Stripe\StripeClient($secretKey); $paymentMethodId = $json_obj["\x70\x61\171\155\x65\156\x74\x5f\x6d\145\x74\150\157\x64\x5f\151\x64"]; $totalPrice = $json_obj["\x74\x6f\164\141\x6c\x5f\160\x72\x69\143\x65"]; $currency = $json_obj["\x63\x75\x72\x72\145\x6e\143\x79"]; $customer = isset($json_obj["\x63\165\163\x74\x6f\155\x65\162"]) ? $json_obj["\x63\165\x73\164\157\x6d\x65\x72"] : null; $payment_method_type = isset($json_obj["\x70\141\x79\155\145\156\x74\137\155\145\164\150\x6f\x64\x5f\164\x79\x70\145"]) ? $json_obj["\x70\x61\171\x6d\x65\156\x74\x5f\155\145\x74\x68\157\144\137\x74\x79\x70\x65"] : ''; try { $intent_data = isset($json_obj["\151\x6e\164\x65\156\164\x5f\144\x61\x74\141"]) ? $json_obj["\x69\x6e\164\145\x6e\x74\137\x64\141\164\141"] : array("\x61\x6d\157\165\156\164" => $totalPrice, "\x63\x75\x72\162\x65\x6e\x63\x79" => $currency, "\x70\x61\x79\155\145\156\164\x5f\x6d\x65\x74\150\157\144" => $paymentMethodId, "\x63\157\x6e\x66\x69\162\155" => true); $this->log("\x50\x61\162\141\x6d\x73\x20\x69\x6e\x74\145\x6e\x74\x3a" . json_encode($intent_data)); $intent_return_url = $intent_data["\x72\x65\164\165\162\156\x5f\x75\162\x6c"]; if (isset($json_obj["\154\141\163\164\x69\156\x74\x65\x6e\x74"]) && $json_obj["\154\x61\163\164\151\x6e\x74\x65\156\x74"] != '') { $this->log("\x52\145\164\162\x69\145\166\x65\40\x26\x20\x75\160\x64\x61\164\x65\x20\x70\x61\x79\x6d\145\156\164\40\x69\156\x74\x65\156\x74\163"); unset($intent_data["\143\157\156\x66\151\x72\155"]); unset($intent_data["\x63\165\163\x74\157\155\x65\x72"]); $intentCurrentData = $stripe->paymentIntents->retrieve($json_obj["\x6c\141\163\164\151\156\164\x65\156\164"]); $this->log("\x63\x75\162\x72\x65\x6e\164\40\x69\156\164\145\156\x74\x20\x44\x61\x74\141\72" . json_encode($intentCurrentData)); if ($intentCurrentData->status != "\x73\165\x63\x63\145\145\144\145\144") { unset($intent_data["\162\x65\164\x75\162\156\x5f\165\x72\x6c"]); unset($intent_data["\x63\x61\160\x74\165\162\x65\137\155\x65\x74\150\x6f\144"]); unset($intent_data["\x63\157\156\x66\x69\x72\155"]); unset($intent_data["\143\x6f\156\146\x69\162\155\141\164\151\157\x6e\x5f\x6d\145\x74\150\x6f\x64"]); if ($intentCurrentData->status == "\162\145\161\x75\151\162\x65\163\x5f\x61\143\x74\151\157\156") { unset($intent_data["\x73\x74\141\164\145\x6d\x65\156\164\137\x64\145\x73\x63\162\151\160\x74\x6f\x72"]); unset($intent_data["\163\164\141\164\145\x6d\145\x6e\x74\137\x64\x65\163\143\162\151\160\x74\157\x72\137\x73\165\x66\146\151\x78"]); } if (isset($json_obj["\x63\150\x65\143\153\x6f\156\x6c\x79"]) && $json_obj["\x63\x68\145\143\x6b\157\156\x6c\171"] == "\x79\x65\163") { if ($intentCurrentData->status == "\162\x65\x71\165\151\x72\x65\x73\x5f\143\x61\160\164\x75\162\x65") { $this->log("\x50\141\x79\155\145\156\x74\x20\151\x6e\x74\145\156\x74\x20\x73\165\143\143\145\145\144\x65\144\40\142\165\x74\40\x6e\145\145\x64\40\143\141\x70\164\x75\x72\145"); $this->log(json_encode($intentCurrentData)); $last_intent = $intentCurrentData->id; $body = json_encode(array("\x73\165\x63\x63\x65\163\x73" => true, "\x69\x6e\x74\x65\x6e\164" => $last_intent, "\160\141\171\x6d\x65\x6e\164\137\x64\x61\x74\141" => $intentCurrentData, "\160\x61\x79\x6d\x65\156\x74\x5f\x69\156\x74\145\156\164\137\143\154\151\x65\156\164\137\x73\145\143\x72\145\164" => $intentCurrentData->client_secret, "\141\165\x74\150\157\x72\151\x7a\x65\x64" => true)); $this->response(array("\143\x6f\144\145" => "\x48\124\124\120\57\61\56\61\40\x32\60\61\x20\103\162\x65\x61\x74\x65\x64", "\142\157\144\x79" => $body)); return; } $this->log("\103\150\145\143\153\40\163\x74\x61\164\165\x73\x20\x6f\156\154\x79"); $this->log("\x50\141\x79\x6d\145\156\164\40\111\156\164\145\x6e\164\x20\146\x61\x69\154\145\144\x3a" . $intentCurrentData->last_payment_error->message); $body = json_encode(array("\163\x75\x63\143\x65\163\163" => false, "\145\162\162\x6f\x72" => $intentCurrentData->last_payment_error->message, "\x69\x6e\164\145\156\x74" => $intentCurrentData != null ? $intentCurrentData->id : '')); $this->response(array("\143\157\x64\145" => "\x48\x54\x54\x50\57\x31\x2e\61\x20\x32\60\61\x20\103\162\145\x61\x74\145\x64", "\x62\x6f\x64\171" => $body)); return; } $idata = $stripe->paymentIntents->update($json_obj["\154\141\x73\164\x69\x6e\x74\145\156\x74"], $intent_data); $this->log("\111\104\x61\x74\x61\x3a" . json_encode($idata)); $this->log("\x50\x61\171\x6d\x65\156\x74\40\151\x6e\x74\x65\156\x74\x73\40\x75\x70\x64\141\164\x65\x64"); $intent = $stripe->paymentIntents->retrieve($json_obj["\x6c\141\163\x74\151\156\164\145\156\x74"]); $this->log("\111\x6e\x74\145\156\164\40\x44\x61\x74\141\x20\116\x65\x77\x3a" . json_encode($intent)); if ($intent->status != "\163\x75\x63\x63\145\145\x64\x65\x64") { if (isset($json_obj["\x63\157\x6e\146\x69\x72\x6d\137\x64\141\164\141"])) { $confirmData = $json_obj["\x63\157\156\146\151\x72\x6d\137\x64\141\164\141"]; $this->log("\x43\x6f\x6e\146\151\x72\x6d\x20\x64\x61\x74\141\40\146\x72\x6f\x6d\x20\x70\x61\x72\141\x6d\163\x20\147\141\x74\145\x77\141\171" . json_encode($confirmData)); } else { $confirmData = array("\160\141\x79\x6d\145\x6e\x74\x5f\x6d\x65\164\x68\x6f\144" => $paymentMethodId, "\162\x65\x74\165\x72\156\x5f\165\162\x6c" => $intent_return_url, "\x75\x73\145\137\163\164\x72\151\x70\x65\137\163\x64\x6b" => true); } $intent = $stripe->paymentIntents->confirm($intent->id, $confirmData); } } else { $this->log("\x50\141\x79\155\x65\x6e\x74\40\x69\156\x74\x65\156\164\x20\163\165\x63\x63\145\145\x64\145\x64"); $this->log(json_encode($intent)); $body = json_encode(array("\163\x75\143\x63\145\x73\163" => true, "\x69\156\164\x65\x6e\x74" => $json_obj["\154\141\x73\164\151\x6e\x74\145\156\x74"], "\160\141\171\155\x65\x6e\164\x5f\x64\141\164\141" => $intentCurrentData)); $this->response(array("\143\157\144\145" => "\x48\x54\124\120\57\61\x2e\x31\40\62\x30\x31\x20\x43\162\145\x61\164\x65\x64", "\142\157\x64\x79" => $body)); return; } } else { $this->log("\103\162\145\x61\164\x65\40\160\x61\171\155\x65\x6e\164\x20\151\156\x74\145\156\x74\x73"); $intent = $stripe->paymentIntents->create($intent_data); $this->log("\x50\x61\x79\x6d\x65\156\x74\40\151\x6e\x74\x65\156\164\163\x20\143\162\145\141\164\145\144\72" . json_encode($intent)); $last_intent = $intent->id; } } catch (Exception $e) { $this->log("\105\x72\x72\157\x72\40\x69\x6e\40\162\145\161\x75\x65\x73\164\40\x74\x6f\40\x53\x74\162\151\160\145\x3a" . $e->getMessage()); $errorObj = $e->getError(); $this->log("\123\x74\x72\x69\x70\145\x20\x72\x65\x73\160\157\156\163\145\72" . json_encode($errorObj)); if (isset($errorObj->payment_intent)) { $last_intent = $errorObj->payment_intent->id; } $body = json_encode(array("\x73\165\143\x63\x65\x73\163" => false, "\145\x72\x72\x6f\x72" => $e->getMessage(), "\151\156\164\x65\156\x74" => $last_intent)); $this->log("\105\162\x72\157\x72\x20\162\x65\x73\x70\157\x6e\163\x65\72" . $body); $this->response(array("\x63\157\x64\145" => "\x48\124\124\120\x2f\61\56\x31\x20\x32\x30\61\40\x43\x72\x65\141\164\x65\144", "\142\157\x64\x79" => $body)); return; } if (isset($json_obj["\162\x65\164\165\162\156"]) && $intent) { set_transient($intent->id . "\137\x72\145\164\165\162\156", $json_obj["\162\x65\164\x75\x72\156"], 7200); } if (isset($json_obj["\x63\141\x6e\x63\145\x6c"]) && $intent) { set_transient($intent->id . "\x5f\143\x61\x6e\x63\145\x6c", $json_obj["\x63\141\156\x63\145\x6c"], 7200); } if (in_array($intent->status, array("\x72\145\161\x75\x69\162\145\163\x5f\141\143\164\151\157\156", "\x72\145\x71\165\x69\x72\x65\x73\137\x73\157\165\x72\x63\145\x5f\x61\x63\164\151\157\x6e"))) { $this->log("\120\x61\x79\155\x65\x6e\164\40\x6e\145\145\144\x20\63\x44\x53"); $body = json_encode(array("\x73\x75\143\143\x65\x73\163" => true, "\x72\x65\x71\x75\151\162\x65\x73\137\x61\x63\x74\151\157\156" => true, "\160\x61\171\155\145\156\164\x5f\x69\156\164\145\x6e\x74\x5f\143\154\x69\145\156\x74\x5f\163\145\143\162\x65\x74" => $intent->client_secret, "\x69\x6e\x74\145\x6e\x74" => $last_intent, "\160\141\x79\155\145\156\164\x5f\x64\141\x74\141" => $intent, "\x75\163\x65\137\163\x74\x72\151\160\x65\137\x73\x64\x6b" => $intent->next_action->type == "\x75\x73\x65\x5f\163\164\162\x69\160\145\137\x73\x64\x6b", "\x6e\x65\x78\x74\x5f\141\x63\x74\x69\x6f\156" => isset($intent->next_action) ? $intent->next_action : array())); } else { if ($intent->status == "\x73\x75\x63\x63\145\145\x64\x65\144") { $this->log("\x50\x61\x79\x6d\x65\156\x74\40\x69\x6e\x74\x65\x6e\x74\40\x73\165\143\143\145\145\144\145\144"); $this->log(json_encode($intent)); $body = json_encode(array("\163\x75\x63\x63\x65\163\163" => true, "\x69\x6e\x74\145\156\x74" => $last_intent, "\x70\x61\171\155\x65\156\x74\137\x64\141\164\x61" => $intent)); } else { if ($intent->status == "\162\145\161\x75\x69\x72\x65\163\137\x63\x6f\x6e\146\151\x72\155\x61\164\151\x6f\x6e") { $this->log("\120\x61\x79\155\145\x6e\x74\40\151\x6e\164\x65\156\164\40\x72\145\161\x75\x69\162\x65\x73\40\x63\157\156\146\151\x72\155\x61\x74\x69\x6f\x6e"); $body = json_encode(array("\163\x75\x63\x63\145\163\x73" => true, "\x72\145\161\165\151\x72\x65\163\137\141\x63\x74\x69\157\156" => true, "\x70\x61\x79\x6d\x65\156\164\x5f\151\156\164\x65\x6e\x74\x5f\143\x6c\x69\x65\x6e\164\137\163\145\x63\x72\145\164" => $intent->client_secret, "\x69\x6e\164\x65\x6e\164" => $last_intent, "\x70\141\x79\x6d\145\156\164\x5f\144\141\164\141" => $intent)); } else { if ($intent->status == "\162\x65\161\x75\151\162\145\x73\137\143\141\x70\164\165\x72\145") { $this->log("\120\141\171\155\145\x6e\164\40\151\156\x74\x65\156\x74\40\x73\x75\143\x63\145\x65\144\x65\144\x20\x62\x75\164\40\156\x65\145\144\x20\x63\x61\x70\x74\165\x72\x65"); $this->log(json_encode($intent)); $body = json_encode(array("\x73\165\143\x63\145\163\x73" => true, "\151\156\164\145\x6e\x74" => $last_intent, "\x70\141\x79\155\x65\x6e\x74\x5f\x64\141\164\x61" => $intent, "\160\141\171\155\145\156\x74\x5f\x69\156\164\x65\x6e\x74\x5f\x63\x6c\x69\145\x6e\x74\137\x73\145\143\x72\x65\x74" => $intent->client_secret, "\141\165\x74\150\157\x72\151\x7a\145\x64" => true)); } else { $this->log("\111\156\166\141\x6c\151\144\40\120\141\171\155\x65\x6e\x74\x49\156\x74\x65\x6e\164\x20\163\x74\141\164\x75\x73"); $body = json_encode(array("\x73\x75\x63\x63\145\x73\x73" => false, "\145\x72\162\157\162" => "\111\156\166\141\154\151\144\40\x50\141\x79\155\x65\156\x74\x49\x6e\164\x65\156\164\40\x73\164\x61\164\165\x73", "\x69\156\x74\145\x6e\164" => $intent != null ? $intent->id : '')); $this->response(array("\143\157\144\145" => "\110\x54\124\x50\x2f\x31\56\x31\40\x32\60\61\40\x43\x72\x65\141\164\145\144", "\142\x6f\144\x79" => $body)); return; } } } } $this->response(array("\143\x6f\144\x65" => "\x48\x54\x54\120\57\61\56\61\40\62\60\x31\40\x43\162\x65\141\x74\x65\x64", "\142\157\144\x79" => $body)); } catch (\Stripe\Exception\CardException $e) { $message_error = $e->getMessage(); $this->log("\105\x72\x72\157\162\x20\x6f\156\x20\x63\162\145\x61\164\145\40\x70\141\x79\x6d\x65\x6e\164\40\x69\156\164\x65\156\x74\x73\x3a" . $e->getMessage()); if (strpos($message_error, "\x59\157\165\162\40\x63\x61\162\x64\40\167\141\x73\40\144\x65\x63\x6c\x69\156\145\144") !== false) { $this->response(array("\143\157\x64\x65" => "\110\x54\x54\x50\57\61\x2e\61\x20\62\x30\x31\x20\103\x72\145\141\x74\145\x64", "\142\157\x64\171" => json_encode(array("\163\165\143\x63\x65\163\163" => false, "\x65\x72\x72\157\x72" => $message_error, "\151\x6e\164\x65\x6e\x74" => $intent != null ? $intent->id : '')))); return; } if (strpos($message_error, "\x59\x6f\165\x72\x20\143\x61\x72\x64\x20\x64\x6f\x65\163\40\x6e\157\x74\x20\163\x75\160\x70\x6f\x72\x74\x20\164\x68\x69\163\x20\164\171\x70\x65\40\157\146\40\x70\165\162\x63\x68\141\163\x65") !== false) { $this->response(array("\x63\x6f\144\x65" => "\x48\x54\x54\120\57\61\56\61\40\x32\60\61\x20\x43\x72\x65\141\x74\145\144", "\142\157\144\x79" => json_encode(array("\163\165\143\143\x65\163\x73" => false, "\145\162\162\x6f\162" => $message_error, "\151\156\164\145\156\164" => $intent != null ? $intent->id : '')))); return; } $this->response(array("\x63\x6f\144\145" => "\110\x54\124\120\57\x31\56\61\40\x32\60\61\x20\x43\x72\x65\141\x74\145\144", "\142\x6f\x64\x79" => json_encode(array("\163\x75\x63\x63\x65\x73\x73" => false, "\x65\x72\x72\157\162" => $e->getMessage())))); } } function refund() { require MC_STRIPE_PATH . "\141\x75\164\157\154\157\x61\x64\56\x70\150\160"; $input = file_get_contents("\160\x68\x70\72\x2f\57\151\x6e\x70\165\164"); $json_obj = json_decode($input, true); $this->log("\122\145\x66\x75\156\144\40\x72\x65\x71\x75\145\x73\x74\x65\x64\40\167\x69\164\150\40\x64\x61\x74\141\72" . json_encode($json_obj)); try { $publicKey = isset($json_obj["\160\165\142\x6c\151\143\137\x6b\x65\171"]) && $json_obj["\x70\165\142\x6c\151\x63\137\153\x65\x79"] != '' ? trim($json_obj["\x70\165\142\154\x69\143\x5f\153\x65\x79"]) : ''; $secretKey = isset($json_obj["\163\x65\x63\x72\145\x74\x5f\153\145\x79"]) && $json_obj["\163\x65\x63\162\x65\x74\x5f\153\145\x79"] != '' ? trim($json_obj["\163\145\x63\162\x65\x74\x5f\x6b\x65\x79"]) : ''; $payment_intent = isset($json_obj["\160\x61\171\155\x65\156\164\151\x6e\164\145\x6e\164"]) && $json_obj["\160\x61\x79\155\x65\156\164\x69\x6e\164\x65\156\164"] != '' ? trim($json_obj["\x70\x61\171\155\145\156\x74\151\x6e\x74\145\156\x74"]) : ''; $charge_id = isset($json_obj["\x63\150\141\162\147\145\137\x69\x64"]) && $json_obj["\143\x68\141\162\147\145\x5f\151\144"] != '' ? trim($json_obj["\143\150\x61\162\147\x65\x5f\x69\x64"]) : ''; $reason = isset($json_obj["\x72\x65\141\163\x6f\x6e"]) && $json_obj["\162\145\x61\163\157\x6e"] != '' ? trim($json_obj["\162\145\x61\x73\x6f\156"]) : ''; $amount = isset($json_obj["\x61\x6d\x6f\165\156\164"]) && $json_obj["\141\155\x6f\165\x6e\164"] != '' ? intval($json_obj["\141\155\x6f\x75\156\x74"]) : 0; if ($amount > 0) { $stripe = new \Stripe\StripeClient($secretKey); $data_refund = array("\143\x68\x61\x72\147\x65" => $charge_id, "\141\155\x6f\x75\156\x74" => $amount); if (!empty($reason)) { $data_refund["\162\145\x61\163\x6f\156"] = $reason; } $response = $stripe->refunds->create($data_refund); if (isset($response->status) && $response->status == "\x73\165\x63\x63\145\145\144\x65\x64") { $this->log("\122\x65\x66\165\x6e\144\40\x73\165\x63\143\145\163\x73"); $this->log("\122\x65\x66\x75\156\144\x20\162\145\163\160\157\156\163\x65" . json_encode($response)); $this->response(array("\143\x6f\x64\x65" => "\110\x54\124\x50\57\x31\56\x31\x20\x32\x30\61\40\x43\x72\x65\141\x74\x65\144", "\x62\x6f\144\x79" => json_encode(array("\x73\x75\143\x63\x65\x73\x73" => true, "\163\164\141\x74\x75\x73" => "\x73\165\143\x63\145\145\144\x65\144", "\162\x65\x66\165\156\144" => $response)))); return; } } else { $this->log("\x52\x65\x66\x75\x6e\x64\x20\145\162\x72\x6f\162\x3a\x20\101\155\x6f\165\x6e\x74\x20\x69\x73\x20\x69\156\166\141\x6c\x69\144"); $this->response(array("\143\x6f\x64\x65" => "\x48\124\x54\120\57\x31\56\x31\40\62\x30\61\x20\103\x72\145\141\164\x65\x64", "\142\157\144\x79" => json_encode(array("\163\x75\x63\143\x65\x73\x73" => false, "\145\162\x72\x6f\162" => "\101\155\157\x75\156\164\40\151\163\40\x69\x6e\x76\141\x6c\x69\x64")))); return; } } catch (Exception $e) { $this->log("\x45\162\162\157\162\x20\x69\x6e\x20\x72\145\x71\165\145\x73\x74\x20\164\x6f\x20\123\164\x72\x69\160\145\x20\157\x6e\40\x72\145\146\x75\156\x64\72" . $e->getMessage()); $this->response(array("\x63\x6f\x64\x65" => "\x48\x54\124\x50\57\61\56\x31\40\x32\60\x31\40\103\x72\145\x61\x74\145\x64", "\x62\x6f\x64\x79" => json_encode(array("\163\x75\143\143\145\163\x73" => false, "\145\x72\x72\157\x72" => $e->getMessage())))); } } function create_webhook() { header("\130\55\106\162\x61\155\145\55\117\x70\164\151\157\x6e\x73\72\40\x41\x4c\114\x4f\127\x41\x4c\x4c"); header("\x41\x63\143\145\163\x73\x2d\103\157\x6e\x74\x72\157\x6c\x2d\101\x6c\x6c\157\x77\x2d\117\162\151\147\x69\x6e\72\40\x2a"); header("\101\143\143\145\163\x73\x2d\103\x6f\x6e\x74\162\157\x6c\x2d\x41\x6c\154\157\167\x2d\115\145\x74\150\x6f\144\163\72\x20\120\125\x54\x2c\x20\107\105\x54\x2c\40\120\x4f\x53\124\54\x20\104\x45\x4c\105\x54\105\x2c\x20\x4f\x50\124\111\x4f\x4e\123"); header("\x41\x63\143\x65\163\x73\x2d\103\x6f\x6e\x74\162\157\154\x2d\x41\154\154\157\167\55\x48\145\x61\x64\x65\162\163\x3a\40\x58\x2d\x52\x65\x71\165\145\163\x74\145\144\x2d\127\x69\164\x68\x2c\x41\x75\164\150\157\x72\x69\172\141\164\151\157\x6e\54\103\157\x6e\x74\x65\x6e\x74\x2d\124\171\160\x65"); header("\x41\x63\x63\x65\163\163\x2d\103\157\x6e\x74\x72\157\154\x2d\x4d\x61\x78\x2d\x41\147\145\x3a\40\70\66\x34\60\60"); require MC_STRIPE_PATH . "\x61\165\164\157\154\157\x61\x64\56\x70\x68\160"; $input = file_get_contents("\160\150\x70\x3a\57\57\151\x6e\160\x75\164"); $json_obj = json_decode($input, true); $this->log("\122\145\x71\165\x65\163\x74\40\x63\162\x65\141\164\x65\40\167\x65\142\150\157\157\153\x3a" . json_encode($json_obj)); try { $publicKey = isset($json_obj["\160\x75\x62\154\x69\x63\x5f\x6b\145\x79"]) && $json_obj["\x70\165\x62\154\151\x63\137\x6b\x65\x79"] != '' ? trim($json_obj["\160\165\x62\x6c\151\143\137\153\145\171"]) : ''; $secretKey = isset($json_obj["\163\x65\x63\162\145\x74\137\x6b\145\171"]) && $json_obj["\163\x65\x63\162\x65\x74\x5f\x6b\x65\x79"] != '' ? trim($json_obj["\x73\x65\x63\162\145\164\x5f\153\145\171"]) : ''; $url = isset($json_obj["\x75\162\154"]) && $json_obj["\165\x72\x6c"] != '' ? trim($json_obj["\165\x72\x6c"]) : ''; $stripe = new \Stripe\StripeClient($secretKey); $webhooks = $stripe->webhookEndpoints->all(array("\x6c\x69\155\x69\164" => 100)); $this->log(json_encode($webhooks, JSON_PRETTY_PRINT)); if (is_object($webhooks) && isset($webhooks->data) && count($webhooks->data) > 0) { foreach ($webhooks->data as $_webhook) { if ($url == $_webhook->url) { $webhook = $stripe->webhookEndpoints->delete($_webhook->id); } } } $webhook = $stripe->webhookEndpoints->create(array("\145\156\x61\142\154\145\144\137\x65\166\x65\x6e\164\x73" => array("\x63\x68\141\x72\147\145\x2e\163\165\x63\x63\145\x65\x64\x65\x64", "\143\x68\x61\x72\x67\x65\x2e\146\141\x69\154\x65\x64", "\x63\150\141\x72\x67\145\56\x75\x70\x64\x61\x74\145\x64", "\143\x68\x61\x72\147\x65\x2e\x63\141\x70\x74\165\x72\x65\144", "\x63\150\145\143\153\157\x75\x74\56\163\145\x73\x73\151\157\x6e\56\141\163\171\x6e\x63\137\160\x61\171\x6d\x65\156\x74\x5f\x66\x61\151\154\x65\144", "\x63\x68\x65\143\x6b\157\x75\x74\x2e\163\145\163\163\151\x6f\156\56\x61\163\171\x6e\x63\x5f\x70\141\171\155\x65\156\164\137\163\165\x63\x63\x65\x65\144\145\x64", "\143\x68\x65\x63\153\x6f\x75\x74\x2e\163\145\x73\163\151\x6f\156\56\143\157\x6d\x70\x6c\x65\x74\145\144", "\143\150\145\143\153\x6f\165\x74\56\x73\x65\x73\x73\151\x6f\x6e\56\x65\170\x70\x69\x72\x65\144"), "\x75\162\x6c" => $url)); update_option("\155\143\137\x73\164\x72\151\x70\145\137\167\x65\x62\x68\157\157\x6b", $webhook->secret); $this->response(array("\143\157\x64\145" => "\x48\124\124\x50\57\61\x2e\61\x20\x32\x30\61\40\x43\x72\x65\141\x74\x65\x64", "\x62\x6f\x64\x79" => json_encode(array("\163\x75\143\x63\x65\163\x73" => true, "\x73\164\x61\x74\165\x73" => "\163\165\143\x63\x65\145\144\x65\144", "\x77\x65\142\150\x6f\x6f\153" => $webhook)))); return; } catch (Exception $e) { $this->log("\105\x72\x72\157\162\x20\x69\156\x20\x72\145\161\165\x65\x73\x74\x20\x74\x6f\40\x53\x74\x72\x69\160\145\40\157\x6e\x20\143\162\145\x61\x74\145\x20\167\x65\142\150\x6f\157\x6b\72" . $e->getMessage()); $this->response(array("\143\157\x64\x65" => "\x48\x54\124\120\57\61\56\61\40\x32\x30\x31\40\x43\x72\145\141\x74\145\x64", "\142\157\144\171" => json_encode(array("\163\165\143\143\145\163\163" => false, "\x65\x72\x72\157\x72" => $e->getMessage())))); } } function capture() { require MC_STRIPE_PATH . "\x61\x75\x74\x6f\x6c\157\x61\144\x2e\x70\150\160"; $input = file_get_contents("\160\150\x70\x3a\x2f\57\x69\x6e\160\x75\x74"); $json_obj = json_decode($input, true); $this->log("\103\141\160\164\165\162\x65\x20\162\145\161\165\x65\x73\164\145\x64\40\167\151\x74\x68\40\x64\x61\164\x61\x3a" . json_encode($json_obj)); try { $publicKey = isset($json_obj["\x70\x75\142\154\x69\x63\x5f\x6b\145\171"]) && $json_obj["\x70\165\x62\154\151\143\x5f\x6b\x65\x79"] != '' ? trim($json_obj["\160\165\142\154\x69\x63\137\153\x65\x79"]) : ''; $secretKey = isset($json_obj["\x73\145\x63\x72\145\164\137\153\x65\171"]) && $json_obj["\x73\145\x63\x72\145\x74\137\153\145\171"] != '' ? trim($json_obj["\163\x65\143\x72\x65\164\x5f\x6b\x65\171"]) : ''; $payment_intent = isset($json_obj["\x70\141\x79\155\145\156\x74\137\151\156\x74\145\x6e\164"]) && $json_obj["\x70\141\171\x6d\x65\x6e\x74\137\x69\x6e\164\x65\156\x74"] != '' ? trim($json_obj["\x70\x61\x79\155\x65\156\x74\x5f\x69\156\164\x65\156\x74"]) : ''; if ($payment_intent != '') { if (strpos($payment_intent, "\x63\x73\137") !== false) { $checkout_session = get_option($payment_intent); $this->log("\x63\150\x65\x63\153\x6f\165\x74\x5f\163\145\x73\x73\x69\157\x6e\72" . json_encode($checkout_session)); if (isset($checkout_session["\160\141\x79\x6d\145\x6e\x74\x5f\151\x6e\164\x65\x6e\x74"])) { $payment_intent = $checkout_session["\160\141\x79\155\x65\x6e\164\137\x69\x6e\164\145\156\164"]; } } $stripe = new \Stripe\StripeClient($secretKey); $response = $stripe->paymentIntents->capture($payment_intent); if (isset($response->status) && $response->status == "\x73\x75\x63\143\145\x65\x64\x65\x64") { $this->log("\103\x61\x70\164\165\x72\145\x20\x73\165\143\x63\x65\163\163"); $this->log("\x43\141\160\x74\x75\162\x65\x20\x73\x75\x63\143\145\x73\x73\40\162\x65\x73\x70\x6f\156\x73\145" . json_encode($response)); $this->response(array("\143\157\144\145" => "\x48\x54\124\x50\x2f\x31\56\x31\x20\x32\60\61\x20\x43\x72\x65\141\164\145\144", "\142\x6f\144\x79" => json_encode(array("\x73\165\x63\x63\145\163\x73" => true, "\x73\x74\141\164\x75\x73" => $response->status, "\x64\x61\164\x61" => $response)))); return; } } else { $this->log("\x43\141\160\164\x75\162\145\40\145\162\x72\x6f\x72\x3a\x20\120\141\x79\155\x65\156\x74\40\x49\156\x74\x65\x6e\x74\40\x65\155\x70\164\x79"); $this->response(array("\143\157\144\x65" => "\x48\124\x54\x50\x2f\x31\56\x31\x20\62\60\x31\40\x43\162\145\141\x74\145\144", "\x62\x6f\x64\x79" => json_encode(array("\163\165\143\143\145\163\x73" => false, "\x65\162\x72\157\162" => "\x50\x61\171\x6d\x65\156\164\40\111\x6e\x74\145\156\164\40\145\x6d\160\164\171")))); return; } } catch (Exception $e) { $this->log("\105\x72\162\157\x72\x20\151\156\40\x72\x65\161\165\x65\163\x74\40\164\157\x20\123\164\162\151\160\x65\x20\x6f\x6e\40\143\x61\160\x74\165\162\x65\x3a" . $e->getMessage()); $msg = $e->getMessage(); $status = "\146\141\151\x6c\145\144"; if (strpos($msg, "\150\141\x73\x20\x61\154\162\x65\141\144\171\40\142\x65\x65\156\x20\143\x61\x70\x74\165\162\145\x64") !== false) { $status = "\142\145\x65\156\x5f\143\141\160\x74\x75\162\145\144"; } $this->response(array("\x63\x6f\x64\x65" => "\x48\x54\x54\120\57\61\56\x31\40\62\x30\61\40\x43\162\x65\x61\x74\145\x64", "\x62\x6f\144\171" => json_encode(array("\x73\165\x63\x63\145\163\163" => false, "\145\x72\x72\157\162" => $msg, "\x73\164\x61\x74\165\163" => $status)))); } $this->response(array("\x63\x6f\x64\x65" => "\110\124\124\x50\x2f\61\x2e\61\40\62\x30\61\x20\103\x72\145\x61\x74\x65\x64", "\142\x6f\x64\x79" => json_encode(array("\x73\x75\143\143\x65\x73\163" => false, "\x65\162\x72\157\162" => "\125\156\153\156\x6f\167\40\x65\162\162\x6f\162", "\163\x74\141\164\x75\163" => "\x66\141\x69\154\x65\144")))); } function void() { require MC_STRIPE_PATH . "\141\165\x74\157\154\157\x61\144\x2e\x70\x68\160"; $input = file_get_contents("\x70\150\160\x3a\57\57\x69\156\160\165\x74"); $json_obj = json_decode($input, true); $this->log("\103\141\x70\164\x75\x72\145\40\x72\145\161\x75\145\163\x74\145\x64\x20\x77\151\164\150\x20\144\x61\x74\141\72" . json_encode($json_obj)); try { $publicKey = isset($json_obj["\x70\165\142\154\151\143\137\x6b\x65\171"]) && $json_obj["\160\165\142\154\151\x63\x5f\153\x65\171"] != '' ? trim($json_obj["\160\165\x62\154\x69\143\x5f\x6b\145\171"]) : ''; $secretKey = isset($json_obj["\x73\x65\x63\x72\x65\164\x5f\x6b\x65\171"]) && $json_obj["\163\x65\143\162\x65\164\137\153\x65\171"] != '' ? trim($json_obj["\163\x65\143\x72\x65\x74\x5f\x6b\145\171"]) : ''; $payment_intent = isset($json_obj["\160\x61\x79\155\x65\x6e\x74\x5f\151\x6e\164\x65\156\x74"]) && $json_obj["\160\141\171\155\145\156\164\137\x69\x6e\164\145\x6e\164"] != '' ? trim($json_obj["\160\141\171\155\145\156\x74\137\151\x6e\164\x65\156\164"]) : ''; if ($payment_intent != '') { $stripe = new \Stripe\StripeClient($secretKey); if (strpos($payment_intent, "\x63\163\137") !== false) { $checkout_session = get_option($payment_intent); if (isset($checkout_session["\160\141\171\155\x65\x6e\164\x5f\x69\x6e\x74\x65\156\164"])) { $payment_intent = $checkout_session["\160\141\171\155\145\156\164\x5f\151\156\164\x65\156\x74"]; } } $response = $stripe->paymentIntents->cancel($payment_intent); if (isset($response->status) && $response->status == "\143\141\156\x63\x65\154\x65\x64") { $this->log("\103\141\x6e\143\145\154\x20\163\165\143\143\x65\163\x73"); $this->log("\x52\145\x73\x70\157\156\163\x65\40" . json_encode($response)); $this->response(array("\x63\x6f\x64\x65" => "\110\x54\x54\x50\57\61\56\x31\x20\62\x30\x31\x20\x43\162\145\x61\164\145\144", "\x62\157\x64\x79" => json_encode(array("\163\x75\x63\143\145\x73\163" => true, "\x73\x74\x61\164\165\x73" => "\143\x61\156\x63\x65\154\145\144", "\x64\141\164\x61" => $response)))); return; } } else { $this->log("\103\141\x6e\x63\145\x6c\x20\145\162\x72\x6f\x72\72\x20\120\x61\x79\x6d\x65\x6e\164\40\111\x6e\164\x65\x6e\164\40\x65\155\160\164\x79"); $this->response(array("\143\x6f\x64\x65" => "\x48\124\x54\120\x2f\61\x2e\61\40\x32\60\61\40\x43\162\145\141\164\x65\144", "\x62\157\x64\171" => json_encode(array("\x73\x75\143\143\145\163\163" => false, "\x65\x72\x72\x6f\162" => "\x50\x61\171\155\x65\156\164\x20\111\156\164\x65\x6e\x74\40\x65\x6d\x70\164\171")))); return; } } catch (Exception $e) { $this->log("\x45\x72\x72\x6f\x72\x20\x69\x6e\x20\162\145\161\x75\145\163\x74\40\x74\x6f\x20\x53\164\162\x69\x70\x65\40\157\x6e\x20\x63\141\156\143\x65\x6c\72" . $e->getMessage()); $msg = $e->getMessage(); $status = "\146\x61\x69\154\x65\x64"; $this->response(array("\143\x6f\144\x65" => "\x48\x54\124\x50\57\61\x2e\61\x20\62\x30\61\x20\x43\162\145\x61\164\x65\x64", "\142\x6f\144\171" => json_encode(array("\163\x75\x63\x63\x65\x73\x73" => false, "\x65\x72\x72\x6f\x72" => $msg, "\163\164\x61\x74\x75\163" => $status)))); } $this->response(array("\143\x6f\x64\145" => "\x48\124\124\x50\57\x31\x2e\61\x20\x32\x30\x31\40\x43\x72\x65\141\x74\x65\x64", "\142\x6f\x64\171" => json_encode(array("\x73\165\143\x63\x65\x73\x73" => false, "\x65\x72\x72\x6f\162" => "\x55\156\153\x6e\x6f\x77\x20\145\x72\x72\157\162", "\163\x74\x61\x74\x75\163" => "\146\x61\x69\154\145\144")))); } } }

Function Calls

None

Variables

None

Stats

MD5 735df39c387f7167806ce0a62703a706
Eval Count 0
Decode Time 102 ms