|
| 1 | +import PropTypes from 'prop-types'; |
| 2 | + |
| 3 | +interface LightboxProps { |
| 4 | + production: boolean; |
| 5 | + transactionId: string; |
| 6 | + onLoaded?: () => void; |
| 7 | + onOpened?: () => void; |
| 8 | + onCancelled?: () => void; |
| 9 | + onError?: (error: { |
| 10 | + message: string; |
| 11 | + detail: string; |
| 12 | + }) => void; |
| 13 | +} |
| 14 | +declare const Lightbox: { |
| 15 | + (props: LightboxProps): null; |
| 16 | + propTypes: { |
| 17 | + transactionId: PropTypes.Validator<string>; |
| 18 | + production: PropTypes.Requireable<boolean>; |
| 19 | + onLoaded: PropTypes.Requireable<(...args: any[]) => any>; |
| 20 | + onOpened: PropTypes.Requireable<(...args: any[]) => any>; |
| 21 | + onCancelled: PropTypes.Requireable<(...args: any[]) => any>; |
| 22 | + onError: PropTypes.Requireable<(...args: any[]) => any>; |
| 23 | + }; |
| 24 | + defaultProps: { |
| 25 | + onLoaded(): void; |
| 26 | + onOpened(): void; |
| 27 | + onCancelled(): void; |
| 28 | + onError(): void; |
| 29 | + production: boolean; |
| 30 | + }; |
| 31 | +}; |
| 32 | + |
| 33 | +/** |
| 34 | + * The config to open a Datatrans Lightbox. |
| 35 | + * |
| 36 | + * @see https://docs.datatrans.ch/docs/redirect-lightbox |
| 37 | + * @see https://api-reference.datatrans.ch/ |
| 38 | + */ |
| 39 | +interface DatatransLightboxConfig { |
| 40 | + closed?: () => void; |
| 41 | + error?: (error: { |
| 42 | + message: string; |
| 43 | + detail: string; |
| 44 | + }) => void; |
| 45 | + form?: unknown; |
| 46 | + loaded?: () => void; |
| 47 | + opened?: () => void; |
| 48 | + params?: IDatatransConfigParams; |
| 49 | +} |
| 50 | +/** |
| 51 | + * The parameters that can be passed to the Datatrans API. |
| 52 | + * |
| 53 | + * @see https://docs.datatrans.ch/docs/redirect-lightbox |
| 54 | + * @see https://api-reference.datatrans.ch/ |
| 55 | + */ |
| 56 | +interface IDatatransConfigParams { |
| 57 | + /** |
| 58 | + * The aliasCC received with a Payment or Registration. |
| 59 | + * @see https://docs.datatrans.ch/v1.0.1/docs/payment-process-alias |
| 60 | + * e.g.: "70119122433810042" |
| 61 | + */ |
| 62 | + aliasCC?: string; |
| 63 | + /** |
| 64 | + * The amount of the transaction in the currency’s smallest unit. |
| 65 | + * For example use "1000" for CHF 10.00. |
| 66 | + */ |
| 67 | + amount?: string; |
| 68 | + /** |
| 69 | + * This parameter represents the URL of the merchant’s web shop, application, |
| 70 | + * where the consumer should be redirected to after cancelling the transaction. |
| 71 | + */ |
| 72 | + cancelUrl: string; |
| 73 | + /** |
| 74 | + * 3 letter ISO-4217 character code. |
| 75 | + * For example "CHF", "USD" |
| 76 | + */ |
| 77 | + currency?: string; |
| 78 | + /** |
| 79 | + * This parameter represents the URL of the merchant’s web shop, application, where the consumer should be redirected to after a failed transaction |
| 80 | + */ |
| 81 | + errorUrl: string; |
| 82 | + /** Expiry month of the card. For example "1" or "01" for January. */ |
| 83 | + expm?: string; |
| 84 | + /** |
| 85 | + * Expiry year of the card |
| 86 | + * e.g.: "25" |
| 87 | + */ |
| 88 | + expy?: string; |
| 89 | + /** |
| 90 | + * This parameter specifies the language (language code) in which the payment page should be presented to the cardholder. |
| 91 | + * The following ISO-639-1 two letter language codes are supported: |
| 92 | + * |
| 93 | + * - de (German) |
| 94 | + * - en (English) |
| 95 | + * - fr (French) |
| 96 | + * - it (Italian) |
| 97 | + * - es (Spanish) |
| 98 | + * - el (Greek) |
| 99 | + * - no (Norwegian) |
| 100 | + * - da (Danish) |
| 101 | + * - pl (Polish) |
| 102 | + * - pt (Portuguese) |
| 103 | + */ |
| 104 | + language?: 'de' | 'en' | 'fr' | 'it' | 'es' | 'el' | 'no' | 'da' | 'pl' | 'pt'; |
| 105 | + /** |
| 106 | + * Unique Merchant Identifier (assigned by Datatrans during signup). |
| 107 | + * Depending on your integration you might receive multiple merchantIds. |
| 108 | + * For example: One for your mobile application and one for your web shop |
| 109 | + */ |
| 110 | + merchantId?: string; |
| 111 | + /** e.g.: "VIS" */ |
| 112 | + paymentmethod?: string; |
| 113 | + /** e.g.: "77666134" */ |
| 114 | + refno?: string; |
| 115 | + /** |
| 116 | + * The reqtype (request type) parameter is used to specify which type of action should be performed on Datatrans side. |
| 117 | + * The different API endpoints support different reqtypes. For Authorizations (Server to Server or by using the Payment page) the following reqtypes are possible: |
| 118 | + * |
| 119 | + * - NOA |
| 120 | + * Only authorization should be done. The amount will be blocked and a separate settlement needs to follow in order to actually charge the customer. |
| 121 | + * Not all payment methods support splitting authorization and settlement. Refer to the documentation of the corresponding payment method if Deferred Settlement is possible. |
| 122 | + * - CAA |
| 123 | + * Direct debit. Authorization with immediate settlement. |
| 124 | + * - SCN |
| 125 | + * Only a pre-screening request should be done. Not all payment methods support pre-screening requests. |
| 126 | + * Refer to the reqtype request parameter documentation for the particular payment method to see if pre-screening requests are supported. |
| 127 | + */ |
| 128 | + reqtype?: 'NOA' | 'CAA' | 'SCN'; |
| 129 | + /** |
| 130 | + * The sign parameter to be submitted with each request. |
| 131 | + * @see https://api-reference.datatrans.ch/xml/#request-signing |
| 132 | + * |
| 133 | + * e.g.: "1902B412B9DDBFF2623ADB4F101F2141" */ |
| 134 | + sign?: string; |
| 135 | + /** |
| 136 | + * This parameter represents the URL of the merchant’s web shop, |
| 137 | + * where the consumer should be redirected to after a successful transaction. |
| 138 | + * |
| 139 | + * e.g.: "https://www.example.com/datatrans/paymentresult/77966133" |
| 140 | + */ |
| 141 | + successUrl: string; |
| 142 | + themeConfiguration?: IDatatransConfigThemeConfiguration; |
| 143 | +} |
| 144 | +/** |
| 145 | + * https://docs.datatrans.ch/docs/redirect-lightbox#styling-the-payment-pages |
| 146 | + */ |
| 147 | +interface IDatatransConfigThemeConfiguration { |
| 148 | + /** e.g. "true" */ |
| 149 | + brandButton?: boolean | string; |
| 150 | + /** e.g. "#444" */ |
| 151 | + brandColor?: string; |
| 152 | + /** |
| 153 | + * Wheter the payment page shows the payment method selection as list (default) or as a grid. |
| 154 | + */ |
| 155 | + initialView?: 'list' | 'grid'; |
| 156 | + /** |
| 157 | + * Decides whether the logo shall be styled with a border around it, |
| 158 | + * if the value is true the default background color is chosen, |
| 159 | + * else the provided string is used as color value. |
| 160 | + */ |
| 161 | + logoBorderColor?: boolean | string; |
| 162 | + /** |
| 163 | + * An SVG image provided by the merchant. |
| 164 | + * The image needs to be uploaded by using the Datatrans Web Administration Tool. |
| 165 | + */ |
| 166 | + logoSrc?: string; |
| 167 | + /** |
| 168 | + * The header logo's display style. |
| 169 | + */ |
| 170 | + logoType?: 'circle' | 'rectangle' | 'none'; |
| 171 | + /** |
| 172 | + * Hides the title from header |
| 173 | + * (Only required if no logo is used) |
| 174 | + */ |
| 175 | + brandTitle?: 'false'; |
| 176 | + /** |
| 177 | + * Color for the title [white|black] |
| 178 | + * (Only required if no logo is used) |
| 179 | + */ |
| 180 | + textColor: 'black' | 'white'; |
| 181 | +} |
| 182 | + |
| 183 | +export { type DatatransLightboxConfig, Lightbox as default }; |
0 commit comments