capitanh
Forum Replies Created
-
or here:
//IPN handler function
function fppap_check_ipn() {
if (isset($_GET[‘ipn’])) {
$paypal_adaptive_payment = new FPPaypalAdaptivePayment();
if (“yes” == $paypal_adaptive_payment->testmode) {
$paypal_ipn_url = “https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate”;
} elseif (“no” == $paypal_adaptive_payment->testmode) {
$paypal_ipn_url = “https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate”;
}
$ipn_post = !empty($_POST) ? $_POST : false;
if ($ipn_post) {
header(‘HTTP/1.1 200 OK’);
$self_custom = $_GET[‘self_custom’];
$received_post = file_get_contents(“php://input”); // adaptive payment ipn message is different from normal paypal so we handle like this
$posted_response = wp_remote_request($paypal_ipn_url, array(‘method’ => ‘POST’, ‘timeout’ => 20, ‘body’ => $received_post));
$received_raw_post_array = explode(‘&’, $received_post);
$post_maded = array(); // making post from raw
foreach ($received_raw_post_array as $keyval) {
$keyval = explode(‘=’, $keyval);
if (count($keyval) == 2)
$post_maded[urldecode($keyval[0])] = urldecode($keyval[1]);
}
if (strcmp($posted_response[‘body’], “VERIFIED”) == 0) {
$received_order_id = $self_custom;
$payment_status = $post_maded[‘transaction[0].status’]; // first user status
if ($payment_status == ‘Completed’) {
$order = new WC_Order($received_order_id);
if (isset($order->id)) { // if order exist
$total = 0;
if ($paypal_adaptive_payment->get_option(‘_payment_mode’) == ‘parallel’) {
for ($i = 0; $i <= 5; $i++) {
if (isset($post_maded[“transaction[$i].amount”])) {
$total = $total + preg_replace(“/[^0-9,.]/”, “”, $post_maded[“transaction[$i].amount”]);
}
}
} else {
$total = preg_replace(“/[^0-9,.]/”, “”, $post_maded[“transaction[0].amount”]);
}
/* if ($total == $order->order_total) { //checking order total with payment as suggested by paypal ipn documentation to avoid fraud pay
$order->payment_complete();
}*/
$order->payment_complete();
update_post_meta($order->id, ‘Transaction ID’, $post_maded[‘transaction[0].id’]); // adding transaction ID to order for future reference
}
}
}
}
}
}add_action(‘init’, ‘fppap_check_ipn’);
i think there something to change around here:
if ($order->payment_method == ‘fp_paypal_adaptive’) {
$order->update_status(‘on-hold’, __(‘Awaiting IPN Response to make the Status to Processing’, ‘fppaypaladaptivesplit’));
}
}function add_fp_payment($methods) {
$methods[] = ‘FPPaypalAdaptivePayment’;
return $methods;
}i think something missing
any one can help me ?
the payment is splitted but the order status not end to “complete”
on my paypal my ipn is set to :http://www.mysitename.com/?addlistener=IPN
this code is right also?
paypal say me is about my code pho on my plug in.
paypal say they are set fine.
HELP !