Recurring credit card payments extend the regular credit card payments, so please walk it through first.
When the dialog is used for recurring payment it is returning a payment_token
that can be used multiple times. The token is associated with the specific credit card and with this specific Shop only. The shop can store the token and use it later on to take payments according to its own business logic.
<?php $request_body = array( 'transaction' => array( 'amount' => $context->transaction->amount, 'currency' => $context->transaction->currency, 'reference' => $context->transaction->reference ), 'customer' => array( 'email' => $context->customer->email, 'ip' => $context->customer->ip, 'country' => $context->customer->country, 'locale' => $context->customer->locale ) ); $transaction = $MK->createTransaction($request_body); ?>
Request | |
Content type |
|
Headers | |
Body | |
Response | |
Content type |
|
Headers | |
Body
|
|
So we have now Transaction ID:
3D Secure test cards
To simulate decline you should use same test cards with amount 99.99 EUR. All card payments with such amount will fail.
<script src="<?php echo $context->creditcard->url; ?>/checkout/dist/checkout.js"></script> <script> window.cc_callback = function(data) { alert( 'The CC dialog returned: \r\n \r\n'+ JSON.stringify(data) ); } window.Maksekeskus.Checkout.initialize( { 'key' : '<?php echo $context->shop->publishableKey; ?>', 'transaction' : '<?php echo $transaction->id; ?>', 'amount' : '<?php echo $transaction->amount; ?>', 'currency' : '<?php echo $transaction->currency; ?>', 'email' : 'john@diehard.ly', 'clientName' : 'John McLane', 'locale' : 'en', 'name' : 'MyService.com', 'description' : 'Order no. 123abc', 'recurringRequired' : 'true', 'recurringTitle' : 'MyService.com subscription', 'recurringDescription' : 'membership fee is 10€ monthly', 'recurringConfirmation' : 'i agree that the fee will be taken from my credit card each month automatically', 'completed' : 'cc_callback', 'cancelled' : 'cc_callback' } ); </script> <button type="button" class="btn btn-primary" aria-label="Open Recurring CC Payment dialog" onclick="window.Maksekeskus.Checkout.open();">Open CC Payment dialog</button>
HTML property name | JS option name | Required | Description |
---|---|---|---|
data-key |
key |
Yes | Shop's Public API Key (available in your Merchant Portal) |
data-transaction |
transaction |
Yes | Transaction ID (created via Billing API) |
data-email |
email |
Pre-filled customer email. | |
data-client-name |
clientName |
Pre-filled customer name. | |
data-locale |
locale |
Customer's language (ISO 639-1). Defaults to en. Languages available:
|
|
data-recurring-title |
recurringTitle |
Title of the subscription/recurring payment the customer is subscribing for. The definition of this option triggers the Checkout form to display recurring payment details. | |
data-recurring-description |
recurringDescription |
Description of the subscription/recurring payment the customer is subscribing for. Include here information about recurring payment amount, interval, etc. | |
data-recurring-confirmation |
recurringConfirmation |
Confirmation text shown next to the approval checkbox for the customer to accept recurring billing. | |
data-recurring-checked |
recurringChecked |
Whether or not the approval checkbox to accept recurring billing is checked by default. Defaults to false. NB! It probably legally more correct that the user does the agreement check by himself. |
|
data-recurring-required |
recurringRequired |
Signals that the dialog will not allow make the payent unless user has marked in the 'recurring-confirmation' checkbox. | |
data-selector |
selector |
Hooks quick implementation to the given selector. Note: it is document.querySelector not jQuery so no fancy selectors. | |
data-completed |
completed |
Name of the JavaScript function to be invoked on success. Will be called with the data argument. | |
data-cancelled |
cancelled |
Name of the JavaScript function to be invoked on user cancel action (modal close). No arguments passed. | |
noConflict |
Tells Checkout to run in noConflic mode. This will return a new instance of Checkout, allowing you to run multiple instances on the same page. Defaults to true in quick mode, false in custom mode. | ||
persistentModal |
Boolean. When set to true, iframe will not be destroyed on close. | ||
openOnLoad |
Open modal right away (on script load). | ||
data-backdrop-close |
backdropClose |
add data-backdrop-close="false" if you want the CC dialog be truly modal. Defaults to true. | |
data-ocp-checked |
ocpChecked |
Whether OCP checkbox is marked by default. Defaults to true. | |
data-preselect |
preselect |
If shop has activated not only card payments, but Apple Pay and Google Pay as well, with this parameter it is possible to pass what should be preselected. Possible options:
|
Payment
with it: