function _uc_recurring_hosted_paypal_ipn_payment in UC Recurring Payments and Subscriptions 6.2
Same name and namespace in other branches
- 7.2 modules/uc_recurring_hosted/uc_recurring_hosted.paypal_ipn.inc \_uc_recurring_hosted_paypal_ipn_payment()
Handles payment information from IPN message.
3 calls to _uc_recurring_hosted_paypal_ipn_payment()
- uc_recurring_hosted_paypal_ipn in modules/
uc_recurring_hosted/ uc_recurring_hosted.paypal_ipn.inc - Handle IPN callbacks for PayPal recurring payments
- uc_recurring_hosted_paypal_wpp_renew in modules/
uc_recurring_hosted/ uc_recurring_hosted.module - Setup a mock renew handler to process through UC Recurring.
- uc_recurring_hosted_paypal_wps_renew in modules/
uc_recurring_hosted/ uc_recurring_hosted.module - Setup a mock renew handler to process through UC Recurring.
File
- modules/
uc_recurring_hosted/ uc_recurring_hosted.paypal_ipn.inc, line 132 - Handle paypal IPN callbacks for recurring payments
Code
function _uc_recurring_hosted_paypal_ipn_payment($ipn) {
global $user;
$context = array(
'revision' => 'formatted-original',
'type' => 'amount',
);
$options = array(
'sign' => FALSE,
);
switch ($ipn->payment_status) {
case 'Canceled_Reversal':
uc_order_comment_save($ipn->order_id, 0, t('PayPal has cancelled the reversal and returned !amount !currency to your account.', array(
'!amount' => uc_price($ipn->mc_gross, $context, $options),
'!currency' => $ipn->mc_currency,
)), 'admin');
break;
case 'Completed':
$comment = t('PayPal transaction ID: @txn_id', array(
'@txn_id' => $ipn->txn_id,
));
uc_payment_enter($ipn->order_id, 'paypal_wps', $ipn->mc_gross, $user->uid, NULL, $comment);
uc_order_comment_save($ipn->order_id, 0, t('Payment of @amount @currency submitted through PayPal.', array(
'@amount' => uc_price($ipn->mc_gross, $context, $options),
'@currency' => $ipn->mc_currency,
)), 'order', 'payment_received');
uc_order_comment_save($ipn->order_id, 0, t('PayPal IPN reported a payment of @amount @currency.', array(
'@amount' => uc_price($ipn->mc_gross, $context, $options),
'@currency' => $ipn->mc_currency,
)));
break;
case 'Denied':
uc_order_comment_save($ipn->order_id, 0, t("You have denied the customer's payment."), 'admin');
break;
case 'Expired':
uc_order_comment_save($ipn->order_id, 0, t('The authorization has failed and cannot be captured.'), 'admin');
break;
case 'Failed':
uc_order_comment_save($ipn->order_id, 0, t("The customer's attempted payment from a bank account failed."), 'admin');
break;
case 'Pending':
uc_order_update_status($ipn->order_id, 'paypal_pending');
uc_order_comment_save($ipn->order_id, 0, t('Payment is pending at PayPal: @reason', array(
'@reason' => _uc_paypal_pending_message(check_plain($ipn->pending_reason)),
)), 'admin');
break;
// You, the merchant, refunded the payment.
case 'Refunded':
$comment = t('PayPal transaction ID: @txn_id', array(
'@txn_id' => $ipn->txn_id,
));
uc_payment_enter($ipn->order_id, 'paypal_wps', $ipn->mc_gross, $ipn->uid, NULL, $comment);
break;
case 'Reversed':
watchdog('uc_recurring_hosted', 'PayPal has reversed a payment!', array(), WATCHDOG_ERROR);
uc_order_comment_save($ipn->order_id, 0, t('Payment has been reversed by PayPal: @reason', array(
'@reason' => _uc_paypal_reversal_message($ipn->reason_code),
)), 'admin');
break;
case 'Processed':
uc_order_comment_save($ipn->order_id, 0, t('A payment has been accepted.'), 'admin');
break;
case 'Voided':
uc_order_comment_save($ipn->order_id, 0, t('The authorization has been voided.'), 'admin');
break;
}
}