Skip to content

Commit 19422d8

Browse files
committed
fix(paypal): Fix saving PayPal web profile to Firestore on creation
Prevent unecessary multiple profiles created
1 parent d52965a commit 19422d8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/apps/paypal/src/paypal-list-payments.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ export const paypalListPayments = async (modBody: AppModuleBody<'list_payments'>
105105
if (!(await docRef.get()).exists) {
106106
await createPaypalWebhook();
107107
const paypalProfile = await createPaypalProfile();
108-
await docRef.set(paypalProfile);
108+
if (paypalProfile) {
109+
await docRef.set(paypalProfile);
110+
}
109111
}
110112
paypalPayment = await createPaypalPayment(parseToPaypalPayment(params));
111113
} catch (_err: any) {

packages/apps/paypal/src/util/paypal-api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export const executePaypalPayment = async (
112112
export const createPaypalProfile = async () => {
113113
const { settingsContent } = config.get();
114114
const { domain } = settingsContent;
115-
return (await getPaypalAxios()).post('/v1/payment-experience/web-profiles/', {
115+
const paypalAxios = await getPaypalAxios();
116+
const { data } = await paypalAxios.post('/v1/payment-experience/web-profiles/', {
116117
name: `EComPlus_${Date.now()}`,
117118
presentation: {
118119
brand_name: settingsContent.name || 'Loja Virtual',
@@ -133,6 +134,7 @@ export const createPaypalProfile = async () => {
133134
: 'http://www.yeowza.com',
134135
},
135136
});
137+
return data;
136138
};
137139

138140
export const createPaypalWebhook = async () => {

0 commit comments

Comments
 (0)