Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
avvy
frontend
Commits
4cbbe3c4
Commit
4cbbe3c4
authored
5 years ago
by
Andrey Leschuk
Browse files
Options
Download
Plain Diff
Merge branch 'payment_fix' into 'master'
AV-365
редирект через window.open See merge request avvy/frontend!76
parents
05134440
518a913d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/PaymentForm/index.js
+23
-15
src/components/PaymentForm/index.js
src/reducers/stripe.js
+5
-4
src/reducers/stripe.js
with
28 additions
and
19 deletions
+28
-19
src/components/PaymentForm/index.js
View file @
4cbbe3c4
...
...
@@ -3,7 +3,7 @@ import { Form, Message, Segment } from "semantic-ui-react";
import
{
connect
}
from
"
react-redux
"
;
import
{
charge
,
error
}
from
"
../../reducers/stripe
"
;
import
{
charge
,
error
,
ReturnStatus
}
from
"
../../reducers/stripe
"
;
import
"
./PaymentForm.scss
"
;
const
mapStateToProps
=
state
=>
state
.
stripe
;
...
...
@@ -13,7 +13,8 @@ const mapDispatchToProps = dispatch => ({
onSubmit
:
(
userID
,
dataJson
,
options
)
=>
dispatch
(
charge
(
userID
,
dataJson
,
options
)),
onSetError
:
(
body
,
header
)
=>
dispatch
(
error
(
body
,
header
)),
onClearError
:
()
=>
dispatch
(
error
())
onClearError
:
()
=>
dispatch
(
error
()),
setStatus
:
status
=>
dispatch
(
ReturnStatus
(
status
))
});
//import Stripe from 'stripe';
...
...
@@ -173,22 +174,29 @@ class PaymentForm extends React.Component {
render
()
{
let
errTag
;
if
(
this
.
props
.
error
)
{
const
{
status
,
loading
,
error
,
error_message
,
setStatus
}
=
this
.
props
;
if
(
error
)
{
errTag
=
(
<
Message
negative
>
<
Message
.
Header
>
{
this
.
props
.
error_message
.
header
}
<
/Message.Header
>
<
p
>
{
this
.
props
.
error_message
.
body
}
<
/p
>
<
Message
.
Header
>
{
error_message
.
header
}
<
/Message.Header
>
<
p
>
{
error_message
.
body
}
<
/p
>
<
/Message
>
);
}
if
(
this
.
props
.
status
!==
undefined
)
{
if
(
status
!==
undefined
)
{
// открываем окно, и закрываем текущее окно
// window.open("avvyland://payment/" + this.props.status)
// window.close()
document
.
location
.
href
=
"
avvyland://payment/
"
+
this
.
props
.
status
;
const
w
=
window
.
open
(
"
avvyland://payment/
"
+
status
,
"
_blank
"
,
"
width=0,height=0
"
);
w
.
close
();
// document.location.href = "avvyland://payment/" + status;
setStatus
(
undefined
);
return
undefined
;
//
return
null
;
}
return
(
...
...
@@ -225,7 +233,7 @@ class PaymentForm extends React.Component {
<
Form
.
Button
fluid
primary
loading
=
{
this
.
props
.
loading
}
loading
=
{
loading
}
onClick
=
{
this
.
handleBeforeSubmit
}
data
-
value
=
{
5
}
>
...
...
@@ -234,7 +242,7 @@ class PaymentForm extends React.Component {
<
Form
.
Button
fluid
primary
loading
=
{
this
.
props
.
loading
}
loading
=
{
loading
}
onClick
=
{
this
.
handleBeforeSubmit
}
data
-
value
=
{
10
}
>
...
...
@@ -243,7 +251,7 @@ class PaymentForm extends React.Component {
<
Form
.
Button
fluid
primary
loading
=
{
this
.
props
.
loading
}
loading
=
{
loading
}
onClick
=
{
this
.
handleBeforeSubmit
}
data
-
value
=
{
50
}
>
...
...
@@ -252,7 +260,7 @@ class PaymentForm extends React.Component {
<
Form
.
Button
fluid
primary
loading
=
{
this
.
props
.
loading
}
loading
=
{
loading
}
onClick
=
{
this
.
handleBeforeSubmit
}
data
-
value
=
{
100
}
>
...
...
@@ -268,7 +276,7 @@ class PaymentForm extends React.Component {
content: "Checkout",
onClick: e => this.handleBeforeSubmit(e)
}}
loading={
this.props.
loading}
loading={loading}
name="amount"
onChange={this.handleChange}
actionPosition="left"
...
...
This diff is collapsed.
Click to expand it.
src/reducers/stripe.js
View file @
4cbbe3c4
...
...
@@ -55,10 +55,10 @@ export const ClearError = () => ({
}
});
//
const ReturnStatus = status => ({
//
type: RETURN_STATUS,
//
payload: status
//
});
export
const
ReturnStatus
=
status
=>
({
type
:
RETURN_STATUS
,
payload
:
status
});
/**
* Устанавливаем текст ошибки
...
...
@@ -110,6 +110,7 @@ export const charge = (userID, jsonData, options) => dispatch => {
response
.
paymentIntent
.
status
===
"
succeeded
"
)
{
// Handle successful payment here
dispatch
(
ReturnStatus
(
response
.
paymentIntent
.
status
));
dispatch
({
type
:
ACTIONS
.
USER
.
ADD_BALANCE
,
payload
:
response
.
paymentIntent
.
amount
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help