Search code examples
javascriptangularjsionic-frameworkstripe-paymentsstrip

Stripe API - Retrieve all Receipts (Invoice) using Javascript


I found at the Stripe Api there is way to retrieve all invoices. However, it does not show how to retrieve them through javascript.

I've done something similar by creating a payment and it's response is the receipt itself.

if ($scope.card.error == "" && $scope.card.cvc_error == "" && $scope.card.cardType != "Unrecognizable card type") {

            return stripe.card.createToken({
                number: $scope.card.number,
                cvc: $scope.card.cvc,
                exp_month: $scope.card.exp_month,
                exp_year: $scope.card.exp_year
            }).then(function (response) {
                //Todo connect to api

                console.log(response)

            }).then(function (res) {

                $scope.successAlert();
            })
        } else {

            $scope.errorAlert(validationArray);
        }

I'm using angular.


Solution

  • The list all invoices API call can only be issed with your secret API key, so you can't send this request from your frontend code. You need to issue the request from your backend, and forward the results to your frontend code for displaying.