Last active
May 13, 2022 11:58
-
-
Save birgire/beb3806eb15db4431e2ae0c35c6b53c4 to your computer and use it in GitHub Desktop.
WordPress plugin: Debug Rapyd Card payment callback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Debug Rapyd Card payment callback. | |
* Description: This plugin saves the payload from the Rapyd Card callback into the order meta under the 'debug' key. | |
* Plugin URI: https://gist.github.com/birgire/beb3806eb15db4431e2ae0c35c6b53c4 | |
* Author: birgire | |
* Author URI: https://github.com/birgire | |
* License: MIT | |
* Version: 0.0.4 | |
*/ | |
namespace Birgir\Rapyd\Debug; | |
add_action( 'woocommerce_api_rapyd_card_payment_callback', __NAMESPACE__ . '\rapyd_card_payment_callback' ); | |
function rapyd_card_payment_callback () { | |
$body = json_decode( file_get_contents( 'php://input' ), true ); | |
if ( ! isset( $body['order_id'] ) ) { | |
return; | |
} | |
if ( ! is_numeric( $body['order_id'] ) ) { | |
return; | |
} | |
$order = wc_get_order( absint( $body['order_id'] ) ); | |
if ( ! $order ) { | |
return; | |
} | |
update_post_meta( $order->get_id(), 'debug', json_encode( $body ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment