Create Stripe payment intent - Fabric
Create Stripe payment intent
cURL
curl --request POST \
--url https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent \
--header 'Content-Type: application/json' \
--data '
{
"amount": 1000,
"currency": "USD",
"customer": "cus_HRp23wXfXMqSao",
"confirm": false,
"off_session": false,
"payment_method": "pm_1Gsv4BFbKq2PvwXbl4XEl1O3",
"payment_method_types": ["card"],
"receipt_email": "joedoe@fabric.inc",
"setup_future_usage": "off_session",
"capture_method": "manual",
"application_fee_amount": 100,
"metadata": {
"orderId": "1234-1234-12345"
}
}
'
Python
import requests
url = "https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent"
payload = {
"amount": 1000,
"currency": "USD",
"customer": "cus_HRp23wXfXMqSao",
"confirm": False,
"off_session": False,
"payment_method": "pm_1Gsv4BFbKq2PvwXbl4XEl1O3",
"payment_method_types": ["card"],
"receipt_email": "joedoe@fabric.inc",
"setup_future_usage": "off_session",
"capture_method": "manual",
"application_fee_amount": 100,
"metadata": { "orderId": "1234-1234-12345" }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch API)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 1000,
currency: 'USD',
customer: 'cus_HRp23wXfXMqSao',
confirm: false,
off_session: false,
payment_method: 'pm_1Gsv4BFbKq2PvwXbl4XEl1O3',
payment_method_types: ['card'],
receipt_email: 'joedoe@fabric.inc',
setup_future_usage: 'off_session',
capture_method: 'manual',
application_fee_amount: 100,
metadata: {orderId: '1234-1234-12345'}
})
};
fetch('https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount' => 1000,
'currency' => 'USD',
'customer' => 'cus_HRp23wXfXMqSao',
'confirm' => false,
'off_session' => false,
'payment_method' => 'pm_1Gsv4BFbKq2PvwXbl4XEl1O3',
'payment_method_types' => ['card'],
'receipt_email' => 'joedoe@fabric.inc',
'setup_future_usage' => 'off_session',
'capture_method' => 'manual',
'application_fee_amount' => 100,
'metadata' => [
'orderId' => '1234-1234-12345'
]
]),
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent"
payload := strings.NewReader("{\n \"amount\": 1000,\n \"currency\": \"USD\",\n \"customer\": \"cus_HRp23wXfXMqSao\",\n \"confirm\": false,\n \"off_session\": false,\n \"payment_method\": \"pm_1Gsv4BFbKq2PvwXbl4XEl1O3\",\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\": \"joedoe@fabric.inc\",\n \"setup_future_usage\": \"off_session\",\n \"capture_method\": \"manual\",\n \"application_fee_amount\": 100,\n \"metadata\": {\n \"orderId\": \"1234-1234-12345\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Java (Unirest)
HttpResponse<String> response = Unirest.post("https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 1000,\n \"currency\": \"USD\",\n \"customer\": \"cus_HRp23wXfXMqSao\",\n \"confirm\": false,\n \"off_session\": false,\n \"payment_method\": \"pm_1Gsv4BFbKq2PvwXbl4XEl1O3\",\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\": \"joedoe@fabric.inc\",\n \"setup_future_usage\": \"off_session\",\n \"capture_method\": \"manual\",\n \"application_fee_amount\": 100,\n \"metadata\": {\n \"orderId\": \"1234-1234-12345\"\n }\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.yourcompany.fabric.zone/ext-stripe/payment-intent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 1000,\n \"currency\": \"USD\",\n \"customer\": \"cus_HRp23wXfXMqSao\",\n \"confirm\": false,\n \"off_session\": false,\n \"payment_method\": \"pm_1Gsv4BFbKq2PvwXbl4XEl1O3\",\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\": \"joedoe@fabric.inc\",\n \"setup_future_usage\": \"off_session\",\n \"capture_method\": \"manual\",\n \"application_fee_amount\": 100,\n \"metadata\": {\n \"orderId\": \"1234-1234-12345\"\n }\n}"
response = http.request(request)
puts response.read_body
Response Structure
Success Response
{
"id": "pi_1GsyhzFbKq2PvwXbwAI3ZluI",
"object": "payment_intent",
"amount": 1000,
"amount_capturable": 0,
"amount_received": 0,
"application_fee_amount": 123,
"client_secret": "pi_1GsyhzFbKq2Pvw1bwAI3ZluI_secret_GKG6hcap7VCggeoqJICAqSsRW",
"currency": "usd",
"status": "requires_payment_method"
}
Error Response
{
"code": "<string>",
"message": "<string>"
}