From 28487f271e748205634d7ef80981ff1ffee8b03a Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sat, 18 Jan 2025 19:14:28 +0530 Subject: [PATCH] add fields to capture venmo details * add new field: venmo_user_id * add new field: phone_last_4 changed the forms to replace paypal with venmo --- .../components/affiliate/JKAffiliatePayee.js | 4 +- .../affiliate/JKAffiliatePayeeAddress.js | 26 +++++++++++ ...ayeePaypal.js => JKAffiliatePayeeVenmo.js} | 44 ++++++++++++------- jam-ui/src/i18n/locales/en/affiliate.json | 23 +++++++++- ...add_venmo_user_id_to_affiliate_partners.rb | 8 ++++ ..._add_phone_last_4_to_affiliate_partners.rb | 8 ++++ web/app/controllers/api_users_controller.rb | 8 +++- 7 files changed, 99 insertions(+), 22 deletions(-) rename jam-ui/src/components/affiliate/{JKAffiliatePayeePaypal.js => JKAffiliatePayeeVenmo.js} (54%) create mode 100644 ruby/db/migrate/20250118172025_add_venmo_user_id_to_affiliate_partners.rb create mode 100644 ruby/db/migrate/20250118184824_add_phone_last_4_to_affiliate_partners.rb diff --git a/jam-ui/src/components/affiliate/JKAffiliatePayee.js b/jam-ui/src/components/affiliate/JKAffiliatePayee.js index d0421f949..45e85ce4c 100644 --- a/jam-ui/src/components/affiliate/JKAffiliatePayee.js +++ b/jam-ui/src/components/affiliate/JKAffiliatePayee.js @@ -4,7 +4,7 @@ import { Card, CardBody, Row, Col } from 'reactstrap'; import FalconCardHeader from '../common/FalconCardHeader'; import { useTranslation } from 'react-i18next'; import JKAffiliatePayeeAddress from './JKAffiliatePayeeAddress'; -import JKAffiliatePayeePaypal from './JKAffiliatePayeePaypal'; +import JKAffiliatePayeeVenmo from './JKAffiliatePayeeVenmo'; import JKAffiliatePayeeTax from './JKAffiliatePayeeTax'; import { useAuth } from '../../context/UserAuth'; import { getAffiliatePartnerData } from '../../helpers/rest'; @@ -87,7 +87,7 @@ const JKAffiliatePayee = () => { - +
diff --git a/jam-ui/src/components/affiliate/JKAffiliatePayeeAddress.js b/jam-ui/src/components/affiliate/JKAffiliatePayeeAddress.js index 90dce5abb..4272ba966 100644 --- a/jam-ui/src/components/affiliate/JKAffiliatePayeeAddress.js +++ b/jam-ui/src/components/affiliate/JKAffiliatePayeeAddress.js @@ -14,6 +14,7 @@ const JKAffiliatePayeeAddress = ({ affiliateUser, onSubmit, submitting }) => { setValue } = useForm({ defaultValues: { + phone_last_4: '', address1: '', address2: '', city: '', @@ -24,6 +25,7 @@ const JKAffiliatePayeeAddress = ({ affiliateUser, onSubmit, submitting }) => { }); useEffect(() => { + setValue('phone_last_4', affiliateUser?.address?.phone_last_4 || ''); setValue('address1', affiliateUser?.address?.address1 || ''); setValue('address2', affiliateUser?.address?.address2 || ''); setValue('city', affiliateUser?.address?.city || ''); @@ -47,6 +49,30 @@ const JKAffiliatePayeeAddress = ({ affiliateUser, onSubmit, submitting }) => { {t('payee.address.help_text')}
+ + + ( + + )} + /> + {errors.phone_last_4 && ( +
+ {errors.phone_last_4.message} +
+ )} +
{ +const JKAffiliatePayeeVenmo = ({ affiliateUser, onSubmit, submitting }) => { const { t } = useTranslation('affiliate'); const { handleSubmit, @@ -14,45 +15,45 @@ const JKAffiliatePayeePaypal = ({ affiliateUser, onSubmit, submitting }) => { setValue } = useForm({ defaultValues: { - paypal_id: '' + venmo_user_id: '' } }); useEffect(() => { - setValue('paypal_id', affiliateUser?.paypal_id || ''); + setValue('venmo_user_id', affiliateUser?.venmo_user_id || ''); }, [affiliateUser]); - const onSubmitPaypal = data => { - const params = { "paypal_id": data.paypal_id }; + const onSubmitVenmo = data => { + const params = { "venmo_user_id": data.venmo_user_id }; onSubmit(params); } return ( -
{t('payee.paypal.title')}
+
{t('payee.venmo.title')}
- {t('payee.paypal.help_text')} - + {t('payee.venmo.help_text')} + - + } + render={({ field }) => } /> - {errors.paypal_id && ( + {errors.venmo_user_id && (
- {errors.paypal_id.message} + {errors.venmo_user_id.message}
)}
- + { submitting && } @@ -63,4 +64,15 @@ const JKAffiliatePayeePaypal = ({ affiliateUser, onSubmit, submitting }) => { ); }; -export default JKAffiliatePayeePaypal; +JKAffiliatePayeeVenmo.propTypes = { + affiliateUser: PropTypes.object, + onSubmit: PropTypes.func.isRequired, + submitting: PropTypes.bool.isRequired +}; + +JKAffiliatePayeeVenmo.defaultProps = { + onSubmit: () => {}, + submitting: false +}; + +export default JKAffiliatePayeeVenmo; diff --git a/jam-ui/src/i18n/locales/en/affiliate.json b/jam-ui/src/i18n/locales/en/affiliate.json index 6c1800111..c08650398 100644 --- a/jam-ui/src/i18n/locales/en/affiliate.json +++ b/jam-ui/src/i18n/locales/en/affiliate.json @@ -14,9 +14,10 @@ "not_affiliate": "You are not currently a JamKazam affiliate.", "learn_to_earn": "Learn how you can earn cash simply by telling your friends and followers about JamKazam.", "address": { - "title": "Address", - "help_text": "If you are a US resident, you must provide your home mailing address for JamKazam to process affiliate payments, per US tax regulations. Please enter your address information below.", + "title": "Address & Phone", + "help_text": "We need the last 4 digits of your phone number to process Venmo payments for all affiliates. In addition, for affiliates that are US residents, you must provide either your home mailing address (for individuals) or your business mailing address (for affiliates operating as a business) for JamKazam to process affiliate payments, per US tax regulations. Please enter your phone and address information below.", "form": { + "phone_last_4": "Last 4 Digits of Phone Number", "address1": "Street Address 1", "address2": "Street Address 2", "city": "City", @@ -24,6 +25,10 @@ "zip": "Zip Code", "submit": "Save", "validations": { + "phone_last_4": { + "required": "Last 4 Digits of Phone Number is required", + "invalid": "Last 4 Digits of Phone Number is invalid" + }, "address1": "Street Address 1 is required", "city": "City is required", "state": "State is required", @@ -42,6 +47,20 @@ } } }, + "venmo": { + "title": "Venmo", + "help_text": "JamKazam makes affiliate payments via Venmo. Please enter your Venmo user ID below - e.g. @username.", + "form": { + "venmo_user_id": "Venmo User ID", + "submit": "Save", + "validations": { + "venmo_user_id": { + "required": "Venmo User ID is required", + "invalid": "Venmo User ID is invalid" + } + } + } + }, "tax": { "title": "Tax", "help_text": "If you are a US resident, you must provide your tax ID for JamKazam to process affiliate payments, per US tax regulations. Please enter your tax ID information below. If you are not a US resident, you may leave this field blank.", diff --git a/ruby/db/migrate/20250118172025_add_venmo_user_id_to_affiliate_partners.rb b/ruby/db/migrate/20250118172025_add_venmo_user_id_to_affiliate_partners.rb new file mode 100644 index 000000000..2e916fc89 --- /dev/null +++ b/ruby/db/migrate/20250118172025_add_venmo_user_id_to_affiliate_partners.rb @@ -0,0 +1,8 @@ + class AddVenmoUserIdToAffiliatePartners < ActiveRecord::Migration + def self.up + execute("ALTER TABLE public.affiliate_partners ADD COLUMN venmo_user_id VARCHAR(255);") + end + def self.down + execute("ALTER TABLE public.affiliate_partners DROP COLUMN venmo_user_id;") + end + end diff --git a/ruby/db/migrate/20250118184824_add_phone_last_4_to_affiliate_partners.rb b/ruby/db/migrate/20250118184824_add_phone_last_4_to_affiliate_partners.rb new file mode 100644 index 000000000..97f42b1d4 --- /dev/null +++ b/ruby/db/migrate/20250118184824_add_phone_last_4_to_affiliate_partners.rb @@ -0,0 +1,8 @@ + class AddPhoneLast4ToAffiliatePartners < ActiveRecord::Migration + def self.up + execute "ALTER TABLE affiliate_partners ADD COLUMN phone_last_4 VARCHAR(4)" + end + def self.down + execute "ALTER TABLE affiliate_partners DROP COLUMN phone_last_4" + end + end diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 18fdd64cf..a4ef22e26 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -981,7 +981,9 @@ class ApiUsersController < ApiController if request.post? oo.address = params[:address] oo.tax_identifier = params[:tax_identifier] - oo.paypal_id = params[:paypal_id] + #oo.paypal_id = params[:paypal_id] + oo.venmo_user_id = params[:venmo_user_id] + oo.phone_last_4 = params[:phone_last_4] oo.save! render json: {}, status: 200 @@ -990,7 +992,9 @@ class ApiUsersController < ApiController result['account'] = { 'address' => oo.address.clone, 'tax_identifier' => oo.tax_identifier, - 'paypal_id' => oo.paypal_id, + #'paypal_id' => oo.paypal_id, + 'venmo_user_id' => oo.venmo_user_id, + 'phone_last_4' => oo.phone_last_4, 'entity_type' => oo.entity_type, 'partner_name' => oo.partner_name, 'partner_id' => oo.partner_user_id,