dsn5510 2015-08-11 16:25
浏览 47

退还已获取的授权

am using the php api sdk found here: https://github.com/paypal/PayPal-PHP-SDK but am having trouble issuing a refund.

This is the code I am using:

// CAPTURE THE ORIGINAL AUTHORIZATION
try
{
    $amount = new Amount();
    $amount->setCurrency("USD");
    $amount->setTotal($amount_authorized);

    $capture = new Capture();
    $capture->setId($authorization_id);
    $capture->setAmount($amount);

    $authorization = Authorization::get($transaction_id, $apiContext);
    $capt = $authorization->capture($capture, $apiContext);

    if ($capt->state == 'completed')
    {
        $capture_id = $capt->id;
    }
}
catch (PayPal\Exception\PayPalConnectionException $e)
{
    $response = json_decode($e->getData());
    die('Error capturing funds: '.$response->message);
}
catch (Exception $e)
{
    die('Error capturing funds: '.$e->getMessage());
}

// REFUND THE CAPTURE
try
{
    $amount = new Amount();
    $amount->setCurrency("USD");
    $amount->setTotal($refund_amount);

    $refund = new Refund();
    $refund->setId($capture_id);
    $refund->setAmount($amount);

    $capture = Capture::get($capture_id, $apiContext);
    $captureRefund = $capture->refund($refund, $apiContext);

    if ($captureRefund->state == 'completed')
    {
        die('REFUNDED');
    }
}
catch (PayPal\Exception\PayPalConnectionException $e)
{
    $response = json_decode($e->getData());
    die('There was an error refunding the funds: '.$response->message);
}
catch (Exception $e)
{
    die('There was an error refunding the funds: '.$e->getMessage());
}

I get this error everytime: The requested resource ID was not found

I believe I am following the sample code on the developer site but I'll pulling my hair out. It's probably something pretty easy I hope.

Any ideas?

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度