Document Status | Status |
---|
colour | Blue |
---|
title | in-progress |
---|
|
|
---|
Document Owner(s) | Capovilla, Evandro |
---|
Reviewers | |
---|
...
We are sending the name as the first string until de empty string.
We are sending the surname as the rest of the name after the first empty string
We are using the same feature flag to send user details to send first name and last name data
Mandatory fields are still being sent (email and/or cell phone)
The workPhone and homePhone fields are not mandatory due to the rule above
The IpAddress field has already been sent - No changes necessary
The cardholderName field only requires updates in BE
#1 - Send cardholder name field to paycomet
...
Whitelabel App (Already done)
The frontend will be responsible for displaying and retrieving the cardholderName field and sending this information to paycomet. Nowadays this information is already sent via Paycomet forms, but they also need it to be sent via the merchantData field.
...
Expand |
---|
title | src/modules/legacy/legacy.service.ts |
---|
|
Before Code Block |
---|
paycometSale = {
...,
fullName: paymentUserDetails.name!,
...,
}; |
After Code Block |
---|
paycometSale = {
...,
fullName: payment?.fullName || paymentUserDetails.name!,
...,
}; |
|
Payment Service (Already done)
Expand |
---|
title | src/functions/graphql/utils/make-payment.ts |
---|
|
Code Block |
---|
private mapPaymentMethod(
params: IPaycometPaymentSaleEvent,
): {
paymentMethodType: string;
paymentMethod: string;
} {
const isVaultedPayment = !params.storePaymentMethod && params.storedPaymentMethodId;
if (isVaultedPayment) {
return {
paymentMethodType: params.paymentType,
paymentMethod: JSON.stringify({
...,
cardholderName: params?.fullName,
...,
}),
};
}
return {
paymentMethodType: params.paymentType,
paymentMethod: JSON.stringify({
...,
cardholderName: params?.fullName,
...,
}),
};
} |
|
...
Expand |
---|
title | src/paycomet-core/paycomet-helper.ts |
---|
|
The idea here is to update the buildUserDetails function to handle first and last name, since the responsibility of this function is to generate the customer field. Create two function parseName and parseSurname, to handle the cardholderName to send to paycomet. Update the buildUserDetails function and tests. Code Block |
---|
public buildUserDetails = (
region: string,
cellphone?: string,
email?: string,
paymentMethod?: PaymentMethod
): TCustomer | undefined => {
if (!cellphonecellphone && !email && !emailpaymentMethod.cardholderName) {
return undefined;
}
return {
mobilePhone: cellphone ? this.parsePhoneNumber(cellphone, region) : undefined,
email: email || undefined,
name: parseName(paymentMethod.cardholderName)
surname: parseSurname(paymentMethod.cardholderName)
};
}; |
|
...
Whitelabel App (Already done)
Expand |
---|
title | src/pages/cart/payment/order-payment/paycomet-hosted-page-payment/paycomet-vaulted-card.tsx |
---|
|
Code Block |
---|
generateCreatePreAuthorization({
variables: {
input: {
...,
cardHolderName: paymentValues.nameOnCard,
...,
},
},
}); |
|
GraphQL (Already done)
Expand |
---|
title | src/functions/graphql/providers/payments.ts |
---|
|
Code Block |
---|
public async createPreAuthorizationPaycomet({...}){
const paycometPreauth =
await this.paymentsClient.paycometClient.request<ICreatePreAuthorizationResponse>((apis) =>
apis.paymentsApi.createPreAuthorization({
iCreatePreAuthorizationRequest: {
...,
cardHolderName,
...,
},
region: regionCountry,
}),
);
}
|
|
...
Expand |
---|
title | src/payment/preauth/preauth.service.ts |
---|
|
Code Block |
---|
| public async processPreAuth(...){
...
const customer = this.paycometHelper.buildUserDetails(region, cellphone, email, request);
...
} |
|
...
Vaulted
No update required
...
Vaulted - Pre-auth
No update required
...
Update phoneNumber field to use user accounts or delivery data
The idea here is to mainly use the phoneNumber from the cart page ( delivery mode ) and if it doesn't exist, we use the phoneNumber from the user data ( restaurant mode ). If neither of these fields exist, we are sending that data as empty.
Whitelabel App
Expand |
---|
title | cart/payment/order-payment/use-order-payment.ts |
---|
|
One-time: Code Block |
---|
const {
...,
orderPhoneNumber,
} = useOrderContext();
const placeOrder = useCallback(async () => {
...
const userPaymentDetails = enablePaycometPaymentUserDetails
? {
phoneNumber: orderPhoneNumber ?? auth.user?.details?.phoneNumber,
email: auth.user?.details?.email,
}
: undefined;
...
} |
Vaulted: Code Block |
---|
const {
...,
orderPhoneNumber,
} = useOrderContext();
const processOrderWithAccount = useCallback(async () => {
...
const userPaymentDetails = enablePaycometPaymentUserDetails
? {
phoneNumber: orderPhoneNumber ?? user?.details.phoneNumber,
email: user?.details?.email,
}
: undefined;
...
} |
|
...