Paypal API 待付款 [英] Paypal API Pending Payments

查看:28
本文介绍了Paypal API 待付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上设置了一个支付系统,其工作方式如下.

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

买家购买商品我执行了一个返回成功或失败的 SetExpressCheckout 调用.成功后,我使用返回的令牌进行提交.提交成功后,我会将项目标记为已售出或扣除数量.

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']);
    }
}

这个程序的问题是,如果买方/卖方的待授权操作时间超过3小时,则令牌无效.所以这给我留下了 2 个查询

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. 令牌过期后如何处理已完成的交易而不尝试再次购买?

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

我可以从 getTransactionDetails 获取买家的邮寄地址吗?

Can i obtain the buyers postal address from getTransactionDetails?

谢谢

推荐答案

请改用 GetTransactionDetails API 调用.如果您提交了 DoExpressCheckoutPayment 调用,您将获得可用于查询付款的交易 ID.响应会告诉您 PayPal 内的交易状态,并为您提供送货地址(如果在原始交易期间提供或要求).

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).

交易 ID 不会过期.

The transaction ID doesn't expire.

不过,我不确定我是否 100% 了解您的流程.您是否将交易作为授权处理?

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

这篇关于Paypal API 待付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆