Ginxxx
Ginxxx

Reputation: 1648

Send Invoice to Email Stripe (Google App Scir

Hi guys I am having trouble sending an invoice due to

parameter_invalid_integer

this error.

Here's my code of sending

var url3 = "https://api.stripe.com/v1/invoices";
      var params3 = {
      method: "post",
      headers: {Authorization: "Basic " + Utilities.base64Encode("sk_test_XXXXX:")},
      payload: 
      {
        customer: responseValue.id,
        collection_method : "send_invoice",
        due_date:responseValue2.date
      }
    };
    var res3 = UrlFetchApp.fetch(url3, params3);
    Logger.log(res3.getContentText());

the due_date is the problem because I can't give its format . The documentation didn't provide any of that or I am just dumb that I can't understand it.

I tried

due_date:Date.now()
due_date:"01/01/2022" // tried different formats

What I am trying to do is that I am trying to send the invoice base on the email address provided on the invoice.

Please enlighten me . Thank you.

#TRIED 1

var timeStamp = (new Date('2022-01-01').getTime())/1000;
due_date = timeStamp

still the same error

Upvotes: 1

Views: 164

Answers (3)

Ginxxx
Ginxxx

Reputation: 1648

Solved it . What I did was

var timeStamp = (new Date('2021-08-10').getTime())/1000;
due_date: ""+timeStamp+""

Thanks everyone.

Upvotes: -1

Cooper
Cooper

Reputation: 64100

payload:JSON.stringify({customer:responseValue.id,collection_method:"send_invoice",due_date:responseValue2.date});

I don't know for a fact that this will work but I'd try it if TheMaster said to try it.

Upvotes: 0

Nolan H
Nolan H

Reputation: 7459

All dates/timestamps in the Stripe API use unix seconds (not milliseconds). So you set the due date to Jan 1 2022 (at 0h UTC, say), you'd use due_date=1641013200

Upvotes: 2

Related Questions