Advertisement
Guest User

Untitled

a guest
May 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. <template>
  2. <form>
  3. <!-- <div class="form-group">
  4. <label for="cc-number" class="control-label">Card Number</label>
  5. <div id="cc-number" class="form-control input-lg" data-braintree-class="braintree-input"></div>
  6. </div> -->
  7.  
  8. <form-input name="cc-number" label="Card Number" :hasError="hasError" :hasSuccess="hasSuccess"></form-input>
  9. </form>
  10. </template>
  11.  
  12. <script>
  13. export default {
  14. props: {
  15. clientInstance: {
  16. required: true,
  17. type: Object
  18. }
  19. },
  20. components: {
  21. formInput: require('@/components/paymentmethod/form-input.vue').default
  22. },
  23. data: function () {
  24. return {
  25. hasError: true,
  26. hasSuccess: false,
  27. working: '',
  28. loadingStatus: ''
  29. }
  30. },
  31. methods: {
  32. createCard: function () {
  33. let clientInstance = this.clientInstance;
  34.  
  35. this.working = true;
  36. this.loadingStatus = 'Generating secure card fields...'
  37.  
  38. window.braintree.hostedFields.create({
  39. client: clientInstance,
  40. styles: {
  41. 'input': {
  42. 'font-size': '14px',
  43. 'border':'none'
  44. },
  45. 'input.invalid': {
  46. 'color': 'red'
  47. },
  48. 'input.valid': {
  49. 'color': 'green'
  50. }
  51. },
  52. fields: {
  53. number: {
  54. selector: '#cc-number',
  55. placeholder: '4111 1111 1111 1111'
  56. },
  57. // cvv: {
  58. // selector: '#cvv',
  59. // placeholder: '123'
  60. // },
  61. // expirationDate: {
  62. // selector: '#expiration-date',
  63. // placeholder: '10/2019'
  64. // }
  65. }
  66. }, (hostedFieldsError, hostedFieldsInstance) => {
  67. if ( hostedFieldsError ) {
  68. console.error(hostedFieldsError);
  69. return;
  70. }
  71.  
  72. // this.working = false;
  73. })
  74. }
  75. },
  76. watch: {
  77. working: function (newWork) {
  78. this.$emit('working', newWork);
  79. },
  80. loadingStatus: function (status) {
  81. this.$emit('loadingStatus', status);
  82. }
  83. },
  84. created: function () {
  85. this.createCard()
  86. }
  87. }
  88. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement