solution/app/scripts/modules/payment-api.js
/*
  * Given a cart set up with an order, gets payment authorization.
  * Returns a promise that resolves when payment is complete, this
  * has a data object you can pass to the back-end payment server.
  */
Given a cart set up with an order, gets payment authorization.
Returns a promise that resolves when payment is complete, this
has a data object you can pass to the back-end payment server.
Given a cart set up with an order gets payment authorization . Returns a promise that resolves when payment is complete this has a data object you can pass to the back - end payment server .
checkout(cart) {
    let request = this.buildPaymentRequest(cart);
    let response;
    return request.show()
      .then(r => {
        response = r;
        var data = this.copy(response, 'methodName', 'details', 'payerEmail',
          'payerPhone', 'shippingOption');
        data.address = this.copy(response.shippingAddress, 'country', 'region',
          'city', 'dependentLocality', 'addressLine', 'postalCode',
          'sortingCode', 'languageCode', 'organization', 'recipient', 'careOf',
          'phone');
        return data;
      })
      .then(sendToServer)
      .then(() => {
        response.complete('success');
      })
      .catch(e => {
        if (response) response.complete(`fail: ${e}`);
      });
  }
checkout ( cart ) { let request = this . buildPaymentRequest ( cart ) ; let response ; return request . show ( ) . then ( r => { response = r ; var data = this . copy ( response , 'methodName' , 'details' , 'payerEmail' , 'payerPhone' , 'shippingOption' ) ; data . address = this . copy ( response . shippingAddress , 'country' , 'region' , 'city' , 'dependentLocality' , 'addressLine' , 'postalCode' , 'sortingCode' , 'languageCode' , 'organization' , 'recipient' , 'careOf' , 'phone' ) ; return data ; } ) . then ( sendToServer ) . then ( ( ) => { response . complete ( 'success' ) ; } ) . catch ( e => { if ( response ) response . complete ( ` ${ e } ` ) ; } ) ; }
Given a cart set up with an order, gets payment authorization.
Given a cart set up with an order gets payment authorization .
// Show UI then continue with user payment info // Extract just the details we want to send to the server