Skip to content

Commit

Permalink
Set Google Pay merchantName to endow name (profileUrl)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Dec 11, 2023
1 parent 7a9e8cd commit cd7319b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { FormStep } from "slices/donation";
import { GOOGLE_PAY_MERCHANT_ID } from "constants/env";
import { GOOGLE_PAY_MERCHANT_ID, PUBLIC_STRIPE_KEY } from "constants/env";
import getProfileUrl from "../getProfileUrl";

export default function createPaymentRequest(
state: FormStep
): google.payments.api.PaymentDataRequest {
const profileUrl = getProfileUrl(state.recipient.id);
return {
apiVersion: 2,
apiVersionMinor: 0,
Expand All @@ -17,14 +19,16 @@ export default function createPaymentRequest(
tokenizationSpecification: {
type: "PAYMENT_GATEWAY",
parameters: {
gateway: "example",
gateway: "stripe",
"stripe:version": "2018-10-31",
"stripe:publishableKey": PUBLIC_STRIPE_KEY,
},
},
},
],
merchantInfo: {
merchantId: GOOGLE_PAY_MERCHANT_ID,
merchantName: state.recipient.name,
merchantName: `${state.recipient.name} (${profileUrl})`,
},
transactionInfo: {
totalPriceStatus: "FINAL",
Expand Down
5 changes: 2 additions & 3 deletions src/components/donation/Steps/DonateMethods/Stocks.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { FormStep } from "slices/donation";
import { appRoutes } from "constants/routes";
import BuildEmailForm from "./BuildEmailForm";
import getProfileUrl from "./getProfileUrl";

type Props = { state: FormStep };

export default function Stocks({ state }: Props) {
const charityName = state.recipient.name;
const profileUrl = `${window.location.origin}${appRoutes.donate}/${state.recipient.id}`;

const profileUrl = getProfileUrl(state.recipient.id);
return (
<div className="grid gap-5">
<h3 className="text-2xl sm:text-3xl text-center leading-relaxed">
Expand Down
5 changes: 5 additions & 0 deletions src/components/donation/Steps/DonateMethods/getProfileUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { appRoutes } from "constants/routes";

export default function getProfileUrl(endowId: number) {
return `${window.location.origin}${appRoutes.donate}/${endowId}`;
}

0 comments on commit cd7319b

Please sign in to comment.