Sun Sep 03 2017
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
<template>

    <main class="container">
        <header>
          <h3>&mdash; Checkout &mdash;</h3>
          <p>Your total is only {{total}}</p>        
        </header>
      
     
        <div>
          <v-stepper v-model="e1" class='checkout-stepper'>
            <v-stepper-header>
              <v-stepper-step step="1" :complete="e1 > 1">
                Guest's Name
                <small>(optional)</small>
              </v-stepper-step>

              <v-divider></v-divider>

              <v-stepper-step step="2" :complete="e1 > 2">
                Shipping Address
              </v-stepper-step>

              <v-divider></v-divider>

              <v-stepper-step step="3">
                Checkout
              </v-stepper-step>
            </v-stepper-header>

            <v-stepper-content step="1">
              <div>                
                <v-text-field    
                  placeholder="Enter guest's name here (optional)"
                  class="input-group">            
                </v-text-field>
                <p>
                  This is optional, and free of charge.
                </p>
                <p>
                  If you enter your guest's name, the crate will say "Welcome, <i>(name of guest)</i>"
                </p>
              </div>
              <v-btn primary @click.native="e1 = 2">Continue</v-btn>
            </v-stepper-content>

            <v-stepper-content step="2">
              <div>
                <p>
                  Where are we shipping to?
                </p>
                <p>
                  <small>
                    Tip: If you can't make it to your property to leave the crate
                    inside, you can have it shipped directly to the property
                    and let the guests know that there is a package for them
                    at the door when they arrive!
                  </small>
                </p>

                <v-layout row>          
                  <v-card flat>
                    <v-card-text>
                      <v-text-field    
                        label="Name"
                        class="input-group">            
                      </v-text-field>
                    </v-card-text>
                  </v-card>        
                </v-layout>

                <v-layout row-sm column child-flex-sm>          
                  <v-card flat>
                    <v-card-text>
                      <v-text-field    
                        label="Address"
                        class="input-group">            
                      </v-text-field>
                    </v-card-text>
                  </v-card>
                   <v-card flat>
                    <v-card-text>
                      <v-text-field    
                        label="City"
                        class="input-group">            
                      </v-text-field>
                    </v-card-text>
                  </v-card>       
                  <v-card flat>
                    <v-card-text>
                      <v-text-field    
                        label="State"
                        class="input-group">            
                      </v-text-field>
                    </v-card-text>
                  </v-card>        
                   <v-card flat>
                    <v-card-text>
                      <v-text-field    
                        label="Zip"
                        class="input-group">            
                      </v-text-field>
                    </v-card-text>
                  </v-card>        
                </v-layout>
              </div>
              <v-btn flat accent @click.native="e1 = 1">Back</v-btn>
              <v-btn primary @click.native="e1 = 3">Continue</v-btn>
            </v-stepper-content>

            <v-stepper-content step="3">
                <h5>Choose a payment method</h5>     
                <v-layout row-sm column>

                  <!--  cc -->
                  <v-flex  order-xs3 order-sm1>
                    <v-card flat class="ma-1 payment-option">
                      <v-card-text>
                        <v-card flat>
                          <v-card-text class='payment-icons'>
                            <img src="/icons/payments/visa.png" alt="">
                            <img src="/icons/payments/mastercard.png" alt="">
                            <img src="/icons/payments/americanexpress.png" alt="">
                            <img src="/icons/payments/discover.png" alt="">
                          </v-card-text>
                        </v-card>
                        <v-card flat>
                          <v-card-text>
                            <v-text-field    
                              label="Name on Card"
                              class="input-group">            
                            </v-text-field>
                          </v-card-text>
                        </v-card>
                         <v-card flat>
                          <v-card-text>
                            <v-text-field    
                              label="Card Number"
                              class="input-group">            
                            </v-text-field>
                          </v-card-text>
                        </v-card>
                       
                        <v-layout row wrap>   
                          <v-flex xs12 sm4 md4>
                            <v-card flat>
                              <v-card flat>
                                <v-card-text>
                                  <v-text-field    
                                    label="Expiry Date"
                                    class="input-group">            
                                  </v-text-field>
                                </v-card-text>
                              </v-card>
                            </v-card>
                          </v-flex>
                          <v-flex xs12 sm4 md4>
                            <v-card flat>
                              <v-card flat>
                                <v-card-text>
                                  <v-text-field    
                                    label="Billing Zip"
                                    class="input-group">            
                                  </v-text-field>
                                </v-card-text>
                              </v-card>
                            </v-card>
                          </v-flex>
                          <v-flex xs12 sm4 md4>
                            <v-card flat>
                              <v-card-text>
                                <v-text-field    
                                  label="Security Code"
                                  class="input-group">            
                                </v-text-field>
                              </v-card-text>
                            </v-card> 
                          </v-flex>   
                        </v-layout>                       
                         
                        <v-btn block primary large class="white--text">
                          <v-icon left dark>lock</v-icon>PAY                        
                        </v-btn>
                      </v-card-text>
                    </v-card>
                  </v-flex>
                  <!-- /cc -->
                  
                  <!-- Paypal -->
                  <v-flex  order-xs1>
                    <v-card  flat class="ma-1 payment-option" order-xs1 order-sm2>
                      <v-card-text>
                        <img class='paypal' src="https://ee-screenshots.s3.amazonaws.com/2016/08/paypal-express-checkout-logo.png" alt="">
                      </v-card-text>
                    </v-card>
                  </v-flex>
                  <!-- /paypal -->
                  
                </v-layout>

                <!-- <v-layout>
                  <v-flex>
                    <v-card flat>
                      <v-card-text>
                        <v-btn accent @click.native="e1 = 2">Back</v-btn>
                      </v-card-text>
                    </v-card>
                  </v-flex>
                </v-layout> -->

            </v-stepper-content>
          </v-stepper>  
        </div>   

        
    </main>

</template>

<script>
import axios from 'axios'

export default {
  layout: 'default',
  data () {
    return {
      e1: 0,
      isSubmitting: false,
      guestName: null,
      email: null,
      shipping: {
        name: null,
        address: null,
        address2: null,
        city: null,
        state: null,
        zip: null,
        country: 'us'
      },
      creditCard: {
        name: null,
        number: null,
        exp: null,
        cvv: null,
        zip: null,
        country: 'us'
      },
      //billingAddressSameAsShipping: true
    }
  },

  computed: {
    total()
    {
      var crates = this.$store.state.crates
      return Object.keys(this.$store.state.crates)
        .map(e => crates[e].price * crates[e].quantity)
        .reduce((acc,cv) => acc + cv)
    }
  },
  methods: {
    handleCreditCardSubmit()
    {

      //const formdata = new FormData()
      //formdata.append('name', name)
      

      this.isSubmitting = true
      axios.post('/api/checkout', {
        guestName: this.guestName,
        shipping: this.shipping,
        crates: this.$store.state.crates, //[{name: 'smiley crate', quantity: 2}],
        paymentMethod: {type: 'credit card', info: this.creditCard}
      })
      .then( response => {
        if (response.data.result == 'success')
        {
          this.$router.replace('/checkout/complete')
        }
        this.isSubmitting = false
      })
      .catch(error => {
        console.log(error);
        this.isSubmitting = false
      });
    }
  }
}
</script>

<style lang='stylus'>
@import '~assets/css/variables'

  
// .stepper__header
//   background white

.stepper__wrapper > div
  font-size 1.3em

.card.payment-option
  border 3px solid #eee
  height 100%!important
  
  &:hover
    border-color #999

.checkout-stepper
  h5
    text-align center
    padding 0.7em 0

.payment-icons
  text-align center
  img
    display inline-block
    margin-left 10px
  
img.paypal
  width 50%
  display block
  margin 0 auto
</style>