| 1 | package Net::Simplify::CardToken; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Net::Simplify::CardToken - A Simplify Commerce CardToken object | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use Net::Simplify; | ||
| 10 | |||
| 11 | |||
| 12 | $Net::Simplify::public_key = 'YOUR PUBLIC KEY'; | ||
| 13 | $Net::Simplify::private_key = 'YOUR PRIVATE KEY'; | ||
| 14 | |||
| 15 | # Create a new CardToken. | ||
| 16 | my $card_token = Net::Simplify::CardToken->create{ {...}); | ||
| 17 | |||
| 18 | # Retrieve a CardToken given its ID. | ||
| 19 | my $card_token = Net::Simplify::CardToken->find('a7e41'); | ||
| 20 | |||
| 21 | # Update existing CardToken. | ||
| 22 | my $card_token = Net::Simplify::CardToken->find('a7e41'); | ||
| 23 | $card_token->{PROPERTY} = "NEW VALUE"; | ||
| 24 | $card_token->update(); | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | =head2 METHODS | ||
| 29 | |||
| 30 | =head3 create(%params, $auth) | ||
| 31 | |||
| 32 | Creates a C<Net::Simplify::CardToken> object. The parameters are: | ||
| 33 | |||
| 34 | =over 4 | ||
| 35 | |||
| 36 | =item C<%params> | ||
| 37 | |||
| 38 | Hash map containing initial values for the object. Valid keys are: | ||
| 39 | |||
| 40 | =over 4 | ||
| 41 | |||
| 42 | =item authenticatePayer | ||
| 43 | |||
| 44 | Set as true to create CardToken for EMV 3DS transaction. [default: false] | ||
| 45 | |||
| 46 | =item callback | ||
| 47 | |||
| 48 | The URL callback for the cardtoken | ||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | =item card.addressCity | ||
| 53 | |||
| 54 | City of the cardholder. [max length: 50, min length: 2] | ||
| 55 | |||
| 56 | =item card.addressCountry | ||
| 57 | |||
| 58 | Country code (ISO-3166-1-alpha-2 code) of residence of the cardholder. [max length: 2, min length: 2] | ||
| 59 | |||
| 60 | =item card.addressLine1 | ||
| 61 | |||
| 62 | Address of the cardholder. [max length: 255] | ||
| 63 | |||
| 64 | =item card.addressLine2 | ||
| 65 | |||
| 66 | Address of the cardholder if needed. [max length: 255] | ||
| 67 | |||
| 68 | =item card.addressState | ||
| 69 | |||
| 70 | State of residence of the cardholder. State abbreviations should be used. [max length: 255] | ||
| 71 | |||
| 72 | =item card.addressZip | ||
| 73 | |||
| 74 | Postal code of the cardholder. The postal code size is between 5 and 9 in length and only contain numbers or letters. [max length: 32] | ||
| 75 | |||
| 76 | =item card.cvc | ||
| 77 | |||
| 78 | CVC security code of the card. This is the code on the back of the card. Example: 123 | ||
| 79 | |||
| 80 | =item card.expMonth | ||
| 81 | |||
| 82 | Expiration month of the card. Format is MM. Example: January = 01 [min value: 1, max value: 12] | ||
| 83 | |||
| 84 | =item card.expYear | ||
| 85 | |||
| 86 | Expiration year of the card. Format is YY. Example: 2013 = 13 [min value: 0, max value: 99] | ||
| 87 | |||
| 88 | =item card.name | ||
| 89 | |||
| 90 | Name as appears on the card. [max length: 50, min length: 2] | ||
| 91 | |||
| 92 | =item card.number | ||
| 93 | |||
| 94 | Card number as it appears on the card. [max length: 19, min length: 13] | ||
| 95 | |||
| 96 | =item key | ||
| 97 | |||
| 98 | Key used to create the card token. | ||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | =item secure3DRequestData.amount | ||
| 103 | |||
| 104 | Amount of the subsequent transaction in the smallest unit of your currency. Example: 100 = $1.00 (B<required>) | ||
| 105 | |||
| 106 | =item secure3DRequestData.authOnly | ||
| 107 | |||
| 108 | Specifies if the subsequent transaction is going to be a Payment or an Authorization (to be Captured later). If false or not specified, it refers to a Payment, otherwise it refers to an Authorization. | ||
| 109 | |||
| 110 | =item secure3DRequestData.currency | ||
| 111 | |||
| 112 | Currency code (ISO-4217). Must match the currency associated with your account. (B<required>) | ||
| 113 | |||
| 114 | =item secure3DRequestData.description | ||
| 115 | |||
| 116 | A description of the transaction. [max length: 256] | ||
| 117 | |||
| 118 | =item secure3DRequestData.id | ||
| 119 | |||
| 120 | 3D Secure data ID. | ||
| 121 | |||
| 122 | =item source | ||
| 123 | |||
| 124 | Card Token Source [default: API] | ||
| 125 | |||
| 126 | |||
| 127 | =back | ||
| 128 | |||
| 129 | =item C<$auth> | ||
| 130 | |||
| 131 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 132 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 133 | |||
| 134 | =back | ||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | =head3 find($id, $auth) | ||
| 139 | |||
| 140 | Retrieve a C<Net::Simplify::CardToken> object from the API. Parameters are: | ||
| 141 | |||
| 142 | =over 4 | ||
| 143 | |||
| 144 | =item C<$id> | ||
| 145 | |||
| 146 | Identifier of the object to retrieve. | ||
| 147 | |||
| 148 | =item C<$auth> | ||
| 149 | |||
| 150 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 151 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 152 | |||
| 153 | =back | ||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | =head3 update() | ||
| 159 | |||
| 160 | Update C<Net::Simplify::CardToken> object. | ||
| 161 | The properties that can be updated are: | ||
| 162 | |||
| 163 | =over 4 | ||
| 164 | |||
| 165 | |||
| 166 | =item C<device.browser> | ||
| 167 | |||
| 168 | The User-Agent header of the browser the customer used to place the order (B<required>) | ||
| 169 | |||
| 170 | =item C<device.ipAddress> | ||
| 171 | |||
| 172 | The IP address of the device used by the payer, in nnn.nnn.nnn.nnn format. (B<required>) | ||
| 173 | |||
| 174 | =item C<device.language> | ||
| 175 | |||
| 176 | The language supported for the payer's browser as defined in IETF BCP47. | ||
| 177 | |||
| 178 | =item C<device.screenHeight> | ||
| 179 | |||
| 180 | The total height of the payer's browser screen in pixels. | ||
| 181 | |||
| 182 | =item C<device.screenWidth> | ||
| 183 | |||
| 184 | The total width of the payer's browser screen in pixels. | ||
| 185 | |||
| 186 | =item C<device.timeZone> | ||
| 187 | |||
| 188 | The timezone of the device used by the payer, in Zone ID format. Example: "Europe/Dublin" (B<required>) | ||
| 189 | |||
| 190 | |||
| 191 | =item C<key> | ||
| 192 | |||
| 193 | The public key of the merchant to be used for the token | ||
| 194 | |||
| 195 | Authentication is done using the same credentials used when the AccessToken was created. | ||
| 196 | |||
| 197 | =back | ||
| 198 | |||
| 199 | |||
| 200 | |||
| 201 | |||
| 202 | =head1 SEE ALSO | ||
| 203 | |||
| 204 | L<Net::Simplify>, | ||
| 205 | L<Net::Simplify::Domain>, | ||
| 206 | L<Net::Simplify::DomainList>, | ||
| 207 | L<Net::Simplify::Authentication>, | ||
| 208 | L<Net::Simplify::ApiException>, | ||
| 209 | L<http://www.simplify.com> | ||
| 210 | |||
| 211 | =head1 VERSION | ||
| 212 | |||
| 213 | 1.6.0 | ||
| 214 | |||
| 215 | =head1 LICENSE | ||
| 216 | |||
| 217 | Copyright (c) 2013 - 2022 MasterCard International Incorporated | ||
| 218 | All rights reserved. | ||
| 219 | |||
| 220 | Redistribution and use in source and binary forms, with or without modification, are | ||
| 221 | permitted provided that the following conditions are met: | ||
| 222 | |||
| 223 | Redistributions of source code must retain the above copyright notice, this list of | ||
| 224 | conditions and the following disclaimer. | ||
| 225 | Redistributions in binary form must reproduce the above copyright notice, this list of | ||
| 226 | conditions and the following disclaimer in the documentation and/or other materials | ||
| 227 | provided with the distribution. | ||
| 228 | Neither the name of the MasterCard International Incorporated nor the names of its | ||
| 229 | contributors may be used to endorse or promote products derived from this software | ||
| 230 | without specific prior written permission. | ||
| 231 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
| 232 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 233 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
| 234 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 235 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
| 236 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
| 237 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
| 238 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 239 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 240 | SUCH DAMAGE. | ||
| 241 | |||
| 242 | =head1 SEE ALSO | ||
| 243 | |||
| 244 | =cut | ||
| 245 | |||
| 246 | use 5.006; | ||
| 247 | use strict; | ||
| 248 | use warnings FATAL => 'all'; | ||
| 249 | |||
| 250 | use Net::Simplify::Domain; | ||
| 251 | use Net::Simplify::DomainList; | ||
| 252 | |||
| 253 | our @ISA = qw(Net::Simplify::Domain); | ||
| 254 | |||
| 255 | sub create { | ||
| 256 | |||
| 257 | my ($class, $params, $auth) = @_; | ||
| 258 | |||
| 259 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 260 | my $result = Net::Simplify::SimplifyApi->send_api_request("cardToken", 'create', $params, $auth); | ||
| 261 | |||
| 262 | $class->SUPER::new($result, $auth); | ||
| 263 | } | ||
| 264 | |||
| 265 | sub find { | ||
| 266 | my ($class, $id, $auth) = @_; | ||
| 267 | |||
| 268 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 269 | my $result = Net::Simplify::SimplifyApi->send_api_request("cardToken", 'find', { id => $id }, $auth); | ||
| 270 | |||
| 271 | $class->SUPER::new($result, $auth); | ||
| 272 | } | ||
| 273 | |||
| 274 | sub update { | ||
| 275 | |||
| 276 | my ($self) = @_; | ||
| 277 | |||
| 278 | my $auth = Net::Simplify::SimplifyApi->get_authentication($self->{_authentication}); | ||
| 279 | my $params = { %$self }; | ||
| 280 | delete $params->{_authentication}; | ||
| 281 | |||
| 282 | $self->merge(Net::Simplify::SimplifyApi->send_api_request("cardToken", 'update', $params, $auth)); | ||
| 283 | } | ||
| 284 | |||
| 285 | |||
| 286 | 1; |