@@ -387,10 +387,9 @@ public function getCheckoutShortcutImageUrl()
387
387
$ pal = null ;
388
388
} elseif (!$ pal ) {
389
389
$ pal = null ;
390
- $ this ->_getApi ();
391
390
try {
392
- $ this ->_api ->callGetPalDetails ();
393
- $ pal = $ this ->_api ->getPal ();
391
+ $ this ->_getApi () ->callGetPalDetails ();
392
+ $ pal = $ this ->_getApi () ->getPal ();
394
393
$ this ->_configCacheType ->save ($ pal , $ cacheId );
395
394
} catch (\Exception $ e ) {
396
395
$ this ->_configCacheType ->save (self ::PAL_CACHE_ID , $ cacheId );
@@ -503,11 +502,10 @@ public function start($returnUrl, $cancelUrl, $button = null)
503
502
$ this ->_quote ->reserveOrderId ();
504
503
$ this ->quoteRepository ->save ($ this ->_quote );
505
504
// prepare API
506
- $ this ->_getApi ();
507
505
$ solutionType = $ this ->_config ->getMerchantCountry () == 'DE '
508
506
? \Magento \Paypal \Model \Config::EC_SOLUTION_TYPE_MARK
509
507
: $ this ->_config ->getValue ('solutionType ' );
510
- $ this ->_api ->setAmount ($ this ->_quote ->getBaseGrandTotal ())
508
+ $ this ->_getApi () ->setAmount ($ this ->_quote ->getBaseGrandTotal ())
511
509
->setCurrencyCode ($ this ->_quote ->getBaseCurrencyCode ())
512
510
->setInvNum ($ this ->_quote ->getReservedOrderId ())
513
511
->setReturnUrl ($ returnUrl )
@@ -516,7 +514,7 @@ public function start($returnUrl, $cancelUrl, $button = null)
516
514
->setPaymentAction ($ this ->_config ->getValue ('paymentAction ' ));
517
515
if ($ this ->_giropayUrls ) {
518
516
list ($ successUrl , $ cancelUrl , $ pendingUrl ) = $ this ->_giropayUrls ;
519
- $ this ->_api ->addData (
517
+ $ this ->_getApi () ->addData (
520
518
[
521
519
'giropay_cancel_url ' => $ cancelUrl ,
522
520
'giropay_success_url ' => $ successUrl ,
@@ -526,13 +524,13 @@ public function start($returnUrl, $cancelUrl, $button = null)
526
524
}
527
525
528
526
if ($ this ->_isBml ) {
529
- $ this ->_api ->setFundingSource ('BML ' );
527
+ $ this ->_getApi () ->setFundingSource ('BML ' );
530
528
}
531
529
532
530
$ this ->_setBillingAgreementRequest ();
533
531
534
532
if ($ this ->_config ->getValue ('requireBillingAddress ' ) == PaypalConfig::REQUIRE_BILLING_ADDRESS_ALL ) {
535
- $ this ->_api ->setRequireBillingAddress (1 );
533
+ $ this ->_getApi () ->setRequireBillingAddress (1 );
536
534
}
537
535
538
536
// suppress or export shipping address
@@ -541,21 +539,18 @@ public function start($returnUrl, $cancelUrl, $button = null)
541
539
if ($ this ->_config ->getValue ('requireBillingAddress ' )
542
540
== PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL
543
541
) {
544
- $ this ->_api ->setRequireBillingAddress (1 );
542
+ $ this ->_getApi () ->setRequireBillingAddress (1 );
545
543
}
546
- $ this ->_api ->setSuppressShipping (true );
544
+ $ this ->_getApi () ->setSuppressShipping (true );
547
545
} else {
548
546
549
- $ billingAddress = $ this ->_quote ->getBillingAddress ();
550
- if ($ billingAddress ) {
551
- $ this ->_api ->setBillingAddress ($ billingAddress );
552
- }
547
+ $ this ->_getApi ()->setBillingAddress ($ this ->_quote ->getBillingAddress ());
553
548
554
549
$ address = $ this ->_quote ->getShippingAddress ();
555
550
$ isOverridden = 0 ;
556
551
if (true === $ address ->validate ()) {
557
552
$ isOverridden = 1 ;
558
- $ this ->_api ->setAddress ($ address );
553
+ $ this ->_getApi () ->setAddress ($ address );
559
554
}
560
555
$ this ->_quote ->getPayment ()->setAdditionalInformation (
561
556
self ::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDDEN ,
@@ -567,19 +562,19 @@ public function start($returnUrl, $cancelUrl, $button = null)
567
562
/** @var $cart \Magento\Payment\Model\Cart */
568
563
$ cart = $ this ->_cartFactory ->create (['salesModel ' => $ this ->_quote ]);
569
564
570
- $ this ->_api ->setPaypalCart ($ cart );
565
+ $ this ->_getApi () ->setPaypalCart ($ cart );
571
566
572
567
if (!$ this ->_taxData ->getConfig ()->priceIncludesTax ()) {
573
568
$ this ->setShippingOptions ($ cart , $ address );
574
569
}
575
570
576
- $ this ->_config ->exportExpressCheckoutStyleSettings ($ this ->_api );
571
+ $ this ->_config ->exportExpressCheckoutStyleSettings ($ this ->_getApi () );
577
572
578
573
/* Temporary solution. @TODO: do not pass quote into Nvp model */
579
- $ this ->_api ->setQuote ($ this ->_quote );
580
- $ this ->_api ->callSetExpressCheckout ();
574
+ $ this ->_getApi () ->setQuote ($ this ->_quote );
575
+ $ this ->_getApi () ->callSetExpressCheckout ();
581
576
582
- $ token = $ this ->_api ->getToken ();
577
+ $ token = $ this ->_getApi () ->getToken ();
583
578
584
579
$ this ->_setRedirectUrl ($ button , $ token );
585
580
@@ -619,15 +614,15 @@ public function canSkipOrderReviewStep()
619
614
*/
620
615
public function returnFromPaypal ($ token )
621
616
{
622
- $ this ->_getApi ();
623
- $ this -> _api ->setToken ($ token )
617
+ $ this ->_getApi ()
618
+ ->setToken ($ token )
624
619
->callGetExpressCheckoutDetails ();
625
620
$ quote = $ this ->_quote ;
626
621
627
622
$ this ->ignoreAddressValidation ();
628
623
629
624
// import shipping address
630
- $ exportedShippingAddress = $ this ->_api ->getExportedShippingAddress ();
625
+ $ exportedShippingAddress = $ this ->_getApi () ->getExportedShippingAddress ();
631
626
if (!$ quote ->getIsVirtual ()) {
632
627
$ shippingAddress = $ quote ->getShippingAddress ();
633
628
if ($ shippingAddress ) {
@@ -646,8 +641,8 @@ public function returnFromPaypal($token)
646
641
647
642
// import shipping method
648
643
$ code = '' ;
649
- if ($ this ->_api ->getShippingRateCode ()) {
650
- $ code = $ this ->_matchShippingMethodCode ($ shippingAddress , $ this ->_api ->getShippingRateCode ());
644
+ if ($ this ->_getApi () ->getShippingRateCode ()) {
645
+ $ code = $ this ->_matchShippingMethodCode ($ shippingAddress , $ this ->_getApi () ->getShippingRateCode ());
651
646
if ($ code ) {
652
647
// possible bug of double collecting rates :-/
653
648
$ shippingAddress ->setShippingMethod ($ code )->setCollectShippingRates (true );
@@ -676,7 +671,7 @@ public function returnFromPaypal($token)
676
671
} else {
677
672
$ billingAddress = $ quote ->getBillingAddress ();
678
673
}
679
- $ exportedBillingAddress = $ this ->_api ->getExportedBillingAddress ();
674
+ $ exportedBillingAddress = $ this ->_getApi () ->getExportedBillingAddress ();
680
675
681
676
$ this ->_setExportedAddressData ($ billingAddress , $ exportedBillingAddress );
682
677
$ billingAddress ->setCustomerNote ($ exportedBillingAddress ->getData ('note ' ));
@@ -686,8 +681,8 @@ public function returnFromPaypal($token)
686
681
// import payment info
687
682
$ payment = $ quote ->getPayment ();
688
683
$ payment ->setMethod ($ this ->_methodType );
689
- $ this ->_paypalInfo ->importToPayment ($ this ->_api , $ payment );
690
- $ payment ->setAdditionalInformation (self ::PAYMENT_INFO_TRANSPORT_PAYER_ID , $ this ->_api ->getPayerId ())
684
+ $ this ->_paypalInfo ->importToPayment ($ this ->_getApi () , $ payment );
685
+ $ payment ->setAdditionalInformation (self ::PAYMENT_INFO_TRANSPORT_PAYER_ID , $ this ->_getApi () ->getPayerId ())
691
686
->setAdditionalInformation (self ::PAYMENT_INFO_TRANSPORT_TOKEN , $ token );
692
687
$ quote ->collectTotals ();
693
688
$ this ->quoteRepository ->save ($ quote );
@@ -731,8 +726,7 @@ public function getShippingOptionsCallbackResponse(array $request)
731
726
732
727
try {
733
728
// obtain addresses
734
- $ this ->_getApi ();
735
- $ address = $ this ->_api ->prepareShippingOptionsCallbackAddress ($ request );
729
+ $ address = $ this ->_getApi ()->prepareShippingOptionsCallbackAddress ($ request );
736
730
$ quoteAddress = $ this ->_quote ->getShippingAddress ();
737
731
738
732
// compare addresses, calculate shipping rates and prepare response
@@ -745,7 +739,7 @@ public function getShippingOptionsCallbackResponse(array $request)
745
739
$ this ->totalsCollector ->collectAddressTotals ($ this ->_quote , $ quoteAddress );
746
740
$ options = $ this ->_prepareShippingOptions ($ quoteAddress , false , true );
747
741
}
748
- $ response = $ this ->_api ->setShippingOptions ($ options )->formatShippingOptionsCallback ();
742
+ $ response = $ this ->_getApi () ->setShippingOptions ($ options )->formatShippingOptionsCallback ();
749
743
750
744
// log request and response
751
745
$ debugData ['response ' ] = $ response ;
@@ -963,7 +957,7 @@ protected function _setBillingAgreementRequest()
963
957
if (!$ this ->_agreementFactory ->create ()->needToCreateForCustomer ($ this ->_customerId )) {
964
958
return $ this ;
965
959
}
966
- $ this ->_api ->setBillingType ($ this ->_api ->getBillingAgreementType ());
960
+ $ this ->_getApi () ->setBillingType ($ this ->_getApi () ->getBillingAgreementType ());
967
961
return $ this ;
968
962
}
969
963
@@ -1136,7 +1130,7 @@ public function getCustomerSession()
1136
1130
private function setShippingOptions (PaypalCart $ cart , Address $ address = null )
1137
1131
{
1138
1132
// for included tax always disable line items (related to paypal amount rounding problem)
1139
- $ this ->_api ->setIsLineItemsEnabled ($ this ->_config ->getValue (PaypalConfig::TRANSFER_CART_LINE_ITEMS ));
1133
+ $ this ->_getApi () ->setIsLineItemsEnabled ($ this ->_config ->getValue (PaypalConfig::TRANSFER_CART_LINE_ITEMS ));
1140
1134
1141
1135
// add shipping options if needed and line items are available
1142
1136
$ cartItems = $ cart ->getAllItems ();
@@ -1147,7 +1141,7 @@ private function setShippingOptions(PaypalCart $cart, Address $address = null)
1147
1141
if (!$ this ->_quote ->getIsVirtual ()) {
1148
1142
$ options = $ this ->_prepareShippingOptions ($ address , true );
1149
1143
if ($ options ) {
1150
- $ this ->_api ->setShippingOptionsCallbackUrl (
1144
+ $ this ->_getApi () ->setShippingOptionsCallbackUrl (
1151
1145
$ this ->_coreUrl ->getUrl (
1152
1146
'*/*/shippingOptionsCallback ' ,
1153
1147
['quote_id ' => $ this ->_quote ->getId ()]
0 commit comments