API reference
Payment Methods
PaymentMethod objects represent your customer's payment instruments. You can use them with PaymentIntents to collect payments or save them to Customer objects to store instrument details for future payments. Related guides: Payment Methods and More Payment Scenarios.
Create a PaymentMethod
POST/v1/payment_methods
Creates a PaymentMethod object. Read the Stripe.js reference to learn how to create PaymentMethods via Stripe.js. Instead of creating a PaymentMethod directly, we recommend using the PaymentIntents API to accept a payment immediately or the SetupIntent API to collect payment method details ahead of a future payment.
Body parameters
acss_debitobjectIf this is an
acss_debitPaymentMethod, this hash contains details about the ACSS Debit payment method.Show 3 child parameters
account_numberstringRequiredinstitution_numberstringRequiredtransit_numberstringRequired
affirmobjectIf this is an
affirmPaymentMethod, this hash contains details about the Affirm payment method.afterpay_clearpayobjectIf this is an
AfterpayClearpayPaymentMethod, this hash contains details about the AfterpayClearpay payment method.alipayobjectIf this is an
AlipayPaymentMethod, this hash contains details about the Alipay payment method.allow_redisplaystringThis field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to
unspecified.Possible valuesalwayslimitedunspecified
almaobjectIf this is a Alma PaymentMethod, this hash contains details about the Alma payment method.
amazon_payobjectIf this is a AmazonPay PaymentMethod, this hash contains details about the AmazonPay payment method.
au_becs_debitobjectIf this is an
au_becs_debitPaymentMethod, this hash contains details about the bank account.Show 2 child parameters
account_numberstringRequiredbsb_numberstringRequired
bacs_debitobjectIf this is a
bacs_debitPaymentMethod, this hash contains details about the Bacs Direct Debit bank account.Show 2 child parameters
account_numberstringsort_codestring
bancontactobjectIf this is a
bancontactPaymentMethod, this hash contains details about the Bancontact payment method.billieobjectIf this is a
billiePaymentMethod, this hash contains details about the Billie payment method.billing_detailsobjectBilling information associated with the PaymentMethod that may be used or required by particular types of payment methods.
Show 5 child parameters
addressobjectShow 6 child parameters
citystringcountrystringline1stringline2stringpostal_codestringstatestring
emailstringnamestringphonestringtax_idstring
bizumobjectIf this is a
bizumPaymentMethod, this hash contains details about the Bizum payment method.blikobjectIf this is a
blikPaymentMethod, this hash contains details about the BLIK payment method.boletoobjectIf this is a
boletoPaymentMethod, this hash contains details about the Boleto payment method.Show 1 child parameter
tax_idstringRequired
cardobjectIf this is a
cardPaymentMethod, this hash contains the user's card details. For backwards compatibility, you can alternatively provide a Stripe token (e.g., for Apple Pay, Amex Express Checkout, or legacy Checkout) into the card hash with formatcard: {token: "tok_visa"}. When providing a card number, you must meet the requirements for PCI compliance. We strongly recommend using Stripe.js instead of interacting with this API directly.Show 5 child parameters
exp_monthintegerRequiredexp_yearintegerRequirednumberstringRequiredcvcstringnetworksobjectShow 1 child parameter
preferredstringPossible valuescartes_bancairesmastercardvisa
cashappobjectIf this is a
cashappPaymentMethod, this hash contains details about the Cash App Pay payment method.cryptoobjectIf this is a Crypto PaymentMethod, this hash contains details about the Crypto payment method.
customobjectIf this is a
customPaymentMethod, this hash contains details about the Custom payment method.Show 1 child parameter
typestringRequired
customerstringThe
Customerto whom the original PaymentMethod is attached.customer_balanceobjectIf this is a
customer_balancePaymentMethod, this hash contains details about the CustomerBalance payment method.epsobjectIf this is an
epsPaymentMethod, this hash contains details about the EPS payment method.Show 1 child parameter
bankstringPossible valuesarzte_und_apotheker_bankaustrian_anadi_bank_agbank_austriabankhaus_carl_spanglerbankhaus_schelhammer_und_schattera_agbawag_psk_agbks_bank_agbrull_kallmus_bank_agbtv_vier_lander_bankcapital_bank_grawe_gruppe_agdeutsche_bank_agdolomitenbankeasybank_agerste_bank_und_sparkassenhypo_alpeadriabank_international_aghypo_bank_burgenland_aktiengesellschaft- and 12 more
expandarray of stringsSpecifies which fields in the response should be expanded.
fpxobjectIf this is an
fpxPaymentMethod, this hash contains details about the FPX payment method.Show 1 child parameter
bankstringRequiredPossible valuesaffin_bankagrobankalliance_bankambankbank_islambank_muamalatbank_of_chinabank_rakyatbnp_paribasbsncimbcitibankdeutsche_bankhong_leong_bankhsbckfh- and 9 more
giropayobjectIf this is a
giropayPaymentMethod, this hash contains details about the Giropay payment method.grabpayobjectIf this is a
grabpayPaymentMethod, this hash contains details about the GrabPay payment method.idealobjectIf this is an
idealPaymentMethod, this hash contains details about the iDEAL payment method.Show 1 child parameter
bankstringPossible valuesabn_amroadyenasn_bankbunqbuutfinomhandelsbankeningknabmolliemoneyoun26nnrabobankregiobankrevolut- and 4 more
interac_presentobjectIf this is an
interac_presentPaymentMethod, this hash contains details about the Interac Present payment method.kakao_payobjectIf this is a
kakao_payPaymentMethod, this hash contains details about the Kakao Pay payment method.klarnaobjectIf this is a
klarnaPaymentMethod, this hash contains details about the Klarna payment method.Show 1 child parameter
dobobjectShow 3 child parameters
dayintegerRequiredmonthintegerRequiredyearintegerRequired
konbiniobjectIf this is a
konbiniPaymentMethod, this hash contains details about the Konbini payment method.kr_cardobjectIf this is a
kr_cardPaymentMethod, this hash contains details about the Korean Card payment method.linkobjectIf this is an
LinkPaymentMethod, this hash contains details about the Link payment method (Link is also known as Onelink in the UK).mb_wayobjectIf this is a MB WAY PaymentMethod, this hash contains details about the MB WAY payment method.
metadataobjectSet of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata.mobilepayobjectIf this is a
mobilepayPaymentMethod, this hash contains details about the MobilePay payment method.multibancoobjectIf this is a
multibancoPaymentMethod, this hash contains details about the Multibanco payment method.naver_payobjectIf this is a
naver_payPaymentMethod, this hash contains details about the Naver Pay payment method.Show 1 child parameter
fundingstringPossible valuescardpoints
nz_bank_accountobjectIf this is an nz_bank_account PaymentMethod, this hash contains details about the nz_bank_account payment method.
Show 6 child parameters
account_numberstringRequiredbank_codestringRequiredbranch_codestringRequiredsuffixstringRequiredaccount_holder_namestringreferencestring
oxxoobjectIf this is an
oxxoPaymentMethod, this hash contains details about the OXXO payment method.p24objectIf this is a
p24PaymentMethod, this hash contains details about the P24 payment method.Show 1 child parameter
bankstringPossible valuesalior_bankbank_millenniumbank_nowy_bfg_sabank_pekao_sabanki_spbdzielczeblikbnp_paribasbozciti_handlowycredit_agricoleenvelobanketransfer_pocztowy24getin_bankideabankinginteligo- and 10 more
pay_by_bankobjectIf this is a
pay_by_bankPaymentMethod, this hash contains details about the PayByBank payment method.paycoobjectIf this is a
paycoPaymentMethod, this hash contains details about the PAYCO payment method.payment_methodstringThe PaymentMethod to share.
paynowobjectIf this is a
paynowPaymentMethod, this hash contains details about the PayNow payment method.paypalobjectIf this is a
paypalPaymentMethod, this hash contains details about the PayPal payment method.paytoobjectIf this is a
paytoPaymentMethod, this hash contains details about the PayTo payment method.Show 3 child parameters
account_numberstringbsb_numberstringpay_idstring
pixobjectIf this is a
pixPaymentMethod, this hash contains details about the Pix payment method.promptpayobjectIf this is a
promptpayPaymentMethod, this hash contains details about the PromptPay payment method.radar_optionsobjectOptions to configure Radar. See Radar Session for more information.
Show 1 child parameter
sessionstring
revolut_payobjectIf this is a
revolut_payPaymentMethod, this hash contains details about the Revolut Pay payment method.samsung_payobjectIf this is a
samsung_payPaymentMethod, this hash contains details about the SamsungPay payment method.satispayobjectIf this is a
satispayPaymentMethod, this hash contains details about the Satispay payment method.scalapayobjectIf this is a Scalapay PaymentMethod, this hash contains details about the Scalapay payment method.
sepa_debitobjectIf this is a
sepa_debitPaymentMethod, this hash contains details about the SEPA debit bank account.Show 1 child parameter
ibanstringRequired
sofortobjectIf this is a
sofortPaymentMethod, this hash contains details about the SOFORT payment method.Show 1 child parameter
countrystringRequiredPossible valuesATBEDEESITNL
sunbitobjectIf this is a
sunbitPaymentMethod, this hash contains details about the Sunbit payment method.swishobjectIf this is a
swishPaymentMethod, this hash contains details about the Swish payment method.twintobjectIf this is a TWINT PaymentMethod, this hash contains details about the TWINT payment method.
typestringThe type of the PaymentMethod. An additional hash is included on the PaymentMethod with a name matching this value. It contains additional information specific to the PaymentMethod type.
Possible valuesacss_debitaffirmafterpay_clearpayalipayalmaamazon_payau_becs_debitbacs_debitbancontactbilliebizumblikboletocardcashappcrypto- and 39 more
upiobjectIf this is a
upiPaymentMethod, this hash contains details about the UPI payment method.Show 1 child parameter
mandate_optionsobjectShow 4 child parameters
amountintegeramount_typestringPossible valuesfixedmaximum
descriptionstringend_dateinteger
us_bank_accountobjectIf this is an
us_bank_accountPaymentMethod, this hash contains details about the US bank account payment method.Show 5 child parameters
account_holder_typestringPossible valuescompanyindividual
account_numberstringaccount_typestringPossible valuescheckingsavings
financial_connections_accountstringrouting_numberstring
wechat_payobjectIf this is an
wechat_payPaymentMethod, this hash contains details about the wechat_pay payment method.zipobjectIf this is a
zipPaymentMethod, this hash contains details about the Zip payment method.
Returns
The payment_method object.
curl -X POST https://api.knoxapi.com/v1/payment_methods \
-H "Authorization: Bearer $KNOX_SECRET_KEY"const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const paymentMethod = await stripe.paymentMethods.create();import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
payment_method = client.v1.payment_methods.create()require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
payment_method = Stripe::PaymentMethod.create(){
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}List PaymentMethods
GET/v1/payment_methods
Returns a list of all PaymentMethods.
Query parameters
allow_redisplaystringThis field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
Possible valuesalwayslimitedunspecified
customerstringThe ID of the customer whose PaymentMethods will be retrieved.
customer_accountstringThe ID of the Account whose PaymentMethods will be retrieved.
ending_beforestringA cursor for use in pagination.
ending_beforeis an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting withobj_bar, your subsequent call can includeending_before=obj_barin order to fetch the previous page of the list.expandarray of stringsSpecifies which fields in the response should be expanded.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
starting_afterstringA cursor for use in pagination.
starting_afteris an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending withobj_foo, your subsequent call can includestarting_after=obj_fooin order to fetch the next page of the list.typestringFilters the list by the object
typefield. Unfiltered, the list returns all payment method types exceptcustom. If your integration expects only one type of payment method in the response, specify that type value in the request to reduce your payload.Possible valuesacss_debitaffirmafterpay_clearpayalipayalmaamazon_payau_becs_debitbacs_debitbancontactbilliebizumblikboletocardcashappcrypto- and 39 more
Returns
A list of payment_method objects.
curl -G https://api.knoxapi.com/v1/payment_methods \
-H "Authorization: Bearer $KNOX_SECRET_KEY" \
--data-urlencode limit=3const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const page = await stripe.paymentMethods.list({
limit: 3,
});import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
page = client.v1.payment_methods.list(params={
"limit": 3,
})require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
page = Stripe::PaymentMethod.list({
limit: 3,
}){
"object": "list",
"url": "/v1/payment_methods",
"has_more": false,
"data": [
{
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}
]
}Update a PaymentMethod
POST/v1/payment_methods/{payment_method}
Updates a PaymentMethod object. A PaymentMethod must be attached to a customer to be updated.
Path parameters
payment_methodstringRequired
Body parameters
allow_redisplaystringThis field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to
unspecified.Possible valuesalwayslimitedunspecified
billing_detailsobjectBilling information associated with the PaymentMethod that may be used or required by particular types of payment methods.
Show 5 child parameters
addressobjectShow 6 child parameters
citystringcountrystringline1stringline2stringpostal_codestringstatestring
emailstringnamestringphonestringtax_idstring
cardobjectIf this is a
cardPaymentMethod, this hash contains the user's card details.Show 3 child parameters
exp_monthintegerexp_yearintegernetworksobjectShow 1 child parameter
preferredstringPossible valuescartes_bancairesmastercardvisa
expandarray of stringsSpecifies which fields in the response should be expanded.
metadataobjectSet of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to
metadata.paytoobjectIf this is a
paytoPaymentMethod, this hash contains details about the PayTo payment method.Show 3 child parameters
account_numberstringbsb_numberstringpay_idstring
us_bank_accountobjectIf this is an
us_bank_accountPaymentMethod, this hash contains details about the US bank account payment method.Show 2 child parameters
account_holder_typestringPossible valuescompanyindividual
account_typestringPossible valuescheckingsavings
Returns
The payment_method object.
curl https://api.knoxapi.com/v1/payment_methods/pm_1Pgc75B7WZ01zgkWlHVgdEGJ \
-H "Authorization: Bearer $KNOX_SECRET_KEY" \
-d "metadata[order_id]=6735"const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const paymentMethod = await stripe.paymentMethods.update('pm_1Pgc75B7WZ01zgkWlHVgdEGJ', {
metadata: {
order_id: '6735',
},
});import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
payment_method = client.v1.payment_methods.update("pm_1Pgc75B7WZ01zgkWlHVgdEGJ", params={
"metadata": {
"order_id": "6735",
},
})require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
payment_method = Stripe::PaymentMethod.update('pm_1Pgc75B7WZ01zgkWlHVgdEGJ', {
metadata: {
order_id: '6735',
},
}){
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}Retrieve a PaymentMethod
GET/v1/payment_methods/{payment_method}
Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a payment method attached to a Customer, you should use Retrieve a Customer’s PaymentMethods
Path parameters
payment_methodstringRequired
Query parameters
expandarray of stringsSpecifies which fields in the response should be expanded.
Returns
The payment_method object.
curl https://api.knoxapi.com/v1/payment_methods/pm_1Pgc75B7WZ01zgkWlHVgdEGJ \
-H "Authorization: Bearer $KNOX_SECRET_KEY"const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const paymentMethod = await stripe.paymentMethods.retrieve('pm_1Pgc75B7WZ01zgkWlHVgdEGJ');import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
payment_method = client.v1.payment_methods.retrieve("pm_1Pgc75B7WZ01zgkWlHVgdEGJ")require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
payment_method = Stripe::PaymentMethod.retrieve('pm_1Pgc75B7WZ01zgkWlHVgdEGJ'){
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}Attach a PaymentMethod to a Customer
POST/v1/payment_methods/{payment_method}/attach
Attaches a PaymentMethod object to a Customer. To attach a new PaymentMethod to a customer for future payments, we recommend you use a SetupIntent or a PaymentIntent with setup_future_usage. These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for future use, which makes later declines and payment friction more likely. See Optimizing cards for future payments for more information about setting up future payments. To use this PaymentMethod as the default for invoice or subscription payments, set invoice_settings.default_payment_method, on the Customer to the PaymentMethod’s ID.
Path parameters
payment_methodstringRequired
Body parameters
customerstringThe ID of the customer to which to attach the PaymentMethod.
customer_accountstringThe ID of the Account representing the customer to which to attach the PaymentMethod.
expandarray of stringsSpecifies which fields in the response should be expanded.
Returns
The payment_method object.
curl -X POST https://api.knoxapi.com/v1/payment_methods/pm_1Pgc75B7WZ01zgkWlHVgdEGJ/attach \
-H "Authorization: Bearer $KNOX_SECRET_KEY"const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const paymentMethod = await stripe.paymentMethods.attach('pm_1Pgc75B7WZ01zgkWlHVgdEGJ');import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
payment_method = client.v1.payment_methods.attach("pm_1Pgc75B7WZ01zgkWlHVgdEGJ")require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
payment_method = Stripe::PaymentMethod.attach('pm_1Pgc75B7WZ01zgkWlHVgdEGJ'){
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}Detach a PaymentMethod from a Customer
POST/v1/payment_methods/{payment_method}/detach
Detaches a PaymentMethod object from a Customer. Detachment is permanent and irreversible — once detached, a PaymentMethod can no longer be used for payments or re-attached to a Customer.
Path parameters
payment_methodstringRequired
Body parameters
expandarray of stringsSpecifies which fields in the response should be expanded.
Returns
The payment_method object.
curl -X POST https://api.knoxapi.com/v1/payment_methods/pm_1Pgc75B7WZ01zgkWlHVgdEGJ/detach \
-H "Authorization: Bearer $KNOX_SECRET_KEY"const Stripe = require('stripe');
const stripe = new Stripe(process.env.KNOX_SECRET_KEY, {host: 'api.knoxapi.com'});
const paymentMethod = await stripe.paymentMethods.detach('pm_1Pgc75B7WZ01zgkWlHVgdEGJ');import os
import stripe
client = stripe.StripeClient(
os.environ["KNOX_SECRET_KEY"],
base_addresses={"api": "https://api.knoxapi.com"},
)
payment_method = client.v1.payment_methods.detach("pm_1Pgc75B7WZ01zgkWlHVgdEGJ")require 'stripe'
Stripe.api_key = ENV['KNOX_SECRET_KEY']
Stripe.api_base = 'https://api.knoxapi.com'
payment_method = Stripe::PaymentMethod.detach('pm_1Pgc75B7WZ01zgkWlHVgdEGJ'){
"allow_redisplay": "unspecified",
"billing_details": {
"address": {
"city": "San Francisco",
"country": "US",
"line1": "1234 Fake Street",
"line2": null,
"postal_code": "94102",
"state": "CA"
},
"email": "[email protected]",
"name": null,
"phone": "+15555555555",
"tax_id": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"display_brand": "visa",
"exp_month": 8,
"exp_year": 2030,
"fingerprint": "AOB934RVNwzk6xtn",
"funding": "credit",
"generated_from": {
"charge": null,
"payment_method_details": {
"type": "type"
},
"setup_attempt": null
},
"last4": "4242",
"networks": {
"available": [
"visa"
],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": {
"dynamic_last4": null,
"type": "link"
},
"regulated_status": null
},
"created": 1234567890,
"customer": null,
"id": "pm_1Pgc75B7WZ01zgkWlHVgdEGJ",
"livemode": false,
"metadata": {
"order_id": "123456789"
},
"object": "payment_method",
"type": "card",
"customer_account": null
}Operations and schemas come from the pinned Stripe OpenAPI specification (MIT); response examples from its fixtures. Nested object definitions and enums are in the complete specification.