import os
import requests
response = requests.delete(
"https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP",
headers={
"Authorization": f"Bearer {os.environ['STRIPE_SECRET_KEY']}",
"Content-Type": "application/json"
}
)
response.raise_for_status()
import os
import httpx
with httpx.Client() as client:
response = client.delete(
"https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP",
headers={
"Authorization": f"Bearer {os.environ['STRIPE_SECRET_KEY']}",
"Content-Type": "application/json"
}
)
response.raise_for_status()
import fetch from 'node-fetch';
const response = await fetch('https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP', {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${process.env.STRIPE_SECRET_KEY}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
import axios from 'axios';
const response = await axios.delete('https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP', {
headers: {
'Authorization': `Bearer ${process.env.STRIPE_SECRET_KEY}`,
'Content-Type': 'application/json'
}
});
package main
import (
"net/http"
"os"
)
func main() {
req, err := http.NewRequest(
"DELETE",
"https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP",
nil,
)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("STRIPE_SECRET_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode >= 400 {
panic("HTTP request failed")
}
}
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . getenv('STRIPE_SECRET_KEY'),
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new RuntimeException(curl_error($ch));
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
throw new RuntimeException("HTTP request failed with code $httpCode");
}
curl_close($ch);
require 'net/http'
require 'json'
uri = URI('https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP')
req = Net::HTTP::Delete.new(uri)
req['Authorization'] = "Bearer #{ENV['STRIPE_SECRET_KEY']}"
req['Content-Type'] = 'application/json'
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(req)
end
unless res.is_a?(Net::HTTPSuccess)
raise "HTTP request failed: #{res.code} #{res.message}"
end
import Foundation
let url = URL(string: "https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer \(ProcessInfo.processInfo.environment["STRIPE_SECRET_KEY"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
fatalError("Error: \(error)")
}
guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode < 400 else {
fatalError("HTTP request failed")
}
}
task.resume()
use reqwest;
use std::env;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = reqwest::Client::new();
let response = client
.delete("https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP")
.header("Authorization", format!("Bearer {}", env::var("STRIPE_SECRET_KEY").unwrap()))
.header("Content-Type", "application/json")
.send()
.await?;
if !response.status().is_success() {
panic!("HTTP request failed");
}
Ok(())
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {Environment.GetEnvironmentVariable("STRIPE_SECRET_KEY")}");
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
var response = await client.DeleteAsync("https://api.stripe.com/v1/customers/cus_ABCDEFGHIJKLMNOP");
if (!response.IsSuccessStatusCode)
{
throw new Exception("HTTP request failed");
}
}
}