mirror of
				https://github.com/KevinMidboe/planetposen-frontend.git
				synced 2025-10-29 13:10:12 +00:00 
			
		
		
		
	Moved applePay & vipps components to /unused folder
This commit is contained in:
		| @@ -1,85 +1,89 @@ | ||||
| <script lang="ts"> | ||||
|   function getApplePaySession(validationURL: string) { | ||||
|     const options = { | ||||
|       method: 'POST', | ||||
|       headers: { | ||||
|         'Content-Type': 'application/json' | ||||
|       }, | ||||
|       body: JSON.stringify({ validationURL }) | ||||
|     }; | ||||
|   // function getApplePaySession(validationURL: string) { | ||||
|   //   const options = { | ||||
|   //     method: 'POST', | ||||
|   //     headers: { | ||||
|   //       'Content-Type': 'application/json' | ||||
|   //     }, | ||||
|   //     body: JSON.stringify({ validationURL }) | ||||
|   //   }; | ||||
| 
 | ||||
|     return fetch('/api/applepay/validateSession', options).then((resp) => resp.json()); | ||||
|   } | ||||
|   //   return fetch('/api/applepay/validateSession', options).then((resp) => resp.json()); | ||||
|   // } | ||||
| 
 | ||||
|   function makeApplePayPaymentTransaction(payment: object) { | ||||
|     const options = { | ||||
|       method: 'POST', | ||||
|       headers: { | ||||
|         'Content-Type': 'application/json' | ||||
|       }, | ||||
|       body: JSON.stringify({ payment }) | ||||
|     }; | ||||
|   // function makeApplePayPaymentTransaction(payment: object) { | ||||
|   //   const options = { | ||||
|   //     method: 'POST', | ||||
|   //     headers: { | ||||
|   //       'Content-Type': 'application/json' | ||||
|   //     }, | ||||
|   //     body: JSON.stringify({ payment }) | ||||
|   //   }; | ||||
| 
 | ||||
|     return fetch('/api/applepay/pay', options).then((resp) => resp.json()); | ||||
|   } | ||||
|   //   return fetch('/api/applepay/pay', options).then((resp) => resp.json()); | ||||
|   // } | ||||
| 
 | ||||
|   function createPaymentRequest() { | ||||
|     const paymentRequest = { | ||||
|       countryCode: 'NO', | ||||
|       currencyCode: 'NOK', | ||||
|       shippingMethods: [ | ||||
|         { | ||||
|           label: 'Free Shipping', | ||||
|           amount: 0.0, | ||||
|           identifier: 'free', | ||||
|           detail: 'Delivers in five business days' | ||||
|         }, | ||||
|         { | ||||
|           label: 'Express Shipping', | ||||
|           amount: 5.0, | ||||
|           identifier: 'express', | ||||
|           detail: 'Delivers in two business days' | ||||
|     return true; | ||||
|   } | ||||
|       ], | ||||
|       lineItems: [ | ||||
|         { | ||||
|           label: 'Shipping', | ||||
|           amount: 0.0 | ||||
|         } | ||||
|       ], | ||||
|       total: { | ||||
|         label: 'Apple Pay Example', | ||||
|         amount: 8.99 | ||||
|       }, | ||||
|       supportedNetworks: ['amex', 'discover', 'masterCard', 'visa'], | ||||
|       merchantCapabilities: ['supports3DS'], | ||||
|       requiredShippingContactFields: ['postalAddress', 'email'] | ||||
|     }; | ||||
| 
 | ||||
|     const session = new ApplePaySession(6, paymentRequest); | ||||
|   // function createPaymentRequest() { | ||||
|   //   const paymentRequest = { | ||||
|   //     countryCode: 'NO', | ||||
|   //     currencyCode: 'NOK', | ||||
|   //     shippingMethods: [ | ||||
|   //       { | ||||
|   //         label: 'Free Shipping', | ||||
|   //         amount: 0.0, | ||||
|   //         identifier: 'free', | ||||
|   //         detail: 'Delivers in five business days' | ||||
|   //       }, | ||||
|   //       { | ||||
|   //         label: 'Express Shipping', | ||||
|   //         amount: 5.0, | ||||
|   //         identifier: 'express', | ||||
|   //         detail: 'Delivers in two business days' | ||||
|   //       } | ||||
|   //     ], | ||||
|   //     lineItems: [ | ||||
|   //       { | ||||
|   //         label: 'Shipping', | ||||
|   //         amount: 0.0 | ||||
|   //       } | ||||
|   //     ], | ||||
|   //     total: { | ||||
|   //       label: 'Apple Pay Example', | ||||
|   //       amount: 8.99 | ||||
|   //     }, | ||||
|   //     supportedNetworks: ['amex', 'discover', 'masterCard', 'visa'], | ||||
|   //     merchantCapabilities: ['supports3DS'], | ||||
|   //     requiredShippingContactFields: ['postalAddress', 'email'] | ||||
|   //   }; | ||||
| 
 | ||||
|     session.onvalidatemerchant = (event) => { | ||||
|       console.log('Validate merchante'); | ||||
|       console.log('event: ', event); | ||||
|   //   const session = new ApplePaySession(6, paymentRequest); | ||||
| 
 | ||||
|       const validationURL = event.validationURL; | ||||
|       this.getApplePaySession(validationURL).then((response) => { | ||||
|         console.log('response from getApplePaySession:', response); | ||||
|         session.completeMerchantValidation(response); | ||||
|       }); | ||||
|     }; | ||||
|   //   session.onvalidatemerchant = (event) => { | ||||
|   //     console.log('Validate merchante'); | ||||
|   //     console.log('event: ', event); | ||||
| 
 | ||||
|     session.onpaymentauthorized = (event) => { | ||||
|       this.makeApplePayPaymentTransaction(event.payment).then((response) => { | ||||
|         console.log('response from pay:', response); | ||||
|   //     const validationURL = event.validationURL; | ||||
|   //     this.getApplePaySession(validationURL).then((response) => { | ||||
|   //       console.log('response from getApplePaySession:', response); | ||||
|   //       session.completeMerchantValidation(response); | ||||
|   //     }); | ||||
|   //   }; | ||||
| 
 | ||||
|         if (response.approved) session.completePayment(ApplePaySession.STATUS_SUCCESS); | ||||
|         else session.completePayment(ApplePaySession.STATUS_FAILURE); | ||||
|       }); | ||||
|     }; | ||||
|   //   session.onpaymentauthorized = (event) => { | ||||
|   //     this.makeApplePayPaymentTransaction(event.payment).then((response) => { | ||||
|   //       console.log('response from pay:', response); | ||||
| 
 | ||||
|     session.begin(); | ||||
|   } | ||||
|   //       if (response.approved) session.completePayment(ApplePaySession.STATUS_SUCCESS); | ||||
|   //       else session.completePayment(ApplePaySession.STATUS_FAILURE); | ||||
|   //     }); | ||||
|   //   }; | ||||
| 
 | ||||
|   //   session.begin(); | ||||
|   // } | ||||
| </script> | ||||
| 
 | ||||
| <div | ||||
		Reference in New Issue
	
	Block a user