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">
|
<script lang="ts">
|
||||||
function getApplePaySession(validationURL: string) {
|
// function getApplePaySession(validationURL: string) {
|
||||||
const options = {
|
// const options = {
|
||||||
method: 'POST',
|
// method: 'POST',
|
||||||
headers: {
|
// headers: {
|
||||||
'Content-Type': 'application/json'
|
// 'Content-Type': 'application/json'
|
||||||
},
|
// },
|
||||||
body: JSON.stringify({ validationURL })
|
// 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) {
|
// function makeApplePayPaymentTransaction(payment: object) {
|
||||||
const options = {
|
// const options = {
|
||||||
method: 'POST',
|
// method: 'POST',
|
||||||
headers: {
|
// headers: {
|
||||||
'Content-Type': 'application/json'
|
// 'Content-Type': 'application/json'
|
||||||
},
|
// },
|
||||||
body: JSON.stringify({ payment })
|
// 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() {
|
function createPaymentRequest() {
|
||||||
const paymentRequest = {
|
return true;
|
||||||
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']
|
|
||||||
};
|
|
||||||
|
|
||||||
const session = new ApplePaySession(6, paymentRequest);
|
|
||||||
|
|
||||||
session.onvalidatemerchant = (event) => {
|
|
||||||
console.log('Validate merchante');
|
|
||||||
console.log('event: ', event);
|
|
||||||
|
|
||||||
const validationURL = event.validationURL;
|
|
||||||
this.getApplePaySession(validationURL).then((response) => {
|
|
||||||
console.log('response from getApplePaySession:', response);
|
|
||||||
session.completeMerchantValidation(response);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
session.onpaymentauthorized = (event) => {
|
|
||||||
this.makeApplePayPaymentTransaction(event.payment).then((response) => {
|
|
||||||
console.log('response from pay:', response);
|
|
||||||
|
|
||||||
if (response.approved) session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
|
||||||
else session.completePayment(ApplePaySession.STATUS_FAILURE);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
session.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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']
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const session = new ApplePaySession(6, paymentRequest);
|
||||||
|
|
||||||
|
// session.onvalidatemerchant = (event) => {
|
||||||
|
// console.log('Validate merchante');
|
||||||
|
// console.log('event: ', event);
|
||||||
|
|
||||||
|
// const validationURL = event.validationURL;
|
||||||
|
// this.getApplePaySession(validationURL).then((response) => {
|
||||||
|
// console.log('response from getApplePaySession:', response);
|
||||||
|
// session.completeMerchantValidation(response);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// session.onpaymentauthorized = (event) => {
|
||||||
|
// this.makeApplePayPaymentTransaction(event.payment).then((response) => {
|
||||||
|
// console.log('response from pay:', response);
|
||||||
|
|
||||||
|
// if (response.approved) session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
||||||
|
// else session.completePayment(ApplePaySession.STATUS_FAILURE);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// session.begin();
|
||||||
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
Reference in New Issue
Block a user