· 6 years ago · May 17, 2019, 11:14 AM
1
2 <script
3 src="https://www.paypal.com/sdk/js?client-id=sb">
4 </script>
5 <script>
6
7
8$.LoadingOverlay("show");
9var site_url="<?=$this->config->base_url();?>";
10var amount="<?php echo $actual_price;?>";
11var actual_alloted_bios="<?php echo $actual_alloted_bios;?>";
12var payment_for_slug="<?php echo $payment_for_slug;?>";
13var user_key_ID="<?php echo $user_key_ID;?>";
14var user_key_email="<?php echo $user_key_email;?>";
15var secret_Key="<?php echo $secret_Key;?>";
16
17
18
19
20 paypal.Button.render({
21 env: 'sandbox', // sandbox | production
22
23
24 style: {
25 label: '',
26 size: 'large', // small | medium | large | responsive
27 shape: 'rect', // pill | rect
28 color: 'gold' , // gold | blue | silver | black
29
30 },
31
32 // PayPal Client IDs - replace with your own
33 // Create a PayPal app: https://developer.paypal.com/developer/applications/create
34
35 client: {
36 sandbox: 'ARZVlfyE6B_xrC7dadJaPs-CtW1ErL2bvq3mJVfKH0HnDXO600FtDHa5V_WxIS1XZ7S62ufl_NRq--CA',
37 },
38
39 payment: function(data, actions) {
40 return actions.payment.create({
41 payment: {
42 transactions: [
43 {
44 amount: { total: amount, currency: 'USD' }
45 }
46 ]
47 }
48 });
49 },
50 onAuthorize: function(data, actions) {
51 return actions.payment.execute().then(function(payment) {
52
53 //console.log(payment);
54 var payment_id = payment.id;
55 $.ajax({
56 type: "POST",
57 url: site_url+'cms/users/payments',
58 enctype: "application/json",
59 data: {payment_details:payment,bio_spaces:actual_alloted_bios,paymentfor:payment_for_slug,user_key_ID:user_key_ID,user_key_email:user_key_email},
60 success: function(data) {
61 $.LoadingOverlay("show");
62 if(data=="pass"){
63 window.location.assign(site_url+"cms/users/auto_submit_login/"+secret_Key);
64 }else{
65 $.LoadingOverlay("hide");
66 window.alert('Sorry, the payment was not successful. Please try again.');
67 }
68
69 }
70
71 });
72
73 });
74 },
75 onCancel: function(data, actions) {
76
77 window.alert('Sorry, cancel the payment. Please try again.');
78
79 }
80 }, '#approval_renewal');
81
82$.LoadingOverlay("hide");
83</script>