-
Notifications
You must be signed in to change notification settings - Fork 8
/
remoteform.stripe.php
52 lines (43 loc) · 1.7 KB
/
remoteform.stripe.php
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
<?php
/**
* Stripe specific functions. Use this file as a model for creating an
* extension for other token-based payment processors.
*/
// Whether or not credit card fields should be included in the form
// sent back to the browser. With STRIPE we no longer use the widget
// so we needs these fields displayed. Return TRUE to include the
// standard CiviCRM cc fields, FALSE to include nothing, or a string
// to include what is returned.
function remoteformstripe_include_cc_fields_in_form() {
return [
'placeholder_stripe_cc_field' => [
'title' => 'Credit Card',
'entity' => 'contribution',
'html' => [
'type' => 'text'
]
]
];
}
function remoteformstripe_extra_js_urls() {
$extraJsUrls = [];
$extraJsUrls[] = Civi::resources()->getUrl('net.ourpowerbase.remoteform', 'remoteform.stripe.js');
$extraJsUrls[] = "https://js.stripe.com/v3/";
return $extraJsUrls;
}
function remoteformstripe_extra_js_params($id) {
$details = remoteform_get_contribution_page_details($id);
$live_id = $details['payment_processor'];
$test_id = $live_id + 1; // Is this right??
$live_key = remoteformstripe_get_public_key($live_id);
$test_key = remoteformstripe_get_public_key($test_id);
return htmlentities(' customInitFunc: initStripe,') . '<br />' .
htmlentities(' customSubmitDataFunc: submitStripe,') . '<br />' .
htmlentities(' customSubmitDataParams: {') . '<br />' .
htmlentities(' apiKey: "' . $live_key . '",') . '<br />' .
htmlentities(' // uncomment for testing: apiKey: "' . $test_key . '",') . '<br />' .
htmlentities(' },') . '<br />';
}
function remoteformstripe_get_public_key($ppid) {
return CRM_Core_Payment_Stripe::getPublicKeyById($ppid);
}