Accept a Przelewy24 payment
Przelewy24 is a single use payment method where customers are required to authenticate their payment. Customers pay with Przelewy24 by redirecting from your website, authorizing the payment, then returning to your website where you get immediate notification on whether the payment succeeded or failed.
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
# Available as a gem sudo gem install stripe
# If you use bundler, you can add this line to your Gemfile gem 'stripe'
Create a PaymentIntentServer-side
A PaymentIntent represents your intent to collect payment from a customer and tracks the lifecycle of the payment process.
Create a PaymentIntent
on your server and specify the amount
to collect, and eur
or pln
as the currency. If you have an existing Payment Intents integration, add p24
to the list of payment method types.
curl https://api.stripe.com/v1/payment_intents \ -u
: \ -d "amount"=1099 \ -d "currency"="pln" \ -d "payment_method_types[]"="p24"sk_test_4eC39HqLyjWDarjtT1zdp7dc
Instead of passing the entire PaymentIntent object to your app, return its client secret. The PaymentIntent’s client secret is a unique key that lets you confirm the payment and update payment details on the client, without allowing manipulation of sensitive information, like the payment amount.
Statement descriptors with Przelewy24
You can also set a custom statement descriptor before confirming the PaymentIntent. For Przelewy24, the statement descriptor is limited to 14 characters. It’s visible on your customer’s bank records with the format P24-XXX-XXX-XXX {statement_descriptor}
, where P24-XXX-XXX-XXX
is a unique reference for the payment.
Collect payment method detailsClient-side
Collect payment information on the client with Stripe Elements. Elements is a set of prebuilt UI components for collecting payment details.
A Stripe Element contains an iframe that securely sends the payment information to Stripe over an HTTPS connection. The checkout page address must also start with https:// rather than http:// for your integration to work.
You can test your integration without using HTTPS. Enable it when you’re ready to accept live payments.
Set up Stripe Elements
Stripe Elements is automatically available as a feature of Stripe.js. Include the Stripe.js script on your payment page by adding it to the head
of your HTML file. Always load Stripe.js directly from js.stripe.com to remain PCI compliant. Do not include the script in a bundle or host a copy of it yourself.
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>
Create an instance of Elements with the following JavaScript on your checkout page:
var stripe = Stripe(
); var elements = stripe.elements();'pk_test_TYooMQauvdEDq54NiTphI7jx'
Add and configure an p24Bank
Element
Elements needs a place to live in your payment form. Create empty DOM nodes (containers) with unique IDs in your payment form and then pass those IDs to Elements.
<form id="payment-form"> <div class="form-row"> <label for="accountholder-name"> Name </label> <input id="accountholder-name" name="accountholder-name"> </div> <div class="form-row"> <!-- Using a label with a for attribute that matches the ID of the Element container enables the Element to automatically gain focus when the customer clicks on the label. --> <label for="p24-bank-element"> P24 Bank </label> <div id="p24-bank-element"> <!-- A Stripe Element will be inserted here. --> </div> </div> <button>Submit Payment</button> <!-- Used to display form errors. --> <div id="error-message" role="alert"></div> </form>
When the form above has loaded, create an instance of an p24Bank
Element and mount it to the Element container created above:
var options = { // Custom styling can be passed to options when creating an Element style: { base: { padding: '10px 12px', color: '#32325d', fontSize: '16px', '::placeholder': { color: '#aab7c4' }, }, }, }; // Create an instance of the p24Bank Element var p24Bank = elements.create('p24Bank', options); // Add an instance of the p24Bank Element into // the `p24-bank-element` <div> p24Bank.mount('#p24-bank-element');
Elements are completely customizable. You can style Elements to match the look and feel of your site, providing a seamless checkout experience for your customers. It’s also possible to style various input states (e.g., when the Element has focus).
Submit the payment to StripeClient-side
Rather than sending the entire PaymentIntent object to the client, use its client secret. This is different from your API keys that authenticate Stripe API requests. The client secret should be handled carefully because it can complete the charge. Do not log it, embed it in URLs, or expose it to anyone but the customer.
Use stripe.confirmP24Payment to handle the redirect away from your page and to complete the payment. Add a return_url to this function to indicate where Stripe should redirect the user after they complete the payment on their bank’s website or mobile application.
var form = document.getElementById('payment-form'); var accountholderName = document.getElementById('accountholder-name'); var accountholderEmail = document.getElementById('accountholder-email'); form.addEventListener('submit', function(event) { event.preventDefault(); // Redirects away from the client stripe.confirmP24Payment( '{{PAYMENT_INTENT_CLIENT_SECRET}}', { payment_method: { p24: p24Bank, billing_details: { name: accountholderName.value, email: accountholderEmail.value, }, }, payment_method_options: { p24: { // In order to be able to pass the `tos_shown_and_accepted` parameter, you must // ensure that the P24 regulations and information obligation consent // text is clearly visible to the customer. See // stripe.com/docs/payments/p24/accept-a-payment#requirements // for directions. tos_shown_and_accepted: true, } }, return_url: 'https://your-website.com/checkout/complete', } ); });
The return_url
should correspond to a page on your website that provides the status of the payment, by verifying the status of the PaymentIntent
when rendering the return page. When Stripe redirects the customer to the return_url
, the following URL query parameters are provided to verify status. You may also append your own query parameters when providing the return_url
. They will persist through the redirect process.
Parameter | Description |
---|---|
payment_intent | The unique identifier for the PaymentIntent |
payment_intent_client_secret | The client secret of the PaymentIntent object |
You can find details about the bank account the customer used to complete the payment on the resulting Charge under the payment_method_details property.
{ "charges": { "data": [ { "payment_method_details": { "p24": { "bank": "inteligo", "reference": "P24 123-456-789", "verified_name": "JENNY ROSEN" }, "type": "p24" }, "id": "src_16xhynE8WzK49JbAs9M21jaR", "object": "source", "amount": 1099,
Test your integration
Select any bank in the P24 bank list with your test API keys. After confirming the payment, you’re redirected to a test page with options to succeed or fail the payment. You can test the successful payment case by authenticating the payment on the redirect page. The PaymentIntent will transition from requires_action
to succeeded
.
To test the case where the user fails to authenticate, select any bank with your test API keys. On the redirect page, click Fail test payment. Your PaymentIntent will transition from requires_action
to requires_payment_method
.
Przelewy24 requirements
Przelewy24 requires customers to agree to their Terms of Service in order to successfully authorize the transaction. This means that the customer will first be redirected to a Przelewy24 page where they can accept these terms. In order to skip the intermediate page, you are required to present the Przelewy24 terms on your website, and collect consent on their behalf. When you have done that, you will be able to set the p24[tos_shown_and_accepted]
payment method option.
Requirement | Details |
---|---|
Present a hyperlinked Przelewy24 Terms of Service standard wording with hyperlinks. | The following text should be clearly visible to the customer, with hyperlinks included:
|
Bank values
Bank name | Value |
---|---|
Alior Bank | alior_bank |
Bank Millenium | bank_millennium |
Bank Nowy BFG S.A. | bank_nowy_bfg_sa |
Bank PEKAO S.A | bank_pekao_sa |
Banki SpBdzielcze | banki_spbdzielcze |
Blik via redirect | blik |
BNP Paribas | bnp_paribas |
BOZ | boz |
CitiHandlowy | citi_handlowy |
Credit Agricole | credit_agricole |
EnveloBank | envelobank |
e-Transfer Poctowy24 | etransfer_pocztowy24 |
Getin Bank | getin_bank |
IdeaBank | ideabank |
ING | ing |
inteligo | inteligo |
mBank-mtransfer | mbank_mtransfer |
Nest Przelew | nest_przelew |
Noble Pay | noble_pay |
PBac z iPKO (PKO+BP) | pbac_z_ipko |
Plus Bank | plus_bank |
Santander-przelew24 | santander_przelew24 |
T-Mobile Usbugi Bankowe | tmobile_usbugi_bankowe |
Toyota Bank | toyota_bank |
Volkswagen Bank | volkswagen_bank |