Skip to content

Commit

Permalink
Cleaner payment method description in Receipt (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree authored Oct 26, 2023
1 parent 9571f89 commit 3f42ae4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/Receipt.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Container from '@opencollective/frontend-components/components/Container'
import StyledTag from '@opencollective/frontend-components/components/StyledTag';
import StyledHr from '@opencollective/frontend-components/components/StyledHr';
import { EventDescription } from './EventDescription';
import { formatPaymentMethodName } from '../lib/payment-methods';

export class Receipt extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -409,7 +410,7 @@ export class Receipt extends React.Component {
<label>
<FormattedMessage defaultMessage="Payment Method:" />
</label>{' '}
{`${transactions[0].paymentMethod.type} ${transactions[0].paymentMethod.name}`}
{formatPaymentMethodName(transactions[0].paymentMethod)}
</div>
)}
</Box>
Expand Down
1 change: 1 addition & 0 deletions lib/graphql/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export async function fetchTransactionInvoice(transactionId, accessToken, apiKey
paymentMethod {
id
type
service
name
}
... on Credit {
Expand Down
11 changes: 11 additions & 0 deletions lib/payment-methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { startCase } from 'lodash';

export const formatPaymentMethodName = (paymentMethod) => {
if (!paymentMethod) {
return null;
} else if (paymentMethod.service === 'paypal') {
return `PayPal ${paymentMethod.type.toLowerCase()} ${paymentMethod.name}`;
} else {
return `${startCase(paymentMethod.type)} ${paymentMethod.name}`;
}
};

1 comment on commit 3f42ae4

@vercel
Copy link

@vercel vercel bot commented on 3f42ae4 Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.