Skip to content

Commit 2a6e836

Browse files
committed
Update PRAPI integration
1 parent c4ef34e commit 2a6e836

File tree

4 files changed

+10
-107
lines changed

4 files changed

+10
-107
lines changed

css/example4.css

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -24,79 +24,6 @@
2424
padding: 3px;
2525
}
2626

27-
.example.example4 .amount {
28-
position: relative;
29-
display: -ms-flexbox;
30-
display: flex;
31-
height: 40px;
32-
}
33-
34-
.example.example4 .amount input[type="radio"] {
35-
display: none;
36-
}
37-
38-
.example.example4 .amount input[type="radio"]:checked + label {
39-
color: #fff;
40-
}
41-
42-
.example.example4 .amount input[type="radio"]:checked + label:active {
43-
color: #ffe0f5;
44-
}
45-
46-
.example.example4
47-
.amount
48-
input[type="radio"]:nth-of-type(2):checked
49-
~ .highlight {
50-
transform: translateX(100%);
51-
}
52-
53-
.example.example4
54-
.amount
55-
input[type="radio"]:nth-of-type(3):checked
56-
~ .highlight {
57-
transform: translateX(200%);
58-
}
59-
60-
.example.example4
61-
.amount
62-
input[type="radio"]:nth-of-type(4):checked
63-
~ .highlight {
64-
transform: translateX(300%);
65-
}
66-
67-
.example.example4
68-
.amount
69-
input[type="radio"]:nth-of-type(5):checked
70-
~ .highlight {
71-
transform: translateX(400%);
72-
}
73-
74-
.example.example4 .amount label {
75-
-ms-flex: 1;
76-
flex: 1;
77-
text-align: center;
78-
line-height: 34px;
79-
cursor: pointer;
80-
color: #32325d;
81-
z-index: 1;
82-
transition: color 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
83-
-webkit-tap-highlight-color: transparent;
84-
}
85-
86-
.example.example4 .amount label:active {
87-
color: #8898aa;
88-
}
89-
90-
.example.example4 .amount .highlight {
91-
position: absolute;
92-
width: calc(20% - 1px);
93-
height: calc(100% - 6px);
94-
left: 3px;
95-
border-radius: 2px;
96-
background-color: #d782d9;
97-
transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
98-
}
99-
10027
.example.example4 fieldset {
10128
border-style: none;
10229
padding: 5px;

index.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>Elements: Build beautiful, smart checkout flows</title>
55
<meta name="description" content="Build beautiful, smart checkout flows.">
66

7-
<script src="https://edge-js.stripe.com/v3/"></script>
7+
<script src="https://js.stripe.com/v3/"></script>
88
<script src="js/index.js"></script>
99

1010
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
@@ -219,19 +219,6 @@ <h3 class="title">Payment successful</h3>
219219
<!--Example 4-->
220220
<div class="cell example example4">
221221
<form>
222-
<div class="amount container">
223-
<input id="example4-amount-1" type="radio" name="amount" value="1">
224-
<label for="example4-amount-1">$1</label>
225-
<input id="example4-amount-5" type="radio" name="amount" value="5" checked="">
226-
<label for="example4-amount-5">$5</label>
227-
<input id="example4-amount-20" type="radio" name="amount" value="20">
228-
<label for="example4-amount-20">$20</label>
229-
<input id="example4-amount-50" type="radio" name="amount" value="50">
230-
<label for="example4-amount-50">$50</label>
231-
<input id="example4-amount-100" type="radio" name="amount" value="100">
232-
<label for="example4-amount-100">$100</label>
233-
<div class="highlight"></div>
234-
</div>
235222
<div id="example4-paymentRequest">
236223
<!--Stripe Apple Pay element inserted here-->
237224
</div>

js/example4.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,25 @@
3232
/**
3333
* Payment Request Element
3434
*/
35-
var paymentRequest = stripe._paymentRequestBeta({
35+
var paymentRequest = stripe.paymentRequest({
3636
country: 'US',
3737
currency: 'USD',
3838
total: {
39-
amount:
40-
document.querySelector('.example4 input[name="amount"]:checked').value *
41-
100,
39+
amount: 2000,
4240
label: 'Total',
4341
},
4442
});
45-
var paymentRequestElement = elements.create('_paymentRequestBeta', {
43+
var paymentRequestElement = elements.create('paymentRequestButton', {
4644
paymentRequest: paymentRequest,
4745
style: {
48-
_paymentRequestBeta: {
46+
paymentRequestButton: {
4947
type: 'donate',
5048
},
5149
},
5250
});
5351

54-
document
55-
.querySelector('.example4 input[name="amount"]')
56-
.addEventListener('change', function(ev) {
57-
if (ev.target.checked) {
58-
// TODO: This API is not yet implemented.
59-
// paymentRequest.update({total: ev.target.value});
60-
}
61-
});
62-
6352
paymentRequest.canMakePayment().then(function(result) {
64-
if (result.available) {
53+
if (result) {
6554
document.querySelector('.example4 .card-only').style.display = 'none';
6655
document.querySelector(
6756
'.example4 .payment-request-available'

js/example5.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@
3535
/**
3636
* Payment Request Element
3737
*/
38-
var paymentRequest = stripe._paymentRequestBeta({
38+
var paymentRequest = stripe.paymentRequest({
3939
country: 'US',
4040
currency: 'USD',
4141
total: {
4242
amount: 2500,
4343
label: 'Total',
4444
},
4545
});
46-
var paymentRequestElement = elements.create('_paymentRequestBeta', {
46+
var paymentRequestElement = elements.create('paymentRequestButton', {
4747
paymentRequest: paymentRequest,
4848
style: {
49-
_paymentRequestBeta: {
49+
paymentRequestButton: {
5050
theme: 'light',
5151
},
5252
},
5353
});
5454

5555
paymentRequest.canMakePayment().then(function(result) {
56-
if (result.available) {
56+
if (result) {
5757
document.querySelector('.example5 .card-only').style.display = 'none';
5858
document.querySelector(
5959
'.example5 .payment-request-available'

0 commit comments

Comments
 (0)