Allow specific funding
Learn how to restrict the funding of a card. e.g. debit or credit.
Overview
One of the attributes of a card in card payments is the type of funding. The funding of the cards used by your customer can be either debit
or credit
.
Debit cards allow customers to spend money by pulling funds from their bank account. In contrast, credit cards allow customers to borrow money from the card issuer up to a certain credit limit. These two funding types behave differently when used in online payments.
The allow specific funding feature adjusts the payment intent's behavior when processing card
payments. For example, if your use case only allows credit
(or debit
) cards, you can instruct the payment intent to do so.
Allow specific card funding in your integration
When creating a payment intent, you can add a payload attribute called payment_method_options
to specify the allowed card funding before your customer completes a card payment.
If you don't know yet how to integrate payments, please refer to this guide
- Node
- PHP
- Python
- Ruby
// Protect your PayRex Secret API key at all costs. One common approach
// to store it in an environment variable.
// Add your PayRex test secret API key.
const payrexSecretApiKey = '';
const payrex = require('payrex-node')(payrexSecretApiKey);
// Create a PaymentIntent with amount and currency
const paymentIntent = await payrex.paymentIntents.create({
// Amount is in cents. The sample below is 100.00.
amount: 10000,
currency: 'PHP',
payment_method_options: {
card: {
// To only allow credit card and not debit card
allowed_funding: ['credit']
}
},
payment_methods: ['card'],
});
const output = {
clientSecret: paymentIntent.clientSecret,
}
console.log(JSON.stringify(output));
<?php
require_once '../vendor/autoload.php';
// Protect your PayRex Secret API key at all costs. One common approach
// to store it in an environment variable.
// Add your PayRex test secret API key.
$payrexSecretApiKey = '';
$payrex = new \Payrex\PayrexClient($payrexSecretApiKey);
// Create a PaymentIntent with amount and currency
$paymentIntent = $payrex->paymentIntents->create([
// Amount is in cents. The sample below is 100.00.
'amount' => 10000,
'currency' => 'PHP',
'payment_method_options': [
'card': [
// To only allow credit card and not debit card
'allowed_funding': ['credit']
]
],
'payment_methods' => [
'card'
],
]);
$output = [
'clientSecret' => $paymentIntent->client_secret,
];
echo json_encode($output);
from payrex import Client as PayrexClient
# Protect your PayRex Secret API key at all costs. One common approach
# to store it in an environment variable.
# Add your PayRex test secret API key.
payrex_secret_api_key = ''
payrex = PayrexClient(payrex_secret_api_key)
# Create a PaymentIntent with amount and currency
payment_intent = payrex.payment_intents.create(
{
# Amount is in cents. The sample below is 100.00.
'amount': 10000,
'currency': 'PHP',
'payment_method_options': {
'card': {
# To only allow credit card and not debit card
'allowed_funding': ['credit']
}
},
'payment_methods': [
'card',
'gcash'
]
}
)
output = {
'client_secret': payment_intent.client_secret
}
print(output)
require "payrex-ruby"
# Protect your PayRex Secret API key at all costs. One common approach
# to store it in an environment variable.
# Add your PayRex test secret API key.
payrex_secret_api_key = ""
payrex = Payrex::Client.new(payrex_secret_api_key)
# Create a PaymentIntent with amount and currency
payment_intent = payrex.payment_intents.create(
# Amount is in cents. The sample below is 100.00.
amount: 10000,
currency: "PHP",
payment_method_options: {
card: {
# To only allow credit card and not debit card
allowed_funding: ['credit']
}
},
payment_methods: [
"card"
]
)
output = {
clientSecret: payment_intent.client_secret
}
puts output.to_json
With the code above, you are instructing that card payment processed by Payment Intent should only allow credit
cards and not debit.
The payment form will return an error if the customer uses a card where the funding is debit
.