[英]Omnipay token billing not working with stripe
我在laravel中將ignited / laravel-omnipay包用於omnipay。 我正在嘗試使用條紋實現令牌計費,如此處https://github.com/thephpleague/omnipay#token-billing所示。 客戶已成功在條帶上創建,但我無法使用返回的客戶ID進行付款。
這是我的代碼
$token = Input::get('stripetoken');
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('My Key');
$gateway->setTestMode(true);
$cardresponse = $gateway->createCard(array('token' =>$token))->send();
if ($cardresponse->isSuccessful()) {
$card_id = $cardresponse->getCardReference();
$data = $cardresponse->getData();
$customerid = $data['id'];
$cardid = $data['default_source'];
}
$paymentresponse = $gateway->purchase(array('amount' => '10.00','currency' => 'USD', 'cardReference' => $card_id))->send();
echo $paymentresponse->getMessage();
我得到以下回應。
No such token: cus_8FwPaLNKdWcfRW
當我檢查條紋儀表板時,存在具有此ID的客戶並分配了卡。 感謝您的幫助。
由於要創建客戶對象,因此需要更新您的費用創建請求,以在customer
參數而非source
參數中傳遞客戶ID(這會導致您看到錯誤)。
我不熟悉Omnipay,但我認為這應該可以:
$paymentresponse = $gateway->purchase(array('amount' => '10.00','currency' => 'USD', 'customerReference' => $card_id))->send();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.