Skip to content

Commit

Permalink
Merge pull request #3242 from Expensify/main
Browse files Browse the repository at this point in the history
  • Loading branch information
OSBotify authored May 31, 2021
2 parents 280f36d + dc2ea0a commit bfb2647
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 11 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001005704
versionName "1.0.57-4"
versionCode 1001005705
versionName "1.0.57-5"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCash/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0.57.4</string>
<string>1.0.57.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCashTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.57.4</string>
<string>1.0.57.5</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expensify.cash",
"version": "1.0.57-4",
"version": "1.0.57-5",
"author": "Expensify, Inc.",
"homepage": "https://expensify.cash",
"description": "Expensify.cash is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,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 @@ -108,6 +108,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));
} else if (paymentMethodType === CONST.IOU.PAYMENT_TYPE.VENMO) {
Expand Down
18 changes: 18 additions & 0 deletions src/pages/iou/IOUDetailsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class IOUDetailsModal extends Component {
this.isComponentMounted = true;
fetchIOUReportByID(this.props.route.params.iouReportID, this.props.route.params.chatReportID);
this.addVenmoPaymentOptionIfAvailable();
this.addExpensifyPaymentOptionIfAvailable();
}

componentWillUnmount() {
Expand Down Expand Up @@ -173,10 +174,27 @@ class IOUDetailsModal extends Component {
});
}

/**
* Checks to see if we can use Expensify.
* The report currency must be USD.
*/
addExpensifyPaymentOptionIfAvailable() {
if (lodashGet(this.props, 'iouReport.currency') !== CONST.CURRENCY.USD) {
return;
}

// Make it the first payment option and set it as the default.
this.setState(prevState => ({
paymentOptions: [CONST.IOU.PAYMENT_TYPE.EXPENSIFY, ...prevState.paymentOptions],
paymentType: CONST.IOU.PAYMENT_TYPE.EXPENSIFY,
}));
}

render() {
const sessionEmail = lodashGet(this.props.session, 'email', null);
const reportIsLoading = _.isUndefined(this.props.iouReport);
const paymentTypeTextOptions = {
[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]: this.props.translate('iou.settleExpensify'),
[CONST.IOU.PAYMENT_TYPE.VENMO]: this.props.translate('iou.settleVenmo'),
[CONST.IOU.PAYMENT_TYPE.PAYPAL_ME]: this.props.translate('iou.settlePaypalMe'),
[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]: this.props.translate('iou.settleElsewhere'),
Expand Down

0 comments on commit bfb2647

Please sign in to comment.