Skip to content

Instantly share code, notes, and snippets.

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 remcotolsma/277254ae239641c36b91ec8f8fe0da92 to your computer and use it in GitHub Desktop.
Save remcotolsma/277254ae239641c36b91ec8f8fe0da92 to your computer and use it in GitHub Desktop.
Custom plugin specific for Pronamic.nl/eu website to add Mollie metadata.
<?php
/**
* Plugin Name: Pronamic Pay - Custom Mollie metadata
* Plugin URI: https://gist.github.com/remcotolsma/277254ae239641c36b91ec8f8fe0da92
* Description: Custom plugin specific for Pronamic.nl/eu website to add Mollie metadata.
*
* Version: 1.0.0
* Requires at least: 4.7
*
* Author: Pronamic
* Author URI: https://www.pronamic.eu/
*
* License: GPL-3.0-or-later
*
* @author Pronamic <info@pronamic.eu>
* @copyright 2005-2020 Pronamic
* @license GPL-3.0-or-later
*/
\add_filter( 'pronamic_pay_mollie_payment_metadata', function( $metadata, $payment ) {
$data = array();
$customer = $payment->get_customer();
if ( null !== $customer ) {
$vat_number = $customer->get_vat_number();
if ( null !== $vat_number ) {
$data['vat_number'] = $vat_number->normalized();
}
}
switch ( $payment->get_source() ) {
case 'easydigitaldownloads':
$data['edd_order_id'] = $payment->get_source_id();
break;
case 'gravityformsideal':
$data['gf_entry_id'] = $payment->get_source_id();
break;
}
return (object) $data;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment