简体   繁体   English

Paypal API待付款

[英]Paypal API Pending Payments

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. 买方购买的商品我执行SetExpressCheckout调用,该调用返回成功或失败。 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. 此过程的问题是,如果具有待处理授权操作的买方/卖方花费了3个小时以上,则令牌无效。 So that leaves me with 2 queries 这样我就有2个查询

  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? 我可以从getTransactionDetails获取买家的邮政地址吗?

Thanks 谢谢

Try the GetTransactionDetails API call instead. 请尝试使用GetTransactionDetails API调用。 If you submitted a DoExpressCheckoutPayment call you would get a transaction ID you can use to look up the payment. 如果您提交了DoExpressCheckoutPayment调用,则会获得一个交易ID,可用于查找付款。 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). 响应将告诉您PayPal内交易的状态并提供送货地址(如果在原始交易中提供或要求)。

The transaction ID doesn't expire. 交易ID不会过期。

I'm not sure if I'm 100% clear on your process though. 不过,我不确定您的程序是否100%明确。 Are you processing transactions as an Authorization? 您是否正在将交易作为授权进行处理?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM