I have problem while using stripe with angular js.I have Successfully generate the token with Stripe.but when I post that token to the api it gives error:
{"errors":"There is no token with ID tok_160BQoCgr0gFKoypElkitdl6.
Here is My Controller code:
$scope.card =function()
{
var number = document.getElementById('number').value;
var expiry = document.getElementById('exp').value;
var res = expiry.split("/");
var month = res[0];
var year = res[1];
var cvv = document.getElementById('cvc').value;
$scope.stripeCallback = function (code, result) {
if (result.error) {
$scope.stripeError = result.error.message;
} else {
$scope.stripeToken = result.id;
}
var api_token=storageService.get("api_token");
$scope.orginal.api_token =JSON.parse(api_token);
//var data = {'number':number,'exp-month':month,'exp-year':year,'stripeToken':$scope.stripeToken,'api_token':$scope.orginal.api_token};
var data = 'number='+number+'&exp-month='+month+'&exp-year='+year+'&stripeToken='+$scope.stripeToken+'&api_token='+$scope.orginal.api_token;
console.log(data);
HomeOwners.NewCard(data).then(function(response){
console.log(response);
})
};
Here is My service:
NewCard:function(data){
var Url = baseurl+'card/create';
var defer = $q.defer();
$http.post(Url,data).
success(function (data, status, headers, config) {
defer.resolve(data);
}).
error(function (data, status, headers, config) {
defer.reject();
});
return defer.promise;
},
Please help