Skip to content

Commit 3fc64be

Browse files
committed
Merge branch '8.x-1.x' of github.com:drupalcommerce/commerce_paypal into 2843999-ipn-handler
2 parents d2a1306 + b873ab8 commit 3fc64be

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Plugin/Commerce/PaymentGateway/ExpressCheckout.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public function setExpressCheckout(PaymentInterface $payment, array $extra) {
477477
'SOLUTIONTYPE' => 'Mark',
478478
'LANDINGPAGE' => 'Login',
479479

480-
// Disable entering notes in PayPal, as we don't have any way to accommodate
480+
// Disable entering notes in PayPal, we don't have any way to accommodate
481481
// them right now.
482482
'ALLOWNOTE' => '0',
483483

@@ -496,8 +496,8 @@ public function setExpressCheckout(PaymentInterface $payment, array $extra) {
496496
$nvp_data['TOKEN'] = $order_express_checkout_data['token'];
497497
}
498498

499-
// Get the order line items.
500499
$n = 0;
500+
// Add order item data.
501501
foreach ($order->getItems() as $item) {
502502
$item_amount = $this->rounder->round($item->getUnitPrice());
503503
$nvp_data += [
@@ -508,9 +508,20 @@ public function setExpressCheckout(PaymentInterface $payment, array $extra) {
508508
$n++;
509509
}
510510

511-
// If reference transactions are enabled and a billing agreement is supplied...
512-
if (!empty($configuration['reference_transactions']) &&
513-
!empty($configuration['ba_desc'])) {
511+
// Add all adjustments.
512+
foreach ($order->collectAdjustments() as $adjustment) {
513+
$adjustment_amount = $this->rounder->round($adjustment->getAmount());
514+
$nvp_data += [
515+
'L_PAYMENTREQUEST_0_NAME' . $n => $adjustment->getLabel(),
516+
'L_PAYMENTREQUEST_0_AMT' . $n => $adjustment_amount->getNumber(),
517+
'L_PAYMENTREQUEST_0_QTY' . $n => 1,
518+
];
519+
$n++;
520+
}
521+
522+
// Check if there is a reference transaction, and also see if a billing
523+
// agreement was supplied.
524+
if (!empty($configuration['reference_transactions']) && !empty($configuration['ba_desc'])) {
514525
$nvp_data['BILLINGTYPE'] = 'MerchantInitiatedBillingSingleAgreement';
515526
$nvp_data['L_BILLINGTYPE0'] = 'MerchantInitiatedBillingSingleAgreement';
516527
$nvp_data['L_BILLINGAGREEMENTDESCRIPTION0'] = $configuration['ba_desc'];

0 commit comments

Comments
 (0)