Moonborn — API · billing
Attach a payment method already created via Stripe Elements
PCI scope kalır: Stripe Elements client-side'da PAN + CVC + postal alır ve `pm_*` üretir. Bu endpoint sadece `pm_*` referansını org'a bağlar; hiçbir kart verisi servera ulaşmaz.
POST/v1/billing/payment_methodsscope · Bearer (API key or session JWT)
Request body
| Field | Type | Description |
|---|---|---|
| stripePaymentMethodIdreq | string | |
| setAsDefault | boolean |
Responses
201Attached
Body
| Field | Type | Description |
|---|---|---|
| paymentMethodIdreq | string | |
| typereq | string | |
| last4req | string | |
| expMonthreq | number | |
| expYearreq | number | |
| isDefaultreq | boolean | |
| createdAtreq | string |
401Unauthenticated
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
402Stripe rejected attachment (e.g. fraud signal)
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
409Payment method already attached
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
422Validation error (invalid `pm_*`)
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
Examples
cURL
curl -X POST https://api.moonborn.co/v1/billing/payment_methods \
-H "Authorization: Bearer $MOONBORN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stripePaymentMethodId": "<string>"
}'TypeScript
import Moonborn from '@moonborn/sdk';
const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });
const result = await client.billing.attachPaymentMethod({
stripePaymentMethodId: "<string>",
});Python
import os
from moonborn import Moonborn
client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])
result = client.billing.attach_payment_method(
stripe_payment_method_id="<string>",
)