@@ -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,15 +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 {
546
+
547
+ $ this ->_getApi ()->setBillingAddress ($ this ->_quote ->getBillingAddress ());
548
+
548
549
$ address = $ this ->_quote ->getShippingAddress ();
549
550
$ isOverridden = 0 ;
550
551
if (true === $ address ->validate ()) {
551
552
$ isOverridden = 1 ;
552
- $ this ->_api ->setAddress ($ address );
553
+ $ this ->_getApi () ->setAddress ($ address );
553
554
}
554
555
$ this ->_quote ->getPayment ()->setAdditionalInformation (
555
556
self ::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDDEN ,
@@ -561,19 +562,19 @@ public function start($returnUrl, $cancelUrl, $button = null)
561
562
/** @var $cart \Magento\Payment\Model\Cart */
562
563
$ cart = $ this ->_cartFactory ->create (['salesModel ' => $ this ->_quote ]);
563
564
564
- $ this ->_api ->setPaypalCart ($ cart );
565
+ $ this ->_getApi () ->setPaypalCart ($ cart );
565
566
566
567
if (!$ this ->_taxData ->getConfig ()->priceIncludesTax ()) {
567
568
$ this ->setShippingOptions ($ cart , $ address );
568
569
}
569
570
570
- $ this ->_config ->exportExpressCheckoutStyleSettings ($ this ->_api );
571
+ $ this ->_config ->exportExpressCheckoutStyleSettings ($ this ->_getApi () );
571
572
572
573
/* Temporary solution. @TODO: do not pass quote into Nvp model */
573
- $ this ->_api ->setQuote ($ this ->_quote );
574
- $ this ->_api ->callSetExpressCheckout ();
574
+ $ this ->_getApi () ->setQuote ($ this ->_quote );
575
+ $ this ->_getApi () ->callSetExpressCheckout ();
575
576
576
- $ token = $ this ->_api ->getToken ();
577
+ $ token = $ this ->_getApi () ->getToken ();
577
578
578
579
$ this ->_setRedirectUrl ($ button , $ token );
579
580
@@ -613,15 +614,15 @@ public function canSkipOrderReviewStep()
613
614
*/
614
615
public function returnFromPaypal ($ token )
615
616
{
616
- $ this ->_getApi ();
617
- $ this -> _api ->setToken ($ token )
617
+ $ this ->_getApi ()
618
+ ->setToken ($ token )
618
619
->callGetExpressCheckoutDetails ();
619
620
$ quote = $ this ->_quote ;
620
621
621
622
$ this ->ignoreAddressValidation ();
622
623
623
624
// import shipping address
624
- $ exportedShippingAddress = $ this ->_api ->getExportedShippingAddress ();
625
+ $ exportedShippingAddress = $ this ->_getApi () ->getExportedShippingAddress ();
625
626
if (!$ quote ->getIsVirtual ()) {
626
627
$ shippingAddress = $ quote ->getShippingAddress ();
627
628
if ($ shippingAddress ) {
@@ -640,8 +641,8 @@ public function returnFromPaypal($token)
640
641
641
642
// import shipping method
642
643
$ code = '' ;
643
- if ($ this ->_api ->getShippingRateCode ()) {
644
- $ code = $ this ->_matchShippingMethodCode ($ shippingAddress , $ this ->_api ->getShippingRateCode ());
644
+ if ($ this ->_getApi () ->getShippingRateCode ()) {
645
+ $ code = $ this ->_matchShippingMethodCode ($ shippingAddress , $ this ->_getApi () ->getShippingRateCode ());
645
646
if ($ code ) {
646
647
// possible bug of double collecting rates :-/
647
648
$ shippingAddress ->setShippingMethod ($ code )->setCollectShippingRates (true );
@@ -670,17 +671,18 @@ public function returnFromPaypal($token)
670
671
} else {
671
672
$ billingAddress = $ quote ->getBillingAddress ();
672
673
}
673
- $ exportedBillingAddress = $ this ->_api ->getExportedBillingAddress ();
674
+ $ exportedBillingAddress = $ this ->_getApi () ->getExportedBillingAddress ();
674
675
675
676
$ this ->_setExportedAddressData ($ billingAddress , $ exportedBillingAddress );
676
677
$ billingAddress ->setCustomerNote ($ exportedBillingAddress ->getData ('note ' ));
677
678
$ quote ->setBillingAddress ($ billingAddress );
679
+ $ quote ->setCheckoutMethod ($ this ->getCheckoutMethod ());
678
680
679
681
// import payment info
680
682
$ payment = $ quote ->getPayment ();
681
683
$ payment ->setMethod ($ this ->_methodType );
682
- $ this ->_paypalInfo ->importToPayment ($ this ->_api , $ payment );
683
- $ 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 ())
684
686
->setAdditionalInformation (self ::PAYMENT_INFO_TRANSPORT_TOKEN , $ token );
685
687
$ quote ->collectTotals ();
686
688
$ this ->quoteRepository ->save ($ quote );
@@ -724,8 +726,7 @@ public function getShippingOptionsCallbackResponse(array $request)
724
726
725
727
try {
726
728
// obtain addresses
727
- $ this ->_getApi ();
728
- $ address = $ this ->_api ->prepareShippingOptionsCallbackAddress ($ request );
729
+ $ address = $ this ->_getApi ()->prepareShippingOptionsCallbackAddress ($ request );
729
730
$ quoteAddress = $ this ->_quote ->getShippingAddress ();
730
731
731
732
// compare addresses, calculate shipping rates and prepare response
@@ -738,7 +739,7 @@ public function getShippingOptionsCallbackResponse(array $request)
738
739
$ this ->totalsCollector ->collectAddressTotals ($ this ->_quote , $ quoteAddress );
739
740
$ options = $ this ->_prepareShippingOptions ($ quoteAddress , false , true );
740
741
}
741
- $ response = $ this ->_api ->setShippingOptions ($ options )->formatShippingOptionsCallback ();
742
+ $ response = $ this ->_getApi () ->setShippingOptions ($ options )->formatShippingOptionsCallback ();
742
743
743
744
// log request and response
744
745
$ debugData ['response ' ] = $ response ;
@@ -956,7 +957,7 @@ protected function _setBillingAgreementRequest()
956
957
if (!$ this ->_agreementFactory ->create ()->needToCreateForCustomer ($ this ->_customerId )) {
957
958
return $ this ;
958
959
}
959
- $ this ->_api ->setBillingType ($ this ->_api ->getBillingAgreementType ());
960
+ $ this ->_getApi () ->setBillingType ($ this ->_getApi () ->getBillingAgreementType ());
960
961
return $ this ;
961
962
}
962
963
@@ -1129,7 +1130,7 @@ public function getCustomerSession()
1129
1130
private function setShippingOptions (PaypalCart $ cart , Address $ address = null )
1130
1131
{
1131
1132
// for included tax always disable line items (related to paypal amount rounding problem)
1132
- $ this ->_api ->setIsLineItemsEnabled ($ this ->_config ->getValue (PaypalConfig::TRANSFER_CART_LINE_ITEMS ));
1133
+ $ this ->_getApi () ->setIsLineItemsEnabled ($ this ->_config ->getValue (PaypalConfig::TRANSFER_CART_LINE_ITEMS ));
1133
1134
1134
1135
// add shipping options if needed and line items are available
1135
1136
$ cartItems = $ cart ->getAllItems ();
@@ -1140,7 +1141,7 @@ private function setShippingOptions(PaypalCart $cart, Address $address = null)
1140
1141
if (!$ this ->_quote ->getIsVirtual ()) {
1141
1142
$ options = $ this ->_prepareShippingOptions ($ address , true );
1142
1143
if ($ options ) {
1143
- $ this ->_api ->setShippingOptionsCallbackUrl (
1144
+ $ this ->_getApi () ->setShippingOptionsCallbackUrl (
1144
1145
$ this ->_coreUrl ->getUrl (
1145
1146
'*/*/shippingOptionsCallback ' ,
1146
1147
['quote_id ' => $ this ->_quote ->getId ()]
0 commit comments