Skip to content
This repository has been archived by the owner on Mar 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #50 from khoanguyen96/bugfix/execute-on-commit-only
Browse files Browse the repository at this point in the history
execute on commit only
  • Loading branch information
cocoastorm authored Jun 21, 2018
2 parents 7894db7 + 262c7ea commit f93b15f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/components/PayPalCheckout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ export default {
onAuthorize(data, actions) {
const vue = this;
vue.$emit('payment-authorized', data);
return actions.payment.execute().then((response) => {
vue.$emit('payment-completed', response);
});
if (this.commit) {
return actions.payment.execute().then((response) => {
vue.$emit('payment-completed', response);
});
}
return true;
},
onCancel(data) {
const vue = this;
Expand Down
4 changes: 3 additions & 1 deletion src/util/defaultProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const specificProps = [
name: 'details',
type: Object,
required: false,
default: {},
default() {
return {};
},
},
{
name: 'commit',
Expand Down
10 changes: 10 additions & 0 deletions test/unit/specs/components/SimpleMethods.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,15 @@ describe('Methods within PayPalCheckout.vue', () => {
onCancel: expect.any(Function),
}));
});

it('onAuthorize() returns true and not a promise if commit is false', () => {
const component = shallow(PayPalCheckout, {
localVue,
attachToDocument: true,
propsData: { ...getProps(), commit: false },
});

expect(component.vm.onAuthorize()).toEqual(true);
});
});
});

0 comments on commit f93b15f

Please sign in to comment.