-1

我有以下用于创建按钮的代码。

public function createButton($name, $price, $currency, $custom=null, $options=array(),$callback)
{
   // $callback=$this->generateReceiveAddress("http://www.tgigo.com");

    // print_r($callback);exit;

    $params = array(
        "name" => $name,
        "price_string" => $price,
        "price_currency_iso" => $currency,
        "callback_url"=>"http://www.tgigo.com"
    );
    if($custom !== null) {
        $params['custom'] = $custom;
    }
    foreach($options as $option => $value) {
        $params[$option] = $value;
    }

    return $this->createButtonWithOptions($params);
}

public function createButtonWithOptions($options=array())
{

    $response = $this->post("buttons", array( "button" => $options ));

    if(!$response->success) {
        return $response;
    }

    $returnValue = new stdClass();
    $returnValue->button = $response->button;
    $returnValue->embedHtml = "<div class=\"coinbase-button\" data-code=\"" . $response->button->code . "\"></div><script src=\"https://coinbase.com/assets/button.js\" type=\"text/javascript\"></script>";
    $returnValue->success = true;


    return $returnValue;
}

我对上述代码有以下响应。

{"success":true,"button":{"code":"675cda22e31b314db557f0538f8ad27e","type":"buy_now","style":"buy_now_large","text":"用比特币支付","name": "Your Order #1234","description":"1 个 100 美元的小部件","custom":"我对这个订单的自定义跟踪代码","callback_url":" http://www.tgigo.com ","price ":{"cents":100000,"currency_iso":"BTC"}}}

使用此代码支付过程完成,但未重定向到回调 url。任何人请帮助我。

提前致谢 :)

4

1 回答 1

-1

callback_url 参数用于在支付完成时在后台接收 POST 请求的回调。用户的浏览器不会在那里重定向。你可能想要success_url。

https://coinbase.com/api/doc/1.0/buttons/create.html

于 2013-12-09T00:34:43.533 回答