Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Force email to be sent to Authorize.net - MemberPress
<?php
// Some processors require email address to be sent
function mepr_array_swap($key1, $key2, $array) {
$newArray = array();
foreach($array as $key => $value) {
if ($key == $key1) {
$newArray[$key2] = $array[$key2];
} elseif ($key == $key2) {
$newArray[$key1] = $array[$key1];
} else {
$newArray[$key] = $value;
}
}
return $newArray;
}
function add_email_to_recurring($args, $txn, $sub) {
$user = new MeprUser($txn->user_id);
$args['subscription']['customer'] = array('email' => $user->user_email);
$args['subscription'] = mepr_array_swap('customer', 'billTo', $args['subscription']);
return $args;
}
add_filter('mepr_authorize_create_subscription_args', 'add_email_to_recurring', 11, 3);
function add_email_to_oneoff($args, $txn) {
$user = new MeprUser($txn->user_id);
$args['x_email'] = $user->user_email;
return $args;
}
add_filter('mepr_authorize_payment_args', 'add_email_to_oneoff', 11, 2);
add_filter('mepr_authorize_auth_card_args', 'add_email_to_oneoff', 11, 2);
@cartpauj

This comment has been minimized.

Copy link
Owner Author

@cartpauj cartpauj commented Nov 12, 2018

This code will work best in a plugin like Code Snippets. In a "run everywhere" snippet type.

@greggh

This comment has been minimized.

Copy link

@greggh greggh commented Sep 23, 2019

Is this still actually needed for the latest versions of Memberpress and its authorize.net integration?

@cartpauj

This comment has been minimized.

Copy link
Owner Author

@cartpauj cartpauj commented Sep 24, 2019

It's typically not required, but some processors force an email to be sent. If you get email errors at checkout, then this may be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment