-
Notifications
You must be signed in to change notification settings - Fork 222
[ECP-9387] Implement Adyen Giving Campaign manager V2 #2950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
00cb3bc
[ECP-9387]Implementing Adyen Giving Manager V2
khushboo-singhvi add23af
[ECP-9387]Completing unit tests
khushboo-singhvi 9ff1deb
Update webapi.xml
khushboo-singhvi 9b34b5d
Merge branch 'develop-10' into ECP-9387
khushboo-singhvi ec72dce
[ECP-9387]Updating MakeFile
khushboo-singhvi 5a5ce72
Merge remote-tracking branch 'origin/ECP-9387' into ECP-9387
khushboo-singhvi 5a8fa67
[ECP-9387]Updating Logic and check for DonationToken for fetching cam…
khushboo-singhvi 61fa14e
[ECP-9387]Updating Logic and check for DonationToken for fetching cam…
khushboo-singhvi ad61095
[ECP-9387]Updating Logic and check for DonationToken for fetching cam…
khushboo-singhvi 0f85690
[ECP-9387]Removing debuggers
khushboo-singhvi 040b757
Merge branch 'develop-10' into ECP-9387
khushboo-singhvi d14892d
[ECP-9387]Improving code by adding Secure renderers and other suggest…
khushboo-singhvi 14deafa
Merge remote-tracking branch 'origin/ECP-9387' into ECP-9387
khushboo-singhvi d5e9a27
[ECP-9387]Improving code by adding Secure renderers and other suggest…
khushboo-singhvi b806531
Fixing the DonationId
khushboo-singhvi 31e76fb
removing return type
khushboo-singhvi 6f57f2f
fixing return type
khushboo-singhvi 8449719
Adding RoundUp Donations
khushboo-singhvi aed45e4
Updating exceptions
khushboo-singhvi 03852d4
Merge branch 'develop-10' into ECP-9387
khushboo-singhvi 51a27ff
Merge branch 'develop-10' into ECP-9387
khushboo-singhvi 0297b45
Merge branch 'develop-10' into ECP-9387
khushboo-singhvi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Adyen\Payment\Api; | ||
|
|
||
| use Magento\Framework\Exception\LocalizedException; | ||
|
|
||
| interface AdyenDonationCampaignsInterface | ||
| { | ||
| /** | ||
| * Retrieve donation campaigns for the current customer's cart | ||
| * | ||
| * @param int $orderId | ||
| * @return string | ||
| * @throws LocalizedException | ||
| */ | ||
| public function getCampaigns(int $orderId): string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| namespace Adyen\Payment\Api; | ||
|
|
||
| use Magento\Framework\Exception\LocalizedException; | ||
|
|
||
| interface GuestAdyenDonationCampaignsInterface | ||
| { | ||
| /** | ||
| * Get donation campaigns for a guest cart | ||
| * | ||
| * @param string $cartId Masked cart ID | ||
| * @return string | ||
| * @throws LocalizedException | ||
| */ | ||
| public function getCampaigns(string $cartId): string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <?php | ||
|
|
||
| namespace Adyen\Payment\Helper; | ||
|
|
||
| use Adyen\Model\Checkout\DonationCampaignsRequest; | ||
| use Adyen\Payment\Logger\AdyenLogger; | ||
| use Magento\Framework\App\Helper\AbstractHelper; | ||
| use Magento\Framework\App\Helper\Context; | ||
| use Adyen\Payment\Helper\Data; | ||
| use Magento\Framework\Exception\LocalizedException; | ||
| use Magento\Framework\Exception\NoSuchEntityException; | ||
| use Magento\Sales\Model\Order; | ||
|
|
||
| class DonationsHelper extends AbstractHelper | ||
| { | ||
| private Data $adyenHelper; | ||
|
|
||
| /** | ||
| * @var AdyenLogger | ||
| */ | ||
| protected $adyenLogger; | ||
|
|
||
| public function __construct( | ||
| Context $context, | ||
| Data $adyenHelper, | ||
| AdyenLogger $adyenLogger | ||
| ) { | ||
| parent::__construct($context); | ||
| $this->adyenHelper = $adyenHelper; | ||
| $this->adyenLogger = $adyenLogger; | ||
| } | ||
|
|
||
| /** | ||
| * @throws NoSuchEntityException | ||
| * @throws LocalizedException | ||
| */ | ||
| public function fetchDonationCampaigns(array $payloadData, int $storeId): array | ||
khushboo-singhvi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| $request = new DonationCampaignsRequest($payloadData); | ||
|
|
||
| try { | ||
khushboo-singhvi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $client = $this->adyenHelper->initializeAdyenClient($storeId); | ||
| $service = $this->adyenHelper->initializeDonationsApi($client); | ||
| return $service->donationCampaigns($request)->toArray(); | ||
| } catch (\Adyen\AdyenException $e) { | ||
| $this->adyenLogger->error('Error fetching donation campaigns', ['exception' => $e]); | ||
| throw new LocalizedException(__('Unable to retrieve donation campaigns. Please try again later.')); | ||
| } | ||
| } | ||
|
|
||
| //Return the data of the first campaign only. | ||
| public function formatCampaign(array $donationCampaignsResponse): array | ||
| { | ||
| $campaignList = $donationCampaignsResponse['donationCampaigns'] ?? []; | ||
|
|
||
| if (empty($campaignList)) { | ||
| return []; | ||
| } | ||
|
|
||
| $firstCampaign = $campaignList[0]; | ||
|
|
||
| //Doing this workaround for now, Will be fixed with next API Library version | ||
| //RoundUp works with donation.type and not with donation.donationType | ||
| $firstCampaign['donation']['type'] = $firstCampaign['donation']['donationType'] ?? ''; | ||
| return [ | ||
| 'nonprofitName' => $firstCampaign['nonprofitName'] ?? '', | ||
| 'nonprofitDescription' => $firstCampaign['nonprofitDescription'] ?? '', | ||
| 'nonprofitUrl' => $firstCampaign['nonprofitUrl'] ?? '', | ||
| 'logoUrl' => $firstCampaign['logoUrl'] ?? '', | ||
| 'bannerUrl' => $firstCampaign['bannerUrl'] ?? '', | ||
| 'termsAndConditionsUrl' => $firstCampaign['termsAndConditionsUrl'] ?? '', | ||
| 'donation' => $firstCampaign['donation'] ?? [], | ||
| 'causeName' => $firstCampaign['causeName'] ?? '', | ||
| ]; | ||
| } | ||
|
|
||
| public function setDonationCampaignId(Order $order, $campaignId): void | ||
| { | ||
| $order->getPayment()->setAdditionalInformation('donationCampaignId', $campaignId); | ||
| $order->save(); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.