forked from ericdude4/shopifex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contain payment related assets within shopifex
- Loading branch information
Showing
15 changed files
with
8,666 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ erl_crash.dump | |
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
shopifex-*.tar | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import "react-phoenix" | ||
|
||
import React from 'react' | ||
// import ReactDOM from 'react-dom' | ||
import { AppProvider } from '@shopify/polaris' | ||
import enTranslations from '@shopify/polaris/locales/en.json' | ||
import '@shopify/polaris/styles.css' | ||
|
||
import ShowPlans from './components/show-plans' | ||
|
||
function WrappedShowPlans(props) { | ||
return ( | ||
<AppProvider i18n={enTranslations}> | ||
<ShowPlans plans={props.plans} guard={props.guard} shopUrl={props.shop_url} shopifyApiKey={props.shopify_api_key}/> | ||
</AppProvider> | ||
) | ||
} | ||
|
||
window.Components = { | ||
WrappedShowPlans | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { Component } from 'react' | ||
import { | ||
Card, | ||
Page, | ||
List, | ||
Layout | ||
} from '@shopify/polaris' | ||
import axios from 'axios' | ||
import createApp from '@shopify/app-bridge' | ||
import { Redirect } from '@shopify/app-bridge/actions' | ||
|
||
export default class ShowPlans extends React.Component { | ||
constructor(props) { | ||
super(props) | ||
const app = createApp({ | ||
apiKey: props.shopifyApiKey, | ||
shopOrigin: props.shopUrl, | ||
}) | ||
const redirect = Redirect.create(app); | ||
this.state = {redirect: redirect} | ||
} | ||
|
||
selectPlan(plan) { | ||
let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content') | ||
axios.post | ||
( | ||
"/payment/select-plan", | ||
{ | ||
plan_id: plan.id, | ||
redirect_after: this.props.redirectAfter | ||
}, | ||
{ | ||
headers: { "x-csrf-token": csrfToken } | ||
} | ||
) | ||
.then(resp => { | ||
this.state.redirect.dispatch(Redirect.Action.REMOTE, resp.data.recurring_application_charge.confirmation_url) | ||
}) | ||
} | ||
|
||
render() { | ||
let cards = [] | ||
for (let i = 0; i < this.props.plans.length; i++) { | ||
let plan = this.props.plans[i] | ||
let features = [] | ||
for (let j = 0; j < plan.features.length; j++) { | ||
let feature = plan.features[j] | ||
features.push(<List.Item key={"card" + i + "list" + j}>{feature}</List.Item>) | ||
} | ||
cards.push( | ||
<Layout.Section oneThird key={"card" + i}> | ||
<Card | ||
title={`${plan.name}`} | ||
primaryFooterAction={{ | ||
content: 'Select', | ||
loading: this.loading, | ||
onClick: () => { | ||
this.loading = true | ||
this.selectPlan(plan) | ||
} | ||
}} | ||
> | ||
<Card.Section> | ||
<h1 style={{ fontSize: "30px", marginBottom: "25px" }}>${plan.price}/month</h1> | ||
<List> | ||
{features} | ||
</List> | ||
</Card.Section> | ||
</Card> | ||
</Layout.Section> | ||
) | ||
} | ||
return <Page | ||
fullWidth | ||
title="Payment required to access this feature" | ||
> | ||
<Layout> | ||
{cards} | ||
</Layout> | ||
</Page>; | ||
} | ||
} |
Oops, something went wrong.