Commits (2)
......@@ -32,6 +32,7 @@ import {
import { Scheduler } from './components/scheduler/scheduler';
import { Modal } from './components/modal/modal.component';
import { MindsRichEmbed } from './components/rich-embed/rich-embed';
import { QRCodeComponent } from './components/qr-code/qr-code.component';
import { MDL_DIRECTIVES } from './directives/material';
import { AutoGrow } from './directives/autogrow';
......@@ -139,6 +140,7 @@ import { HorizontalInfiniteScroll } from "./components/infinite-scroll/horizonta
MindsRichEmbed,
TagcloudComponent,
DropdownComponent,
QRCodeComponent,
AutoGrow,
InlineAutoGrow,
......@@ -223,6 +225,7 @@ import { HorizontalInfiniteScroll } from "./components/infinite-scroll/horizonta
MindsRichEmbed,
TagcloudComponent,
DropdownComponent,
QRCodeComponent,
AutoGrow,
InlineAutoGrow,
......
import {
Component,
Input,
ElementRef,
} from '@angular/core';
declare var require: any;
let QRCode: any;
@Component({
selector: 'm-qr-code',
template: '',
})
export class QRCodeComponent {
qrcode;
@Input() data: string = '';
constructor(public el: ElementRef) { }
ngOnInit() {
if (!QRCode) {
QRCode = require('qrcodejs2');
}
this.qrcode = new QRCode(this.el.nativeElement, {
colorDark: '#000',
colorLight: '#FFF',
correctLevel: QRCode.CorrectLevel['M'],
height: 300,
text: this.data || ' ',
useSVG: true,
width: 300,
});
}
}
......@@ -24,7 +24,7 @@ export class RevenueConsoleComponent {
}
ngOnInit() {
if (!this.session.getLoggedInUser().merchant) {
if (!this.session.getLoggedInUser().merchant || this.session.getLoggedInUser().merchant.deleted) {
this.router.navigate(['/wallet/usd/onboarding']);
}
}
......
......@@ -37,7 +37,7 @@ export class RevenueOptionsComponent {
getSettings() {
this.inProgress = true;
this.client.get('api/v2/wallet/usd/settings')
this.client.get('api/v2/payments/stripe/connect')
.then(({ account }) => {
this.inProgress = false;
this.payoutMethod.country = account.country;
......@@ -55,7 +55,7 @@ export class RevenueOptionsComponent {
this.editing = false;
this.detectChanges();
this.client.post('api/v1/monetization/settings', this.form.value)
this.client.post('api/v2/payments/stripe/connect/bank', this.form.value)
.then((response: any) => {
this.inProgress = false;
this.getSettings();
......@@ -70,7 +70,7 @@ export class RevenueOptionsComponent {
leave() {
this.leaving = true;
this.detectChanges();
this.client.delete('api/v1/monetization/settings/account')
this.client.delete('api/v2/payments/stripe/connect')
.then((response: any) => {
(<any>window).Minds.user.merchant = [];
this.router.navigate(['/newsfeed']);
......
<div class="m-btc__wrapper">
<p>Please scan the following QR code, or send <b>{{ amount }} BTC</b> to <b>{{ address }}</b>.</p>
<m-qr-code
[data]="qrdata"
>
</m-qr-code>
</div>
.m-btc__wrapper {
m-qr-code {
width: 300px;
height: 300px;
display: block;
position: relative;
}
}
import {
Component,
ChangeDetectorRef,
ChangeDetectionStrategy,
} from '@angular/core';
@Component({
selector: 'm-btc',
templateUrl: 'btc.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BTCComponent {
address: string = '1DWPuJjcZWzsRPCwss4gYqgeUpkj5AD1yu';
amount: string = '0.01';
set data(data) {
this.address = data.address;
this.amount = data.amount;
}
get qrdata() {
return 'bitcoin:' + this.address + '?amount=' + this.amount;
}
}
import { Injectable } from '@angular/core';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { BTCComponent } from './btc.component';
@Injectable()
export class BTCService {
constructor(
private overlayModal: OverlayModalService,
) { }
showModal(opts) {
this.overlayModal
.create(BTCComponent, opts)
.present();
}
}
<form class="m-form">
<p>You can receive Bitcoin (BTC) payments via wire by inputing a receiver address below. Note: You may want to rotate this address frequently to avoid 3rd parties tracking your transactions.</p>
<label>Bitcoin Address</label>
<input
class="m-input"
[(ngModel)]="btcAddress"
[ngModelOptions]="{standalone: true}"
/>
<button
class="m-btn m-btn--slim m-btn--action"
[disabled]="!btcAddress || saving"
(click)="save()"
>
<ng-container *ngIf="saving">
Saving...
</ng-container>
<ng-container *ngIf="!saving">
Save
</ng-container>
</button>
</form>
m-btc__settings {
label {
font-weight: 600;
}
input {
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 32px;
}
}
import {
Component,
ChangeDetectorRef,
ChangeDetectionStrategy,
} from '@angular/core';
import { Client } from '../../../services/api';
@Component({
selector: 'm-btc__settings',
templateUrl: 'settings.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BTCSettingsComponent {
btcAddress: string = '';
saving: boolean = false;
constructor(
private client: Client,
private cd: ChangeDetectorRef,
) { }
ngOnInit() {
this.getAddressFromRemote();
}
async getAddressFromRemote() {
const { address } = <any>await this.client.get('api/v2/wallet/btc/address');
this.btcAddress = address;
this.detectChanges();
}
async save() {
this.saving = true;
await this.client.post('api/v2/wallet/btc/address', {
address: this.btcAddress,
});
this.saving = false;
this.detectChanges();
}
detectChanges() {
this.cd.markForCheck();
this.cd.detectChanges();
}
}
......@@ -10,6 +10,9 @@ import { PayWall } from './paywall/paywall.component';
import { PaywallCancelButton } from './paywall/paywall-cancel.component';
import { PaymentsNewCard } from './new-card/new-card.component';
import { PaymentsSelectCard } from './select-card/select-card.component';
import { BTCService } from './btc/btc.service';
import { BTCComponent } from './btc/btc.component';
import { BTCSettingsComponent } from './btc/settings.component';
@NgModule({
imports: [
......@@ -25,6 +28,8 @@ import { PaymentsSelectCard } from './select-card/select-card.component';
PaywallCancelButton,
PaymentsNewCard,
PaymentsSelectCard,
BTCComponent,
BTCSettingsComponent,
],
exports: [
PayWall,
......@@ -32,8 +37,13 @@ import { PaymentsSelectCard } from './select-card/select-card.component';
PaymentsNewCard,
PaymentsSelectCard,
],
providers: [
BTCService,
],
entryComponents: [
PaymentsNewCard,
BTCComponent,
BTCSettingsComponent,
],
})
export class PaymentsModule {
......
......@@ -24,7 +24,7 @@ import { Session } from '../../../services/session';
export class PaymentsSelectCard {
minds = (<any>window).Minds;
@Output() selected: EventEmitter<void> = new EventEmitter();
@Output() selected: EventEmitter<string> = new EventEmitter();
paymentMethodId: string = '';
paymentMethods = [];
......
......@@ -29,6 +29,7 @@
<ng-template ngSwitchCase="money">{{ subscription.amount | currency:'USD':true }}</ng-template>
<ng-template ngSwitchCase="tokens" i18n="@@SETTINGS__BILLING__SUBSCRIPTIONS__TOKENS_LABEL">{{ subscription.amount | token:18 | number }} Tokens</ng-template>
<ng-template ngSwitchCase="points" i18n="@@SETTINGS__BILLING__SUBSCRIPTIONS__POINTS_LABEL">{{ subscription.amount | number:'1.0-0' }} Points</ng-template>
<ng-template ngSwitchCase="usd">{{ subscription.amount | token:2 }} USD</ng-template>
</span>
<span class="m-settings--billing-subscriptions--subscription-item-select" (click)="cancel(i)" i18n="@@M__ACTION__CANCEL">Cancel</span>
......
......@@ -56,6 +56,12 @@
>
<i class="material-icons">attach_money</i>
<span i18n="@@WALLET__TOKENS__TESTNET_TOKENS">USD Console</span>
</a>
<a class="m-page--sidebar--navigation--item"
(click)="openBtcSettingsModal()"
>
<i class="material-icons">settings</i>
<span i18n="@@WALLET__TOKENS__TESTNET_TOKENS">BTC Console</span>
</a>
<a class="m-page--sidebar--navigation--item"
(click)="invite.open = true"
......
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { OverlayModalService } from '../../../services/ux/overlay-modal';
import { BTCSettingsComponent } from '../../payments/btc/settings.component';
@Component({
moduleId: module.id,
selector: 'm-wallet--tokens',
templateUrl: 'tokens.component.html'
})
......@@ -11,9 +13,18 @@ export class WalletTokensComponent {
showOnboarding: boolean = false;
minds = window.Minds;
constructor(route: ActivatedRoute) {
constructor(
route: ActivatedRoute,
private overlayModal: OverlayModalService,
) {
route.url.subscribe(() => {
this.showOnboarding = route.snapshot.firstChild && route.snapshot.firstChild.routeConfig.path === 'transactions';
});
}
openBtcSettingsModal() {
this.overlayModal
.create(BTCSettingsComponent, {})
.present();
}
}
import { Component, OnInit, Output, EventEmitter, Input, ChangeDetectorRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Client } from '../../../../services/api';
import { requiredFor, optionalFor } from './onboarding.validators';
......@@ -28,6 +29,7 @@ export class WalletUSDOnboardingComponent implements OnInit {
private fb: FormBuilder,
private client: Client,
private cd: ChangeDetectorRef,
private router: Router,
protected overlayModal: OverlayModalService,
) { }
......@@ -90,7 +92,7 @@ export class WalletUSDOnboardingComponent implements OnInit {
}
}
onboard() {
async onboard() {
if (this.inProgress) {
return;
}
......@@ -98,22 +100,25 @@ export class WalletUSDOnboardingComponent implements OnInit {
this.inProgress = true;
this.error = '';
this.client.post('api/v2/wallet/usd/onboarding', this.form.value)
.then((response: any) => {
this.inProgress = false;
try {
const response = <any>await this.client.post('api/v2/wallet/usd/onboarding', this.form.value)
this.inProgress = false;
if (!this.minds.user.programs)
this.minds.user.programs = [];
this.minds.user.programs.push('affiliate');
if (!this.minds.user.programs)
this.minds.user.programs = [];
this.minds.user.programs.push('affiliate');
this.completed.emit(response);
this.detectChanges();
})
.catch((e) => {
this.inProgress = false;
this.error = e.message;
this.detectChanges();
});
this.minds.user.merchant = {
'id': response.account.id,
'service': 'stripe',
};
this.router.navigate(['/wallet/usd/']);
} catch(e) {
this.inProgress = false;
this.error = e.message;
this.detectChanges();
}
}
update() {
......
......@@ -10,7 +10,7 @@ import { Session } from '../../../services/session';
template: `
<button class="m-btn m-btn--action m-btn--slim m-wire-button" (click)="wire()">
<i class="ion-icon ion-flash"></i>
<span>Donate</span>
<span>Wire</span>
</button>
`
})
......
......@@ -7,7 +7,7 @@
<i class="ion-icon ion-flash"></i>
<span class="m-wire-channel--cta-label">
<span i18n="@@WIRE__CHANNEL__WIRE_ME_ACTION">Donate</span>
<span i18n="@@WIRE__CHANNEL__WIRE_ME_ACTION">Wire me</span>
</span>
</button>
</div>
......