App öffnen
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
FieldTypeDescription
stripePaymentMethodIdreqstring
setAsDefaultboolean

Responses

201Attached
Body
FieldTypeDescription
paymentMethodIdreqstring
typereqstring
last4reqstring
expMonthreqnumber
expYearreqnumber
isDefaultreqboolean
createdAtreqstring
401Unauthenticated
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
402Stripe rejected attachment (e.g. fraud signal)
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
409Payment method already attached
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
422Validation error (invalid `pm_*`)
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring

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>",
)