Check for captured vault webhook order meta

This commit is contained in:
dinamiko 2021-12-20 15:34:55 +01:00
parent f03f3e5fb1
commit 572c62c74c
3 changed files with 8 additions and 2 deletions

View file

@ -171,6 +171,11 @@ trait ProcessPaymentTrait {
try {
if ( $this->order_processor->process( $wc_order ) ) {
if($this->subscription_helper->has_subscription( $wc_order->get_id() )) {
$wc_order->update_meta_data('_ppcp_captured_vault_webhook', false);
}
WC()->cart->empty_cart();
$this->session_handler->destroy_session_data();

View file

@ -217,8 +217,9 @@ class AuthorizedPaymentsProcessor {
if ($this->config->has('intent') && strtoupper((string)$this->config->get('intent')) === 'CAPTURE') {
foreach ($wc_orders as $wc_order) {
if( $this->subscription_helper->has_subscription( $wc_order->get_id() ) ) {
if( $this->subscription_helper->has_subscription( $wc_order->get_id() ) && $wc_order->get_meta( '_ppcp_captured_vault_webhook' ) === false ) {
$this->capture_authorized_payment($wc_order);
$wc_order->update_meta_data('_ppcp_captured_vault_webhook', true);
}
}
}

View file

@ -53,7 +53,7 @@ class VaultPaymentTokenCreated implements RequestHandler
$response = array( 'success' => false );
$webhook_id = (string) ( $request['id'] ?? '' );
$customer_id = $resource['customer_id'] ?? '';
$customer_id = $request['customer_id'] ?? '';
if(!$customer_id) {
$message = sprintf( 'No customer id for webhook event %s was found.', $webhook_id );
$this->logger->warning( $message, array( 'request' => $request ) );