Question

I have setup a payments system on my site which works as follows.

Buyer buys item I do a SetExpressCheckout call which returns a success or failure. On success, I do a commit with the returned token. On success of the commit, I then mark the item as sold or deduct quantity.

The problem I am having is my current procedure works if the transactions is completed with no pending status but in order to process pending items I do the following

Check if user has any pending items

$sql = "SELECT * FROM basket_items WHERE status = 'pending' AND userID = '$user_id'";
$pending_items = queryArray($sql);

foreach($pending_items as $item){
    $token = $item['token'];
    //get status of the pending transaction
    $transaction_details = GetExpressCheckoutDetails($token);
    $trans_status = $EXP_CHECK_DETAILS['CHECKOUTSTATUS'];

    if($trans_status == 'completed'){
        MarkItemSold($item['id']);
    }
}

The problem with this procedure is, if the buyer / seller with the pending authorisation action takes more than 3hours, the token is invalid. So that leaves me with 2 queries

  1. How do i process completed transaction after the token has expired without trying to buy the item again?

  2. Can i obtain the buyers postal address from getTransactionDetails?

Thanks

Was it helpful?

Solution

Try the GetTransactionDetails API call instead. If you submitted a DoExpressCheckoutPayment call you would get a transaction ID you can use to look up the payment. The response would tell you the status of the transaction within PayPal and give you the shipping address (if provided or requested during the original transaction).

The transaction ID doesn't expire.

I'm not sure if I'm 100% clear on your process though. Are you processing transactions as an Authorization?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top