Created
July 13, 2020 08:47
-
-
Save remcotolsma/277254ae239641c36b91ec8f8fe0da92 to your computer and use it in GitHub Desktop.
Custom plugin specific for Pronamic.nl/eu website to add Mollie metadata.
This file contains 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: 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