首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >2创建销售的2checkout调用

2创建销售的2checkout调用
EN

Stack Overflow用户
提问于 2016-07-19 13:38:57
回答 0查看 320关注 0票数 0

我正在使用2checkout api来销售我的网站产品。因此,我调用2checkout api来创建销售,其中我可以调用单个产品的总金额api。它看起来像流动的:

代码语言:javascript
复制
try {
    $charge = Twocheckout_Charge::auth(array(
        "merchantOrderId" => "123",
        "token"      => $_POST['token'],
        "currency"   => 'USD',
        "total"      => $first_bill['amount'],
        "billingAddr" => array(
            "name" => $_POST['b_name'],
            "addrLine1" => $_POST['b_address'],
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => $_POST['b_country'],
            "email" => $_POST['b_emaill'],
            "phoneNumber" => $_POST['b_phone']
            ),
        "shippingAddr" => array(
            "name" => 'Testing Tester',
            "addrLine1" => '123 Test St',
            "city" => 'Columbus',
            "state" => 'enter code hereOH',
            "zipCode" => '43123',
            "country" => 'USA',
            "email" => 'example@2co.com',
            "phoneNumber" => '555-555-5555'
            )
        ));
    if ($charge['response']['responseCode'] == 'APPROVED') {

        echo $response;exit;
        // echo "Thanks for your Order!";
        // echo "<h3>Return Parameters:</h3>";
        // echo "<pre>";
        // print_r($charge);
        // echo "</pre>";
    }
    else
    {
        $this->Registrationmodel->delete_account($accounts_id);
        echo $charge['response']['responseCode'];
        exit;
    }
} 
catch (Twocheckout_Error $e) 
{
    echo $e->getMessage();
    exit;
}

}

因此,当我尝试单独设置行项目时,如下所示:

代码语言:javascript
复制
try {
    $charge = Twocheckout_Charge::auth(array(
        "merchantOrderId" => "123",
        "token"      => $_POST['token'],
        "currency"   => 'USD',
        //"total"      => $first_bill['amount'],
        "billingAddr" => array(
            "name" => $_POST['b_name'],
            "addrLine1" => $_POST['b_address'],
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => $_POST['b_country'],
            "email" => $_POST['b_emaill'],
            "phoneNumber" => $_POST['b_phone']
            ),
        "LineItem" => array(
            "duration" => 'Forever',
            "price" => '10',
            "productId" =>'1235',
            "quantity" => '1',
            "recurrence" => '1 Month',
            "tangible" => 'N',
            "type"=>'product'
            ),
        "shippingAddr" => array(
            "name" => 'Testing Tester',
            "addrLine1" => '123 Test St',
            "city" => 'Columbus',
            "state" => 'OH',
            "zipCode" => '43123',
            "country" => 'USA',
            "email" => 'example@2co.com',
            "phoneNumber" => '555-555-5555'
            )
        ));
    if ($charge['response']['responseCode'] == 'APPROVED') {
        $response = $this->return_information($charge['response']['orderNumber']);
        echo $response;exit;
        // echo "Thanks for your Order!";
        // echo "<h3>Return Parameters:</h3>";
        // echo "<pre>";
        // print_r($charge);
        // echo "</pre>";
    }
    else
    {
        $this->Registrationmodel->delete_account($accounts_id);
        echo $charge['response']['responseCode'];
        exit;
    }
} 
catch (Twocheckout_Error $e) 
{
    $this->Registrationmodel->delete_account($accounts_id);
    echo $e->getMessage();
    exit;
}

}

它给我提供了参数错误。有谁能帮上忙吗?如何使用api调用设置行项目?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38450309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档