| 1 | package Business::Giropay::Request::Transaction; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | =head1 NAME | ||||||||||||||
| 4 | |||||||||||||||
| 5 | Business::Giropay::Request::Transaction - start payment transaction request | ||||||||||||||
| 6 | |||||||||||||||
| 7 | =cut | ||||||||||||||
| 8 | |||||||||||||||
| 9 | 2 | ▶ | use Business::Giropay::Types qw/Int Maybe Str/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 2 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 2 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 2 | with 'Business::Giropay::Role::Request', 'Business::Giropay::Role::Urls'; | |||||||||||||
| 13 | 2 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | =head1 ATTRIBUTES | ||||||||||||||
| 16 | |||||||||||||||
| 17 | See L<Business::Giropay::Role::Request/ATTRIBUTES> for attributes common to | ||||||||||||||
| 18 | all request classes and also L<Business::Giropay::Role::Urls/ATTRIBUTES>. | ||||||||||||||
| 19 | |||||||||||||||
| 20 | =head2 response_class | ||||||||||||||
| 21 | |||||||||||||||
| 22 | The response class to use. Defaults to | ||||||||||||||
| 23 | L<Business::Giropay::Response::Transaction>. | ||||||||||||||
| 24 | |||||||||||||||
| 25 | =cut | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 2 | has response_class => ( | |||||||||||||
| 28 | is => 'ro', | ||||||||||||||
| 29 | isa => Str, | ||||||||||||||
| 30 | default => "Business::Giropay::Response::Transaction", | ||||||||||||||
| 31 | ); | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =head2 merchantTxId | ||||||||||||||
| 34 | |||||||||||||||
| 35 | Unique transaction ID to identify this request. | ||||||||||||||
| 36 | |||||||||||||||
| 37 | =cut | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 2 | has merchantTxId => ( | |||||||||||||
| 40 | is => 'ro', | ||||||||||||||
| 41 | isa => Str, # Varchar [255] | ||||||||||||||
| 42 | required => 1, | ||||||||||||||
| 43 | ); | ||||||||||||||
| 44 | |||||||||||||||
| 45 | =head2 amount | ||||||||||||||
| 46 | |||||||||||||||
| 47 | Amount of transaction in cents/pennies/etc so EUR 23.54 will be 2354. | ||||||||||||||
| 48 | |||||||||||||||
| 49 | =cut | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 2 | has amount => ( | |||||||||||||
| 52 | is => 'ro', | ||||||||||||||
| 53 | isa => Int, | ||||||||||||||
| 54 | required => 1, | ||||||||||||||
| 55 | ); | ||||||||||||||
| 56 | |||||||||||||||
| 57 | =head2 currency | ||||||||||||||
| 58 | |||||||||||||||
| 59 | Three letter currency code, e.g.: EUR for Euros | ||||||||||||||
| 60 | |||||||||||||||
| 61 | =cut | ||||||||||||||
| 62 | |||||||||||||||
| 63 | has currency => ( | ||||||||||||||
| 64 | is => 'ro', | ||||||||||||||
| 65 | isa => Str, # Char [3] | ||||||||||||||
| 66 | required => 1, | ||||||||||||||
| 67 | 6 | ▶ | coerce => sub { uc( $_[0] ) }, | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 68 | 2 | ); | |||||||||||||
| 69 | |||||||||||||||
| 70 | =head2 purpose | ||||||||||||||
| 71 | |||||||||||||||
| 72 | Short purpose for transaction, e.g.: product purchase | ||||||||||||||
| 73 | |||||||||||||||
| 74 | =cut | ||||||||||||||
| 75 | |||||||||||||||
| 76 | 2 | has purpose => ( | |||||||||||||
| 77 | is => 'ro', | ||||||||||||||
| 78 | isa => Str, # Varchar [27] | ||||||||||||||
| 79 | required => 1, | ||||||||||||||
| 80 | ); | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =head2 bic | ||||||||||||||
| 83 | |||||||||||||||
| 84 | Bank BIC code. Required for eps and giropay. | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =cut | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 2 | has bic => ( | |||||||||||||
| 89 | is => 'rwp', | ||||||||||||||
| 90 | isa => Str, # Varchar [11] | ||||||||||||||
| 91 | default => '', | ||||||||||||||
| 92 | ); | ||||||||||||||
| 93 | |||||||||||||||
| 94 | =head2 iban | ||||||||||||||
| 95 | |||||||||||||||
| 96 | Bank account IBAN. Optional for giropay only. | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =cut | ||||||||||||||
| 99 | |||||||||||||||
| 100 | 2 | has iban => ( | |||||||||||||
| 101 | is => 'ro', | ||||||||||||||
| 102 | isa => Str, # Varchar [34] | ||||||||||||||
| 103 | default => '', | ||||||||||||||
| 104 | ); | ||||||||||||||
| 105 | |||||||||||||||
| 106 | =head2 issuer | ||||||||||||||
| 107 | |||||||||||||||
| 108 | iDEAL issuer bank. Required for ideal only. | ||||||||||||||
| 109 | |||||||||||||||
| 110 | =cut | ||||||||||||||
| 111 | |||||||||||||||
| 112 | 2 | has issuer => ( | |||||||||||||
| 113 | is => 'rwp', | ||||||||||||||
| 114 | isa => Str, | ||||||||||||||
| 115 | default => '', | ||||||||||||||
| 116 | ); | ||||||||||||||
| 117 | |||||||||||||||
| 118 | =head2 info1Label | ||||||||||||||
| 119 | |||||||||||||||
| 120 | Optional for giropay only. | ||||||||||||||
| 121 | |||||||||||||||
| 122 | =head2 info1Text | ||||||||||||||
| 123 | |||||||||||||||
| 124 | Text for L</info1Label>. | ||||||||||||||
| 125 | |||||||||||||||
| 126 | =head2 info2Label | ||||||||||||||
| 127 | |||||||||||||||
| 128 | Optional for giropay only. | ||||||||||||||
| 129 | |||||||||||||||
| 130 | =head2 info2Text | ||||||||||||||
| 131 | |||||||||||||||
| 132 | Text for L</info2Label>. | ||||||||||||||
| 133 | |||||||||||||||
| 134 | =head2 info3Label | ||||||||||||||
| 135 | |||||||||||||||
| 136 | Optional for giropay only. | ||||||||||||||
| 137 | |||||||||||||||
| 138 | =head2 info3Text | ||||||||||||||
| 139 | |||||||||||||||
| 140 | Text for L</info3Label>. | ||||||||||||||
| 141 | |||||||||||||||
| 142 | =head2 info4Label | ||||||||||||||
| 143 | |||||||||||||||
| 144 | Optional for giropay only. | ||||||||||||||
| 145 | |||||||||||||||
| 146 | =head2 info4Text | ||||||||||||||
| 147 | |||||||||||||||
| 148 | Text for L</info4Label>. | ||||||||||||||
| 149 | |||||||||||||||
| 150 | =head2 info5Label | ||||||||||||||
| 151 | |||||||||||||||
| 152 | Optional for giropay only. | ||||||||||||||
| 153 | |||||||||||||||
| 154 | =head2 info5Text | ||||||||||||||
| 155 | |||||||||||||||
| 156 | Text for L</info5Label>. | ||||||||||||||
| 157 | |||||||||||||||
| 158 | =cut | ||||||||||||||
| 159 | |||||||||||||||
| 160 | 2 | has [qw(info1Label info2Label info3Label info4Label info5Label)] => ( | |||||||||||||
| 161 | is => 'ro', | ||||||||||||||
| 162 | isa => Str, # Varchar [30] | ||||||||||||||
| 163 | default => '', | ||||||||||||||
| 164 | ); | ||||||||||||||
| 165 | |||||||||||||||
| 166 | 2 | has [qw(info1Text info2Text info3Text info4Text info5Text)] => ( | |||||||||||||
| 167 | is => 'ro', | ||||||||||||||
| 168 | isa => Str, # Varchar [80] | ||||||||||||||
| 169 | default => '', | ||||||||||||||
| 170 | ); | ||||||||||||||
| 171 | |||||||||||||||
| 172 | =head2 urlRedirect | ||||||||||||||
| 173 | |||||||||||||||
| 174 | Override to make it required. | ||||||||||||||
| 175 | |||||||||||||||
| 176 | =cut | ||||||||||||||
| 177 | |||||||||||||||
| 178 | 2 | has '+urlRedirect' => ( | |||||||||||||
| 179 | required => 1, | ||||||||||||||
| 180 | ); | ||||||||||||||
| 181 | |||||||||||||||
| 182 | =head2 urlNotify | ||||||||||||||
| 183 | |||||||||||||||
| 184 | Shop URL to which the outgoing payment is reported. | ||||||||||||||
| 185 | |||||||||||||||
| 186 | =cut | ||||||||||||||
| 187 | |||||||||||||||
| 188 | 2 | has '+urlNotify' => ( | |||||||||||||
| 189 | required => 1, | ||||||||||||||
| 190 | ); | ||||||||||||||
| 191 | |||||||||||||||
| 192 | =head1 METHODS | ||||||||||||||
| 193 | |||||||||||||||
| 194 | See L<Business::Giropay::Role::Request/METHODS> in addition to the following: | ||||||||||||||
| 195 | |||||||||||||||
| 196 | =head2 BUILD | ||||||||||||||
| 197 | |||||||||||||||
| 198 | Different networks require different attributes to be set. Check for them here. | ||||||||||||||
| 199 | |||||||||||||||
| 200 | =cut | ||||||||||||||
| 201 | |||||||||||||||
| 202 | 6 | ▶ | sub BUILD { | ||||||||||||
|
Subroutine
BUILD: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||
| 203 | 6 | my $self = shift; | |||||||||||||
| 204 | 6 | ▶ | if ( $self->network =~ /^(eps|giropay)$/ ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 205 | 4 | ▶ | croak "Missing required argument: bic" unless $self->bic; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 206 | } | ||||||||||||||
| 207 | elsif ( $self->network eq 'ideal' ) { | ||||||||||||||
| 208 | 2 | ▶ | croak "Missing required argument: issuer" unless $self->issuer; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 209 | } | ||||||||||||||
| 210 | } | ||||||||||||||
| 211 | |||||||||||||||
| 212 | =head2 parameters | ||||||||||||||
| 213 | |||||||||||||||
| 214 | Returns additional parameters for the request. | ||||||||||||||
| 215 | |||||||||||||||
| 216 | =cut | ||||||||||||||
| 217 | |||||||||||||||
| 218 | 3 | ▶ | sub parameters { | ||||||||||||
|
Subroutine
parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 219 | return [ | ||||||||||||||
| 220 | 3 | qw/merchantTxId amount currency purpose bic iban issuer | |||||||||||||
| 221 | info1Label info1Text info2Label info2Text info3Label | ||||||||||||||
| 222 | info3Text info4Label info4Text info5Label info5Text | ||||||||||||||
| 223 | urlRedirect urlNotify/ | ||||||||||||||
| 224 | ]; | ||||||||||||||
| 225 | } | ||||||||||||||
| 226 | |||||||||||||||
| 227 | =head2 sandbox_data \%data | ||||||||||||||
| 228 | |||||||||||||||
| 229 | Clean up data to be submitted in request to contain only safe data for testing. | ||||||||||||||
| 230 | |||||||||||||||
| 231 | It is not normally necessary to call this method since it happens automatically | ||||||||||||||
| 232 | if L<Business::Giropay::Role::Core/sandbox> is true. | ||||||||||||||
| 233 | |||||||||||||||
| 234 | =cut | ||||||||||||||
| 235 | |||||||||||||||
| 236 | 0 | ▶ | sub sandbox_data { | ||||||||||||
|
Subroutine
sandbox_data: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 237 | 0 | my $self = shift; | |||||||||||||
| 238 | 0 | ▶ | if ( $self->network eq 'ideal' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 239 | 0 | $self->_set_issuer('RABOBANK'); | |||||||||||||
| 240 | } | ||||||||||||||
| 241 | else { | ||||||||||||||
| 242 | 0 | $self->_set_bic('TESTDETT421'); | |||||||||||||
| 243 | } | ||||||||||||||
| 244 | } | ||||||||||||||
| 245 | |||||||||||||||
| 246 | =head2 uri | ||||||||||||||
| 247 | |||||||||||||||
| 248 | Returns the URI to be appended to L<Business::Giropay::Role::Request/base_uri> | ||||||||||||||
| 249 | to construct the appropriate URL for the request. | ||||||||||||||
| 250 | |||||||||||||||
| 251 | =cut | ||||||||||||||
| 252 | |||||||||||||||
| 253 | 3 | ▶ | sub uri { | ||||||||||||
|
Subroutine
uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 254 | 3 | return 'transaction/start'; | |||||||||||||
| 255 | } | ||||||||||||||
| 256 | |||||||||||||||
| 257 | 2 | 1; | |||||||||||||