我试图使用wepay创建一个简单的结帐页面,我的结帐代码(取自SDK示例)在我登录时对所有者(我)很有用,但是当我登录时一个没有创建帐户的用户(在他们的下面?),表示该帐户无效或不属于该用户。
那么新登录的用户应该如何支付账户(我的),换句话说付款?
以下是供参考的代码。 account_id对新登录用户不起作用,因为他们尚未创建它。
$wepay = new WePay($_SESSION['wepay_access_token']);
$checkout = $wepay->request('checkout/create', array(
'account_id' => 501999810,
'amount' => 1.00,
'currency'=> 'USD',
'short_description'=> 'Selling 42 Pens',
'type'=> 'goods'
));
也许我完全关闭了一些东西,但是account_id是我想收到付款的地方吗?
任何帮助将不胜感激!
答案 0 :(得分:0)
注册用户后,您必须致电/account/create
创建实际的商家帐户。
获得用户的访问令牌后,您可以使用用户的访问令牌和相关信息来呼叫/account/create
,以便将帐户实际附加到用户。 /account/create
来电将返回account_id
。 account_id
是您在/checkout/create
电话中使用的那个。
因此,在您通过/account/create
创建帐户之前,用户无法接受付款。
答案 1 :(得分:0)
$productData['data']['seller_data']['wepay_access_token']="STAGE_ea6cd2dffa3dfa23bd4817f210936fadada9fa91e906f353e15813c6cf920fb8";
$productData['data']['seller_data'}['wepay_account_id']="287443494";
$wepay = new WePay($productData['data']['seller_data']['wepay_access_token']);
$checkOutData = array(
//"account_id" => 12345678,
"account_id" => $productData['data']['seller_data'}['wepay_account_id'],
"amount" => 500,
"type" => "goods",
"currency" => "USD",
"short_description" => "Purchase made at test site",
"long_description" => "The charges made in this payment are of the order placed in test",
"delivery_type" => "point_of_sale",
"fee" => array(
"app_fee" => 15,
//'fee_payer' => 'payer_from_app'
'fee_payer' => 'payee_from_app'
),
//"auto_release"=>false,
"payment_method" => array(
"type" => "credit_card",
"credit_card" => array(
"id" => 2178689241,
"auto_capture" => false
)
)
);
try {
$checkoutResult = $wepay->request('checkout/create', $checkOutData);
} catch (Exception $e) {
$data['status'] = '0';
$data['message'] = 'We could not complete checkout!';
return $this->SetOutput();
}
You can get seller access token and account id using
$user_id=20;
$access_token="STAGE_ea6cd2dffa3dfa23bd4817f210936fadada9fa91e906f353e15813c6cf920fb8":
$userName="test user";
$description="sell products";
try {
$wepay = new WePay($access_token);
if (empty($userName)) {
try {
$uresponse = $wepay->request('/user');
$userName = $uresponse->user_name;
} catch (WePayException $e) {
$uresponse['status'] = '0';
$uresponse['message'] = $e->getMessage();
return $uresponse;
}
}
$response = $wepay->request('account/create/', array(
'name' => $userName,
'description' => $description,
'reference_id' => '"' . $user_id . '"'
));
} catch (WePayException $e) {
$response['status'] = '0';
$response['message'] = $e->getMessage();
return $response;
}