Vulcan/packages/vulcan-payments/lib/containers/withCreateCharge.js
2017-05-31 10:25:13 +09:00

30 lines
No EOL
1,006 B
JavaScript

import { graphql } from 'react-apollo';
import gql from 'graphql-tag';
import { getFragment, getFragmentName } from 'meteor/vulcan:core';
export default function withCreateCharge(options) {
const fragment = options.fragment || getFragment(options.fragmentName);
const fragmentName = getFragmentName(fragment) || fragmentName;
const mutation = gql`
mutation createChargeMute($token: JSON, $userId: String, $productKey: String, $associatedCollection: String, $associatedId: String, $properties: JSON) {
createChargeMutation(token: $token, userId: $userId, productKey: $productKey, associatedCollection: $associatedCollection, associatedId: $associatedId, properties: $properties) {
__typename
...${fragmentName}
}
}
${fragment}
`;
return graphql(mutation, {
alias: 'withCreateCharge',
props: ({ownProps, mutate}) => ({
createChargeMutation: (vars) => {
return mutate({
variables: vars,
});
}
}),
});
}