Skip to content

Instantly share code, notes, and snippets.

@birgire
Last active May 13, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save birgire/beb3806eb15db4431e2ae0c35c6b53c4 to your computer and use it in GitHub Desktop.
Save birgire/beb3806eb15db4431e2ae0c35c6b53c4 to your computer and use it in GitHub Desktop.
WordPress plugin: Debug Rapyd Card payment callback
<?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