Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
feat(SFOX): sell expected delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Apr 23, 2018
1 parent 81e9068 commit 390fb7c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion assets/js/controllers/sfox/sfoxSellCheckout.controller.js
Expand Up @@ -38,12 +38,15 @@ function SfoxSellCheckoutController ($scope, $timeout, $stateParams, $q, Wallet,
$scope.payment.amount(amt);
$scope.payment.updateFeePerKb(Exchange.sellFee || 2);
$scope.payment.from(Wallet.my.wallet.hdwallet.defaultAccountIndex);
let minutesInADay = 1440;
let profile = exchange.profile;
let expectedDelivery = profile.processingTimes && profile.processingTimes.usd.sell / minutesInADay + ' Days';

$scope.payment.sideEffect((payment) => {
$scope.checkout.quote = quote;
$scope.checkout.type = 'sell';
$scope.checkout.goTo('confirm');
$scope.checkout.tradeDetails = sfox.sellTradeDetails($scope.checkout.quote, payment);
$scope.checkout.tradeDetails = sfox.sellTradeDetails($scope.checkout.quote, payment, null, null, expectedDelivery);
Wallet.api.incrementPartnerTrade('sfox', 'sell', $scope.checkout.quote.baseCurrency, $scope.checkout.quote.quoteCurrency);
});

Expand All @@ -58,6 +61,7 @@ function SfoxSellCheckoutController ($scope, $timeout, $stateParams, $q, Wallet,

let submitTx = (trade) => {
$scope.checkout.trade = trade;
$scope.checkout.expectedDelivery = trade.expectedDelivery;
$scope.payment.to(trade.receiveAddress);
return Wallet.askForSecondPasswordIfNeeded().then((pw) => {
return $scope.payment.build().sign(pw).publish().payment;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/controllers/sfox/sfoxTradeDetails.controller.js
Expand Up @@ -28,7 +28,7 @@ function SfoxTradeDetailsController ($scope, MyWallet, Exchange, currency, sfox,
$q.resolve(sfox.buyTradeDetails(null, trade, tx, expectedDelivery))
.then(details => $scope.tradeDetails = details);
} else {
$scope.tradeDetails = sfox.sellTradeDetails(null, null, trade, tx);
$scope.tradeDetails = sfox.sellTradeDetails(null, null, trade, tx, expectedDelivery);
}

$scope.rate = $scope.type === '.buy'
Expand Down
13 changes: 11 additions & 2 deletions assets/js/services/sfox.service.js
Expand Up @@ -195,7 +195,7 @@ function sfox ($q, MyWallet, MyWalletHelpers, Alerts, modals, Env, Exchange, cur
return localStorageService.get('hasSeenSfoxBuyIntro');
}

function sellTradeDetails (quote, payment, trade, tx) {
function sellTradeDetails (quote, payment, trade, tx, expectedDelivery) {
let { formatCurrencyForView, convertFromSatoshi } = currency;
let fiat = currency.currencies.find((curr) => curr.code === 'USD');
let btc = currency.bitCurrencies.find((curr) => curr.code === 'BTC');
Expand All @@ -209,7 +209,7 @@ function sfox ($q, MyWallet, MyWalletHelpers, Alerts, modals, Env, Exchange, cur
: (trade.receiveAmount).toFixed(2);
let amountKey = quote || payment ? '.AMT' : '.AMT_SOLD';

return {
let details = {
txAmt: {
key: amountKey,
val: isNaN(amount) ? amount : formatCurrencyForView(convertFromSatoshi(amount, btc), btc, true)
Expand All @@ -232,6 +232,15 @@ function sfox ($q, MyWallet, MyWalletHelpers, Alerts, modals, Env, Exchange, cur
tip: () => console.log('Clicked tooltip')
}
};

if (expectedDelivery) {
details.expectedDelivery = {
key: '.EXPECTED_DELIVERY',
val: expectedDelivery
};
}

return details;
}

function buyTradeDetails (quote, trade, tx, expectedDelivery) {
Expand Down
5 changes: 3 additions & 2 deletions locales/en-human.json
Expand Up @@ -1902,7 +1902,7 @@
"DISPLAY": "Pending Sell",
"ACTION": "@:EXCHANGE.ACTIONS.VIEW_DETAILS",
"HEADER": "Sell Order in Progress",
"BODY": "Your sell trade has been initiated. Your funds will be deposited into your bank account within 3-5 business days. <b>Your order ID is: SFX-{{::tradeId}}</b>"
"BODY": "Your sell trade has been initiated. Your funds will be deposited into your bank account by {{::expectedDelivery}}. <b>Your order ID is: SFX-{{::tradeId}}</b>"
},
"failed": {
"DISPLAY": "Failed Sell",
Expand All @@ -1927,6 +1927,7 @@
"TX_FEE": "Transaction Fee",
"TOTAL": "Total Outgoing Bitcoin",
"INTRODUCING_HEADER": "Sell Bitcoin",
"EXPECTED_DELIVERY": "Estimated Delivery of Funds",
"INTRODUCING_BODY": "Selling bitcoin is simple, seamless, and secure. Thanks to our partnership with SFOX, you can sell bitcoin directly from your Blockchain wallet.<br><br>Tips for getting started:<br>The minimum amount you can sell is $10. Your daily maximum can be found under the local currency field.<br><br>Currently, your Blockchain wallet supports linking only one bank account. If you would like to change your synced account, please email <a href=\"mailto:support@sfox.com?subject=Questions%20about%20my%20account%20-%20Blockchain\">support@sfox.com</a>. Please note: selling with a credit card is not supported at this time.",
"TRADING_FEE": "Trading Fee",
"TO_BE_RECEIVED": "USD To Be Received",
Expand Down Expand Up @@ -1964,7 +1965,7 @@
"TRADING_FEE": "@:SFOX.sell.TRADING_FEE",
"TX_FEE": "@:SFOX.sell.TX_FEE",
"NOW_SUPPORTING": "This Just In!",
"EXPECTED_DELIVERY": "Estimated Delivery of Funds",
"EXPECTED_DELIVERY": "@:SFOX.sell.EXPECTED_DELIVERY",
"ANNOUNCEMENT": "Buy has arrived. You can now swiftly buy bitcoin directly from within your Blockchain wallet!",
"GET_STARTED": "Begin Buying",
"COMING_SOON": "We are working hard to bring <strong>buy bitcoin</strong> functionality to your wallet very soon.",
Expand Down
4 changes: 2 additions & 2 deletions rootApp/Resources/wallet-options.json
Expand Up @@ -44,9 +44,9 @@
"showBuyFraction": 1,
"inviteFormFraction": 0.1,
"buyTransactionFeeInSatoshi": false,
"apiKey": "f31614a7-5074-49f2-8c2a-bfb8e55de2bd",
"apiKey": "6fbfb80536564af8bbedb7e3be4ec439",
"plaid": "0b041cd9e9fbf1e7d93a0d5a39f5b9",
"plaidEnv": "production",
"plaidEnv": "tartan",
"siftScience": "3884e5fae5",
"surveyLinks": ["https://blockchain.co1.qualtrics.com/jfe/form/SV_9BuZyJxdOT0Psb3",
"https://blockchain.co1.qualtrics.com/jfe/form/SV_8cE4saqzhlLXngN",
Expand Down

0 comments on commit 390fb7c

Please sign in to comment.