Skip to content

Commit

Permalink
feat: add functions for changing the payment method on an existing or…
Browse files Browse the repository at this point in the history
…der (#299)

* feat: assign payment method to sales channel

* feat: function to get the radio button for a specific payment method on the order edit storefront page

* fix: Delete payment method instead of currency
  • Loading branch information
sguder authored Feb 4, 2025
1 parent a4e0a41 commit 6719019
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/page-objects/storefront/CheckoutOrderEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ export class CheckoutOrderEdit implements PageObject{
url(orderUuid: string) {
return `account/order/edit/${orderUuid}`;
}

/**
* Returns the radio button element for a specified payment method.
*
* @param paymentMethodName - Name of the payment method on the page.
*/
getPaymentMethodButton(paymentMethodName: string): Locator {
return this.page.getByLabel(paymentMethodName);
}
}
35 changes: 34 additions & 1 deletion src/services/TestDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class TestDataService {
*
* @private
*/
private highPriorityEntities = ['order', 'product', 'landing_page', 'shipping_method', 'sales_channel_domain', 'sales_channel_currency', 'sales_channel_country', 'customer'];
private highPriorityEntities = ['order', 'product', 'landing_page', 'shipping_method', 'sales_channel_domain', 'sales_channel_currency', 'sales_channel_country', 'sales_channel_payment_method', 'customer'];

/**
* A registry of all created records.
Expand Down Expand Up @@ -1212,6 +1212,39 @@ export class TestDataService {
return salesChannel;
}

/**
* Assigns a payment method to a sales channel.
*
* @param salesChannelId - The uuid of the sales channel.
* @param paymentMethodId - The uuid of the currency.
*/
async assignSalesChannelPaymentMethod(salesChannelId: string, paymentMethodId: string) {
const syncSalesChannelResponse = await this.AdminApiClient.post('./_action/sync', {
data: {
'write-sales-channel-payment-method': {
entity: 'sales_channel_payment_method',
action: 'upsert',
payload: [
{
salesChannelId: salesChannelId,
paymentMethodId: paymentMethodId,
},
],
},
},
});
expect(syncSalesChannelResponse.ok()).toBeTruthy();

const { data: salesChannel } = await syncSalesChannelResponse.json();

this.addCreatedRecord('sales_channel_payment_method', {
salesChannelId: salesChannelId,
paymentMethodId: paymentMethodId,
});

return salesChannel;
}

/**
* Assigns a media resource to a payment method as a logo.
*
Expand Down

0 comments on commit 6719019

Please sign in to comment.