try:
payment = pl.Payment.create(
amount=100.0,
payment_method=pl.Card(
card_number='4111 1111 1111 9903',
expiry='12/25',
card_code='123'
)
)
except TransactionDeclined as error:
print(f'Declined: {error.transaction.status_code}')
try {
const payment = await pl.Payment.create({
amount: 100.0,
payment_method: pl.Card({
card_number: '4111 1111 1111 9903',
expiry: '12/25',
card_code: '123'
})
})
} catch(e) {
if (e instanceof pl.TransactionDeclined)
console.log('Declined: ' + e.transaction.status_code)
}
try {
var payment = await pl.Payment.CreateAsync(new {
amount = 100.0,
payment_method = new pl.Card(new {
card_number="4111 1111 1111 9903",
expiry="12/25",
card_code="123"
})
});
} catch (pl.TransactionDeclined e) {
Console.WriteLine("Declined: " + e.details["status_code"]);
}
<?php
try {
$payment = Payload\Transaction::create([
'amount'=>100.0,
'type' => 'payment',
'payment_method' => new Payload\PaymentMethod([
'type' => 'card',
'card' => [
'card_number' => '4111 1111 1111 9903',
'expiry' => '12/25',
'card_code' => '123'
]
])
]);
} catch (TransactionDeclined $e) {
echo('Declined: '. $e->details["status_code"]);
}
?>
begin
payment = Payload::Payment.create(
amount: 100.0,
payment_method: Payload::Card.new(
card_number: '4111 1111 1111 9903',
expiry: '12/25',
card_code: '123'
)
)
rescue TransactionDeclined => err
print "Declined: " + err.details.status_code
end
If a payment has been declined, by default the HTTP request will return a status code of 400. The error
object returned in the response will contain the transaction object with a status of declined. If you're using
one of the Payload libraries, this will result in an TransactionDeclined error.
The transaction's status_code will contain one of the decline codes described below.
To trigger one of the decline codes, use the test number from the below table in the test environment.
| Decline Code | Description | Test Number |
|---|---|---|
card_expired |
The card has expired. | 4111 1111 1111 9900 |
duplicate_attempt |
This transaction appears to be a duplicate attempt and has been prevented. | 4111 1111 1111 9901 |
exceeded_limit |
The amount of the transaction exceeds the allowed limit for this account. | 4111 1111 1111 9902 |
general_decline |
The card has been declined, contact card issuer for more information. | 4111 1111 1111 9903 |
insufficient_bal |
The card does not have a sufficient balance to complete the payment. | 4111 1111 1111 9904 |
invalid_card_code |
The security code is invalid, please check the number. | 4111 1111 1111 9905 |
invalid_card_number |
The card number is invalid, please check the number. | 4111 1111 1111 9906 |
invalid_zip |
The ZIP Code does not match the card. | 4111 1111 1111 9907 |
suspicious_activity |
This transaction has been identified as suspicious. | 4111 1111 1111 9908 |
too_many_attempts |
Too many payment attempts have been made, please try again later. | 4111 1111 1111 9909 |
invalid_address |
The billing address does not match the card. | 4111 1111 1111 9910 |