3 replies [Last post]
slayerment's picture
Offline
Uber Donor
Joined: 01/06/2008
Juice: 86
Was this information Helpful?

I'm using UC Beta1.

I have a module where I update the database after an order has been paid for. When using the check option for payment type the following code works perfectly. However, when I switch over to Paypal and complete my payment there I get returned back to my site and it appears as though this is not being executed. Is there something I am doing wrong?

Here's the code I'm using:

<?php
function credit_order($op, &$arg1, $arg2) {
  switch (
$op) {
    case
'submit':
     
$credits = '1.50';
     
db_query("INSERT INTO {credit_user} (uid, credits) VALUES (%d, '%s')", $arg1->uid, $credits);
      break;
  }
}
?>

Thanks,
Quinton

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Problem with hook_order submit and Paypal

I would use case 'update' and compare against the order status. Keep in mind if you change the order status to Pending and then back to Completed, this will repeat the function; consider a "credits_have_been_added" flag (or perhaps case 'submit' would work in this regard - never used it)...

<?php
function credit_order($op, $order, $status) {
  switch (
$op) {
    case
'update':

    if ((

$order->uid > 0) && ($order_user = user_load(array('uid' => $order->uid))) !== FALSE && $status == 'completed') {
       
$credits = '1.50';
       
db_query("INSERT INTO {credit_user} (uid, credits) VALUES (%d, '%s')", $arg1->uid, $credits);
    break;
    }
  }
}
?>

Not sure if that works, just an example.

--
Help directly fund development: Donate via PayPal!

slayerment's picture
Offline
Uber Donor
Joined: 01/06/2008
Juice: 86
Re: Re: Problem with hook_order submit and Paypal

I just tried your update method along with the status check and that seems to be working perfect Smiling.

Appreciate the help man!

loubabe's picture
Offline
Joined: 08/13/2008
Juice: 34
Re: Problem with hook_order submit and Paypal

So does the hook_order submit operation not fire when using PayPal?