Skip to content

Commit

Permalink
Merge branch 'pt-13099/payment-method-preset' into 'master'
Browse files Browse the repository at this point in the history
PT-13099 - Set PayPal as payment method on update express user

See merge request shopware/5/services/swagpaymentpaypalunified!336
  • Loading branch information
mitelg committed Jun 13, 2023
2 parents 6ef3d83 + b18a4b7 commit 5378b93
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Components/Services/ExpressCheckout/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function upsertCustomer(Order $orderStruct)
}

$customerModel->setEmail($payer->getEmailAddress());

$customerModel->setPaymentId($this->paymentMethodProvider->getPaymentId(PaymentMethodProviderInterface::PAYPAL_UNIFIED_PAYMENT_METHOD_NAME));
$addressForm = $this->formFactory->create(AddressFormType::class, $address);
$addressForm->submit($customerData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PHPUnit\Framework\TestCase;
use Shopware\Models\Customer\Address;
use Shopware\Models\Customer\Customer;
use SwagPaymentPayPalUnified\Components\PaymentMethodProviderInterface;
use SwagPaymentPayPalUnified\Components\Services\ExpressCheckout\CustomerService;
use SwagPaymentPayPalUnified\PayPalBundle\V2\Api\Order;
use SwagPaymentPayPalUnified\PayPalBundle\V2\Api\Order\Payer;
Expand Down Expand Up @@ -78,6 +79,8 @@ public function testUpsertCustomer()
static::assertSame(self::POSTAL_CODE, $createdCustomerShippingAddress->getZipcode());
static::assertSame(self::CITY, $createdCustomerShippingAddress->getCity());

$this->updatePaymentMethod((int) $createdCustomer->getId(), -1);

// update customer
$orderStruct = $this->createOrderStruct(true);
$orderStruct->getPayer()->setEmailAddress(self::CHANGED_CUSTOMER_EMAIL_ADDRESS);
Expand All @@ -104,6 +107,9 @@ public function testUpsertCustomer()
static::assertSame(self::STREET, $updatedCustomerShippingAddress->getStreet());
static::assertSame(self::POSTAL_CODE, $updatedCustomerShippingAddress->getZipcode());
static::assertSame(self::CITY, $updatedCustomerShippingAddress->getCity());

$payPalPaymentMethodId = $this->getContainer()->get('paypal_unified.payment_method_provider')->getPaymentId(PaymentMethodProviderInterface::PAYPAL_UNIFIED_PAYMENT_METHOD_NAME);
static::assertSame($payPalPaymentMethodId, $updatedCustomer->getPaymentId());
}

/**
Expand Down Expand Up @@ -302,4 +308,21 @@ private function createShipping()

return $shipping;
}

/**
* @param int $userId
* @param int $paymentMethodId
*
* @return void
*/
private function updatePaymentMethod($userId, $paymentMethodId)
{
$this->getContainer()->get('dbal_connection')->createQueryBuilder()
->update('s_user')
->set('paymentID', ':paymentId')
->where('id = :userId')
->setParameter('paymentId', $paymentMethodId)
->setParameter('userId', $userId)
->execute();
}
}
9 changes: 9 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<author>shopware AG</author>
<compatibility minVersion="5.2.27" maxVersion="5.99.99"/>

<changelog version="REPLACE_GLOBAL_WITH_NEXT_VERSION(6.0.8)">
<changes lang="de">
PT-13099 - Bei wiederkehrendem Express-Checkout ist die PayPal Zahlungsart nun korrekt ausgewählt;
</changes>
<changes lang="en">
PT-13099 - For recurring express checkout, the PayPal payment method is now correctly selected;
</changes>
</changelog>

<changelog version="6.0.7">
<changes lang="de">
PT-13098 - Gutscheinfeld wird im Warenkorb wieder korrekt angezeigt;
Expand Down

0 comments on commit 5378b93

Please sign in to comment.