@@ -11,29 +11,40 @@ class CIMAuthorizeRequest extends AIMAuthorizeRequest
1111{
1212 protected function addPayment (\SimpleXMLElement $ data )
1313 {
14- $ this ->validate ('cardReference ' );
15-
16- /** @var mixed $req */
17- $ req = $ data ->transactionRequest ;
18- /** @var CardReference $cardRef */
19- $ cardRef = $ this ->getCardReference (false );
20- $ req ->profile ->customerProfileId = $ cardRef ->getCustomerProfileId ();
21- $ req ->profile ->paymentProfile ->paymentProfileId = $ cardRef ->getPaymentProfileId ();
22- if ($ shippingProfileId = $ cardRef ->getShippingProfileId ()) {
23- $ req ->profile ->shippingProfileId = $ shippingProfileId ;
24- }
14+ if ($ this ->isCardPresent ()) {
15+ // Prefer the track data if present over the payment profile (better rate)
16+ return parent ::addPayment ($ data );
17+
18+ } else {
19+ $ this ->validate ('cardReference ' );
20+
21+ /** @var mixed $req */
22+ $ req = $ data ->transactionRequest ;
23+ /** @var CardReference $cardRef */
24+ $ cardRef = $ this ->getCardReference (false );
25+ $ req ->profile ->customerProfileId = $ cardRef ->getCustomerProfileId ();
26+ $ req ->profile ->paymentProfile ->paymentProfileId = $ cardRef ->getPaymentProfileId ();
27+ if ($ shippingProfileId = $ cardRef ->getShippingProfileId ()) {
28+ $ req ->profile ->shippingProfileId = $ shippingProfileId ;
29+ }
2530
26- $ desc = $ this ->getDescription ();
27- if (!empty ($ desc )) {
28- $ req ->order ->description = $ desc ;
31+ $ desc = $ this ->getDescription ();
32+ if (!empty ($ desc )) {
33+ $ req ->order ->description = $ desc ;
34+ }
35+
36+ return $ data ;
2937 }
3038
31- return $ data ;
3239 }
3340
3441 protected function addBillingData (\SimpleXMLElement $ data )
3542 {
36- // Do nothing since billing information is already part of the customer profile
37- return $ data ;
43+ if ($ this ->isCardPresent ()) {
44+ return parent ::addBillingData ($ data );
45+ } else {
46+ // Do nothing since billing information is already part of the customer profile
47+ return $ data ;
48+ }
3849 }
3950}
0 commit comments