-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher J Baker
committed
Nov 12, 2024
1 parent
4bdc66c
commit 9d58a1d
Showing
5 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@import url("../common/theme/index.css"); | ||
|
||
#pay { | ||
display: block; | ||
margin: 0 auto; | ||
font-size: 1.5em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import "../common/sandbox-header.js" | ||
|
||
const payEl = document.getElementById("pay") | ||
payEl.style.display = "" | ||
|
||
payEl.addEventListener("click", async () => { | ||
requestPayment() | ||
}) | ||
|
||
async function requestPayment() { | ||
const request = new PaymentRequest( | ||
[ | ||
{ | ||
supportedMethods: "https://google.com/pay", | ||
data: { | ||
environment: "TEST", | ||
apiVersion: 2, | ||
apiVersionMinor: 0, | ||
merchantInfo: { | ||
merchantName: "Example Merchant", | ||
}, | ||
allowedPaymentMethods: [ | ||
{ | ||
type: "CARD", | ||
parameters: { | ||
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"], | ||
allowedCardNetworks: [ | ||
"AMEX", | ||
"DISCOVER", | ||
"INTERAC", | ||
"JCB", | ||
"MASTERCARD", | ||
"VISA", | ||
], | ||
}, | ||
tokenizationSpecification: { | ||
type: "PAYMENT_GATEWAY", | ||
// Check with your payment gateway on the parameters to pass. | ||
// @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway} | ||
parameters: { | ||
gateway: "example", | ||
gatewayMerchantId: "exampleGatewayMerchantId", | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
supportedMethods: "https://apple.com/apple-pay", | ||
data: { | ||
version: 3, | ||
merchantIdentifier: "merchant.com.example", | ||
merchantCapabilities: [ | ||
"supports3DS", | ||
"supportsCredit", | ||
"supportsDebit", | ||
], | ||
supportedNetworks: ["amex", "discover", "masterCard", "visa"], | ||
countryCode: "US", | ||
}, | ||
}, | ||
], | ||
{ | ||
id: "order-123", | ||
displayItems: [ | ||
{ | ||
label: "Example item", | ||
amount: { currency: "USD", value: "1.00" }, | ||
}, | ||
], | ||
total: { | ||
label: "Total", | ||
amount: { currency: "USD", value: "1.00" }, | ||
}, | ||
}, | ||
{ | ||
requestPayerName: true, | ||
requestPayerEmail: true, | ||
requestPayerPhone: true, | ||
}, | ||
) | ||
|
||
if (!(await request.canMakePayment())) { | ||
alert("No supported payment methods.") | ||
return | ||
} | ||
|
||
await request | ||
.show() | ||
.then((response) => response.complete("fail")) | ||
.catch((error) => alert(error)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Checkout | Bitovi PWA Sandbox</title> | ||
<link rel="manifest" href="../manifest.json" /> | ||
|
||
<link type="text/css" rel="stylesheet" href="./checkout.css" /> | ||
</head> | ||
<body> | ||
<sandbox-header share-title="PWA Checkout"></sandbox-header> | ||
|
||
<button id="pay">Pay Now</button> | ||
|
||
<script type="module" src="./checkout.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters