Project:PayPal Buttons for Ubercart
Version:6.x-1.0
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Is it possible when user complete the payment via paypal, and if the payment is completed (not in paypal pending) then the user is redirected to download page?

What is the value should I catch in the custom redirection page template?

Thanks

duckz

Comments

#1

<?php
function uc_checkout_download_page() {
// Get the posted result from paypal
$tx = check_plain($_GET[tx]);
$status = check_plain($_GET[st]);
$amount = check_plain($_GET[amt]);
$currency = check_plain($_GET[cc]);
$product_code = check_plain($_GET[item_number]);

$prep_tx = 'PayPal transaction ID: ' . $tx;
// Get the payment receipt

$sql = "SELECT * FROM {uc_payment_receipts} WHERE comment = '%s'";
$payment = db_fetch_object(db_query($sql , $prep_tx));

// Get the order data

$sql_order = "SELECT * FROM {uc_orders} WHERE order_id = '%d'";
$order_detail = db_fetch_object(db_query($sql_order , $payment->order_id));

// Get the product data

$sql_product = "SELECT nid FROM {uc_products} WHERE model = '%s'";
$data = db_fetch_object(db_query($sql_product, $product_code));
$product = node_load($data->nid);

// Check download limit

$download_limit = variable_get('uc_file_download_limit_number', NULL);
if (
$download_limit == NULL) {
   
$download_limit_message = 'not limited';
    } else {
   
$download_limit_message = 'to '. $download_limit . ' download times';
}

// Check download ip limit

$download_ip_limit = variable_get('uc_file_download_limit_addresses', NULL);
if (
$download_ip_limit == NULL) {
   
$download_ip_limit_message = 'unlimited unique ip address';
    } else {
   
$download_ip_limit_message = 'upto '. $download_ip_limit . ' unique ip';
}
// Check download time limit
$download_timer = variable_get('uc_file_download_limit_duration_qty', NULL);
if (
$download_timer == NULL) {
   
$download_timer_message = 'will not expire';
    } else {
   
$download_timer_message = 'will expire after '. $download_timer;
}

// Build the output
global $user;
$uid = $user->uid;
if (
$uid == $payment->uid and $uid == $order_detail->uid) {
if (
$order_detail->order_status == 'completed') {

// CODE FOR DISPLAYING OUTPUT HERE
   
} else {
   
$output .= '<p>There is a problem with your payment, please contact our <a href="mailto:support@zweetsal.com">customer service</a></p>';
}

} else {
   
$output .= '<p>You are not authorized to view this page.</p>';
}


    return
$output;
}
?>

is this code safe to use???

#2

Not sure about it, but if you install me aliases, you can set the landing page to user/me/purchased-files and the user will be taken there...

http://drupal.org/project/me

#3

You're asking several questions; I'll briefly answer each:

- Yes, you can direct the user to a specific page when the payment is successful. Use the Successful payment URL option for your product.
- Yes, you can check the payment status by looking at the variables returned by PayPal when the user returns to your site. Usually $_GET, but can be $_POST if you've enabled the Return transaction variables using POST method to the specified successful payment URL option. The variable to check is usually payment_status, but you should also check st. You're looking for Completed.
- I have no comment on the code you posted.