It is possible in stripe payment gateway?
我们将使用条带付款,首先我创建令牌 .
$result = Stripe_Token::create(
array(
"card" => array(
"name" => $user['name'],
"number" => base64decrypt($user['card_number']),
"exp_month" => $user['month'],
"exp_year" => $user['year'],
"cvc" => base64decrypt($user['cvc_number'])
)
)
);
使用令牌后创建客户存储卡 .
$customer = \Stripe\Customer::create(array(
"card" => $token,
"description" => "New customer",
"email" => $users->email
)
);
并在创建充电后 .
$charge = \Stripe\Charge::create(
array('card' => $token->token,
'amount' => $token->amount * 100,
'currency' => 'usd',
)
);
但我找不到在单个客户中保存多张卡 . 请帮我 .
1 回答
首先,您永远不应该在 生产环境 中创建令牌服务器端 . 要获得PCI SAQ A的资格,您必须使用Checkout或Stripe.js创建卡令牌客户端 .
在服务器上收到令牌后,您可以通过几种不同的方式使用它:
通过在
source
参数中传递令牌ID("tok_..."
),您可以直接使用它直接create a charge,而无需使用客户对象 . 在这种情况下,卡信息将是"lost",您将需要再次收集信息并创建一个新令牌,以便将来再次为此卡充电 .你可以用它来create a new customer .
你可以用它来add a card to an existing customer .
当creating charges与客户对象一起使用时,您需要在
customer
参数中传递客户的ID("cus_..."
) . 如果未传递source
参数,则将使用客户的默认卡 . 如果要为非默认卡充电,那么除了customer
参数之外,source
参数中还有'll also need to pass the card' s ID("card_..."
) .参看this StackOverflow answer .