Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD Auth 5613] [IOU] Pay with Expensify option #3174

Merged
merged 5 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const CONST = {
// not be changed.
PAYMENT_TYPE: {
ELSEWHERE: 'Elsewhere',
EXPENSIFY: 'Expensify',
PAYPAL_ME: 'PayPal.me',
VENMO: 'Venmo',
},
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default {
pay: 'Pay',
viewDetails: 'View Details',
settleElsewhere: 'I\'ll settle up elsewhere',
settleExpensify: 'Pay with Expensify',
settlePaypalMe: 'Pay with PayPal.me',
settleVenmo: 'Pay with Venmo',
request: ({amount}) => `Request ${amount}`,
Expand Down
12 changes: 12 additions & 0 deletions src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@ function PayIOU(parameters) {
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {Number} parameters.reportID
* @returns {Promise}
*/
function PayWithWallet(parameters) {
const commandName = 'PayWithWallet';
requireParameters(['reportID'], parameters, commandName);
return Network.post(commandName, parameters);
}

/**
* @param {Object} parameters
* @param {String} parameters.emailList
Expand Down Expand Up @@ -800,6 +811,7 @@ export {
Graphite_Timer,
Log,
PayIOU,
PayWithWallet,
PersonalDetails_GetForEmails,
PersonalDetails_Update,
Plaid_GetLinkToken,
Expand Down
10 changes: 5 additions & 5 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ function payIOUReport({
chatReportID, reportID, paymentMethodType, amount, currency, submitterPhoneNumber, submitterPayPalMeAddress,
}) {
Onyx.merge(ONYXKEYS.IOU, {loading: true, error: false});
API.PayIOU({
reportID,
paymentMethodType,
})
const payIOUPromise = paymentMethodType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY
? API.PayWithWallet({reportID})
: API.PayIOU({reportID, paymentMethodType});
payIOUPromise
.then((response) => {
if (response.jsonCode !== 200) {
throw new Error(response.message);
Expand All @@ -171,7 +171,7 @@ function payIOUReport({
fetchIOUReportByIDAndUpdateChatReport(reportID, chatReportID);

// Once we have successfully paid the IOU we will transfer the user to their platform of choice if they have
// selected something other than a manual settlement e.g. Venmo or PayPal.me
// selected something other than a manual settlement or Expensify Wallet e.g. Venmo or PayPal.me
if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.PAYPAL_ME) {
openURLInNewTab(buildPayPalPaymentUrl(amount, submitterPayPalMeAddress, currency));