DROP-IN UI를 설정하려고합니다. 해당 문서에 설명 된대로 내가 백엔드에 Laravel 5.2을 사용하고 있습니다 (설정을 따랐다.서버에 데이터를 게시하려고 할 때 Braintree의 payment_method_nonse가 비어 있습니다.
[https://laravel.com/docs/5.2/billing#braintree-configuration]
을하고 난 BraintreeController.php
을 만들었으며이 json
로 client token
를 반환 그것은 다음과 같습니다
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Braintree_ClientToken;
use App\Http\Requests;
class BraintreeController extends Controller
{
public function token()
{
return response()->json(['token' => Braintree_ClientToken::generate() ], 200);
}
}
이 좋은 내가 AngularJS와 여기에서 설정하고있는 클라이언트 측에
내 BillingController.js
:
$http.get('/braintree/token').then(function(result){
braintree.setup(result.data.token, "dropin", {
container: "payment",
paypal: {
button: {
type: 'checkout'
}
}
});
});
$('#customButton').on('click', function(event) {
var map = {};
$('#billForm').find('input').each(function() {
map[$(this).attr("name")] = $(this).val();
});
console.log(map);
$http.post('/order/checkout', map).then(function(result){
console.log(result);
});
});
그리고 난과 같이 양식을 포함하는 간단한 HTML 템플릿 billing.html
있습니다
<form id="billForm">
<input type="text" name="fullname" id="fullname">
<input type="text" name="address1" id="address1">
<input type="text" name="city" id="city">
<input type="text" name="postalcode" id="postalcode">
<div id="payment"></div>
<button id="customButton">Submit</button>
</form>
내가 가진 문제는 BillingController.js
에 로그가 payment_method_nonse
는 "빈"또는 "비어 있음을 보여주고 있다는 점이다 끈". 누구든지 내가 뭘 잘못하고 있는지 생각해? 고맙습니다.
편집 :
그냥 추가하고 모든 사람에게 게시 된 데이터의 수신 끝에있는 방법을 표시합니다. 기본적으로 양식 데이터를store
메서드 안에
OrdersController.php
에
/order/checkout
에 게시하고 있습니다. 그리고이는 모습입니다 :
public function store(Request $request)
{
$result = Braintree_Transaction::sale([
'amount' => '10.00',
'paymentMethodNonce' => $request->input('payment_method_nonce'),
'options' => [
'submitForSettlement' => True
]
]);
dd($result);
}
을 그리고 이것은이 다시 뱉어 : 양식을 제출하기 전에 양식에
Error {#211
+success: false
#_attributes: array:8 [
"errors" => ErrorCollection {#213
-_errors: ValidationErrorCollection {#227
-_errors: []
-_nested: array:1 [
"transaction" => ValidationErrorCollection {#214
-_errors: array:1 [
0 => Validation {#212
-_attribute: "base"
-_code: "91508"
-_message: "Cannot determine payment method."
}
]
-_nested: array:1 [
"creditCard" => ValidationErrorCollection {#216
-_errors: array:1 [
0 => Validation {#217
-_attribute: "cvv"
-_code: "81706"
-_message: "CVV is required."
}
]
-_nested: []
#_collection: []
}
]
#_collection: []
}
]
#_collection: []
}
}
"params" => array:1 [
"transaction" => array:4 [
"type" => "sale"
"amount" => "10.00"
"paymentMethodNonce" => null
"options" => array:1 [
"submitForSettlement" => "true"
]
]
]
"message" => """
Cannot determine payment method.\n
CVV is required.
"""
"creditCardVerification" => null
"transaction" => null
"subscription" => null
"merchantAccount" => null
"verification" => null
]
}
Braintree_ClientToken :: generate()가 클라이언트 토큰을 올바르게 검색하고 있는지 확인할 수 있습니까? – pblesi
예. 결과에 대한'BillingController.js'의''/ braintree/token "'URI에 서버에 대한 ajax 호출 내에서'console.log'를 실행했습니다 :'consoloe.log (result.data)'그러면 결국 'result.data.token'으로 서버에서'BraintreeController.php' 안에 어떻게 구성했는지 검색했습니다. – iTenzo