-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment_code
79 lines (57 loc) · 1.73 KB
/
payment_code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
ADD THIS TO INDEX.HTML:
<script src="https://js.stripe.com/v3/"></script>
PAYMENT FUNCTION:
declare var Stripe;
var stripe1 = Stripe('pk_test_bwrO9Y04SX335bjByq2M11jK');
var elements = stripe1.elements();
var style = {
base: {
// Add your base input styles here. For example:
fontSize: '16px',
color: "#32325d",
}
};
// Create an instance of the card Element.
var card = elements.create('card', {style: style});
paymentButton2(){
var form = document.getElementById('payment-form');
var ownerInfo = {
owner: {
name: 'Jenny Rosen',
address: {
line1: 'Nollendorfstraße 27',
city: 'Berlin',
postal_code: '10777',
country: 'DE',
},
email: '[email protected]'
},
};
form.addEventListener('submit', function(event) {
event.preventDefault();
stripe1.createSource(card, ownerInfo).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
console.log(JSON.stringify(result.source));
}
});
});
}
PAYMENT UI:
<form action="/charge" method="post" id="payment-form" style="padding:100px; color: white;">
<div class="form-row">
<label for="card-element">
Credit or debit card
</label>
<div id="card-element">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display Element errors. -->
<div id="card-errors" role="alert"></div>
</div>
<button ion-button color="primary" (click)="paymentButton2()">Submit Payment</button>
</form>