connecteev
5 months ago
525
2
Testing

Calling Stripe's javascript APIs from PHPUnit?

Posted 5 months ago by connecteev

This may come off as a strange question, is there a way to call a javascript API from phpunit or laravel dusk? I need to call Stripe's Javascript API: https://stripe.com/docs/js/setup_intents/confirm_card_setup and I don't see a "php" or backend way of doing it

I have a value for this.stripePublicKey and intentToken available in phpunit, I now need to do this:

      this.stripe = Stripe(this.stripePublicKey);
      this.elements = this.stripe.elements();
      this.card = this.elements.create('card', {style: this.stripeOptions.style});
      this.card.mount('#card-element');

      this.stripe.confirmCardSetup(
        this.intentToken.client_secret, {
          payment_method: {
            card: this.card,
            billing_details: {
              name: this.name
            }
          }
        }
      ).then(function(result) {
          console.log("Your card has been added to your account, but you have not yet been charged");
          this.savePaymentMethod(result.setupIntent.payment_method);
      }.bind(this));

Please sign in or create an account to participate in this conversation.