Zum Hauptinhalt springen
POST
/
payment-methods
curl -X POST \ /payment-methods \ --header "Content-Type: application/json" \ --header "Authorization: Bearer <token>" \ --data '{ "summary": "Create stripe setup intent", "description": "The stripe setup intent clientSecret is required to add a stripe credit card payment method. The clientSecret is required to collect credit card data with stripe.js elements.", "value": { "gateway": "stripe", "type": "card", "customerId": "ad8f7a8d-8f7a-8d8f-7a8d8f7a8d8f", "isDefault": true, "futureUsageAllowed": true, "stripe": { "paymentMethodId": null, "customerId": null } } }'
{
  "status": "action_required",
  "actionRequired": {
    "action": "client_site_action",
    "redirectUrl": null,
    "details": {
      "clientSecret": "seti_1N5J2n2eZvKYlo2C_secret_abc123",
      "publishableKey": "pk_test_1234567890",
      "accountId": "acct_1234567890"
    }
  },
  "failReason": null,
  "paymentMethod": null
}

Autorisierungen

Authorization
string
header
erforderlich

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

The new PaymentMethod resource

Request body for creating a new payment method for a customer.

gateway
enum<string>
erforderlich

The payment gateway to use to process the given payment method type

Possible values:

  • paypal: PayPal (supports "paypal")
  • stripe: Stripe (supports "card")
  • testing: Testing (supports all)
  • go_cardless: GoCardless (supports "sepa_debit")
  • bank_transfer: Bank Transfer (supports "bank_transfer")
  • sepa_debit: SEPA Credit and Debit with xml file (supports "sepa_debit")
  • wallet: Credit Balance from Wallet (supports "wallet")
Verfügbare Optionen:
wallet,
sepa_debit,
stripe,
fake_provider,
paypal,
bank_transfer,
go_cardless,
testing
Beispiel:

"stripe"

type
enum<string>
erforderlich

The payment method type to use for this payment method

Possible values:

  • sepa_debit: SEPA Debit
  • card: Credit Card
  • paypal: PayPal
  • bank_transfer: Bank Transfer
  • wallet: Wallet
Verfügbare Optionen:
sepa_debit,
card,
paypal,
bank_transfer,
wallet,
fake_provider
Beispiel:

"card"

customerId
string | null

The customer that owns this payment method. If not provided, the customer will be determined by the authenticated user.

Beispiel:

"ad8f3b9e-1b1a-4b9a-9b9a-9b9a9b9a9b9a"

isDefault
boolean
Standard:true

Determines if this payment method should be used as default payment method for the customer

Beispiel:

true

futureUsageAllowed
boolean
Standard:true

Determines if this payment method is allowed to be used for future payments. Otherwise the payment method is only available for this payment.

Beispiel:

true

stripe
object

Required when gateway is "stripe". Holds all necessary data for the payment gateway to create the payment method.

sepaMandate
object

Required when gateway is "sepa_debit". Holds all necessary data for the payment gateway to create the payment method.

goCardless
object

Optional for gateway "go_cardless". It is only required when you want to migrate, or assign an existing GoCardless customer or mandate to fynn.

redirectUrl
string | null

The redirect url to redirect the customer to after the payment method was created. This is only required, when you create a payment method with your own flow, independent from provided Hosted-Checkout, Hosted-Customerfront or Fynn.JS. Otherwise this has no effect.

Beispiel:

"https://example.com/checkout/confirm"

Antwort

PaymentMethod resource created

The result of creating a payment method. Contains the status, any required actions, and the created payment method.

status
enum<string>

Possible values:

  • action_required: The payment method requires an action to be taken by the customer
  • success: The payment method was successfully created
  • failed: The payment method could not be created
Verfügbare Optionen:
action_required,
success,
failed
actionRequired
object

The action required if the payment method requires an action to be taken by the customer

  • redirect_to_gateway: The customer needs to be redirected to the payment gateway
  • client_site_action: The customer needs to take an action on the client site
Beispiel:
{
  "action": "client_site_action",
  "details": {
    "clientSecret": "test_1234567890",
    "publishableKey": "pk_test_1234567890",
    "accountId": "acct_1234567890"
  }
}
failReason
string | null

The fail reason if status is failed

paymentMethod
object

The created payment method, if status is success