Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9249b80cb6 | ||
|
|
cc5b9518e4 | ||
|
|
f6cd67ed0d |
No files matched your search
@@ -30,6 +30,11 @@ You need two values from PayPal: a **Client ID** and a **Secret**.
|
||||
Start in **Sandbox**, make a test donation using a PayPal sandbox buyer account, then repeat the steps
|
||||
with the Live credentials and switch the mode to Live in Settings.
|
||||
|
||||
### Behind Cloudflare?
|
||||
Nothing to do: the plugin recognises Cloudflare automatically (by its published addresses) so each visitor is rate
|
||||
limited separately. For another proxy, choose it in StreamGoals > Settings > Advanced; the panel there shows what your
|
||||
server sees.
|
||||
|
||||
### Notes on fees and currency
|
||||
- "Cover the processing fees" adds an estimate based on the rates in Settings (default: US domestic,
|
||||
3.49% + $0.49). Your actual PayPal rate depends on your account, country and payment method.
|
||||
@@ -51,6 +56,19 @@ with the Live credentials and switch the mode to Live in Settings.
|
||||
form, as a **Rewards menu** overlay for OBS, and as a highlighted line in the donation alert. Triggered rewards land in a
|
||||
**queue** on the Rewards screen so you can tick them off as you do them. Rewards count the donation amount, not the
|
||||
optional fee cover, and must be at least your minimum donation.
|
||||
- **Alerts with pictures, GIFs, videos and sounds:** StreamGoals > Alerts. Pick files from your WordPress Media Library
|
||||
(PNG, JPEG, GIF, WebP, MP4, WebM for the picture/video; MP3, OGG, WAV for sound). Tie an alert to **a donation size**
|
||||
("any donation of at least $5": the highest matching amount wins) or to **a reward** (a reward alert beats an amount
|
||||
alert). Set the volume, how long a picture stays, and a message using `{name}`, `{amount}` and `{reward}`. In OBS media
|
||||
plays automatically; in an ordinary browser tab click the page once before sound is allowed. Keep files small (videos
|
||||
under about 25 MB). If a file is deleted the alert still shows, just without it.
|
||||
- **Tiers (milestones):** on the Goals screen use **Tiers** to turn one goal into a ladder, for example $100 "Giveaway",
|
||||
$250 "New microphone", $500 "24-hour stream". The goal bar shows the current tier and fills within it; unlocking a tier
|
||||
shows a **TIER UNLOCKED** line in the alert and the bar moves on to the next one. The goal's final target is your highest
|
||||
tier. The donation form shows "Next unlock: ... to go".
|
||||
- **End at target:** tick "Close this goal to donations when the target is reached" on a goal. When the total reaches or
|
||||
passes the target (for a tiered goal, the final tier) the goal closes and the donation page says so. Donations already
|
||||
in checkout still go through. Use **Reopen** after raising the target.
|
||||
- **Test:** "Send test donation" on the Overlays screen shows an alert without touching real totals.
|
||||
|
||||
## Privacy and moderation
|
||||
|
||||
@@ -47,7 +47,12 @@
|
||||
/* Phones: wide tables scroll inside their own box instead of pushing the page; controls never exceed the card. */
|
||||
@media (max-width: 782px) {
|
||||
.sg-admin table.sg-table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
|
||||
.sg-admin .sg-table th, .sg-admin .sg-table td { min-width: 4.5em; }
|
||||
.sg-admin .sg-table th, .sg-admin .sg-table td { min-width: 3em; padding: 8px 6px; font-size: 13px; }
|
||||
.sg-admin .sg-table code { overflow-wrap: anywhere; word-break: break-all; font-size: 12px; }
|
||||
.sg-admin .sg-table td:last-child .button { margin: 0 4px 4px 0; }
|
||||
.sg-admin .sg-card details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
|
||||
.sg-admin .sg-card label > input[type="radio"], .sg-admin .sg-card label > input[type="checkbox"] { margin-right: 6px; }
|
||||
.sg-admin .sg-card p > label + .description, .sg-admin .sg-card p > label { display: inline-block; margin: 4px 0; }
|
||||
.sg-admin select, .sg-admin input[type="text"], .sg-admin input[type="url"], .sg-admin input[type="number"], .sg-admin textarea { max-width: 100%; box-sizing: border-box; }
|
||||
.sg-admin .sg-card { padding-left: 14px; padding-right: 14px; }
|
||||
}
|
||||
@@ -11,3 +11,13 @@
|
||||
.sga-alert-head{font-weight:800;font-size:1.2em}
|
||||
.sga-alert-head b{color:#22d3ee}
|
||||
.sga-idle{color:#bbb;font-size:14px;align-self:center}
|
||||
|
||||
/* Phones: radio rows breathe, slider fills the width, preview stage scales and never overflows. */
|
||||
@media (max-width:782px){
|
||||
.sga-form label{display:inline-block;margin:6px 0;min-height:32px}
|
||||
.sga-form input[type=range]{width:100%;min-height:32px}
|
||||
.sga-stage{min-height:120px;padding:10px;font-size:16px;overflow:hidden;box-sizing:border-box;max-width:100%}
|
||||
.sga-alert{box-sizing:border-box}
|
||||
.sga-alert-media img,.sga-alert-media video{max-height:180px}
|
||||
.sga-media .button{min-height:40px}
|
||||
}
|
||||
@@ -38,3 +38,7 @@
|
||||
|
||||
.sg-donate .sg-next-unlock{margin:0 0 .9rem;padding:.5rem .75rem;border:1px solid rgba(128,128,128,.5);border-left-width:4px;border-radius:.4rem;font-weight:600;line-height:1.4;overflow-wrap:anywhere}
|
||||
.sg-donate .sg-next-unlock[hidden]{display:none}
|
||||
.sg-donate .sg-presets button.sg-action{padding-right:2.2em}
|
||||
.sg-donate .sg-presets.sg-actions{padding:0 5px}
|
||||
|
||||
.sg-donate .sg-notice{margin:.6rem 0 0;font-size:.9em;line-height:1.4;opacity:.85;overflow-wrap:anywhere}
|
||||
@@ -121,6 +121,7 @@
|
||||
root.appendChild(row([total]));
|
||||
root.appendChild(status); // messages sit above the PayPal buttons, next to the form fields
|
||||
root.appendChild(buttons);
|
||||
if (C.notice) { root.appendChild(el('p', { 'class': 'sg-notice', text: String(C.notice) })); } // e.g. "Donations are non-refundable." right where the donor pays
|
||||
|
||||
function say(text, cls) { status.textContent = text || ''; status.className = 'sg-msg' + (cls ? ' ' + cls : ''); }
|
||||
function amountStr() { return amount.value.trim().replace(',', '.'); }
|
||||
|
||||
@@ -34,6 +34,7 @@ final class SettingsPage {
|
||||
}
|
||||
echo '</select><p class="description">One currency for the whole site. It applies to goals you create from now on; existing goals keep their currency. Check the fixed fee below after changing it.</p></td></tr>';
|
||||
echo '<tr><th scope="row"><label for="sg_min">Minimum donation (' . esc_html( $cur ) . ')</label></th><td><input type="text" id="sg_min" name="min_donation" class="small-text" inputmode="decimal" value="' . esc_attr( Format::decimal( \StreamGoals\Core\Settings::effectiveMin( (int) $s['min_donation_minor'] ), $cur ) ) . '"> <span class="description">At least ' . esc_html( Format::money( \StreamGoals\Core\Settings::HARD_MIN_MINOR, $cur ) ) . '. Visitors cannot donate less than this.</span></td></tr>';
|
||||
echo '<tr><th scope="row"><label for="sg_notice">Notice under the donation form</label></th><td><input type="text" id="sg_notice" name="donation_notice" class="large-text" maxlength="200" value="' . esc_attr( (string) $s['donation_notice'] ) . '"><p class="description">Shown right under the PayPal buttons so donors see it before paying. Plain text, up to 200 characters. The default says donations are non-refundable. Leave it empty to hide the notice.</p></td></tr>';
|
||||
echo '<tr><th scope="row"><label for="sg_len">Longest message</label></th><td><input type="number" id="sg_len" name="message_max_length" min="0" max="500" class="small-text" value="' . (int) $s['message_max_length'] . '"> characters <span class="description">(0 to 500; 0 = no messages)</span></td></tr>';
|
||||
echo '<tr><th scope="row">Names</th><td><fieldset>';
|
||||
foreach ( self::POLICIES as $k => $l ) {
|
||||
@@ -147,6 +148,7 @@ final class SettingsPage {
|
||||
}
|
||||
$upd['funding_card'] = ! empty( $post['funding_card'] );
|
||||
$upd['funding_paylater'] = ! empty( $post['funding_paylater'] );
|
||||
$upd['donation_notice'] = Input::text( $post['donation_notice'] ?? '', 200 );
|
||||
$upd['moderate_messages'] = ! empty( $post['moderate_messages'] );
|
||||
$upd['profanity_filter'] = ! empty( $post['profanity_filter'] );
|
||||
$upd['profanity_use_builtin'] = ! empty( $post['profanity_use_builtin'] );
|
||||
|
||||
@@ -34,6 +34,7 @@ final class Settings {
|
||||
'profanity_words' => '', // streamer's extra words, one per line
|
||||
'message_max_length' => 200,
|
||||
'min_donation_minor' => 100,
|
||||
'donation_notice' => 'Donations are non-refundable.', // shown under the donation form; empty hides it
|
||||
'overlay_token' => '',
|
||||
'visitor_ip_header' => 'auto', // auto | '' (direct) | cloudflare | real_ip | forwarded (see Core\ClientIp)
|
||||
'funding_paylater' => false, // show PayPal "Pay Later" button
|
||||
|
||||
@@ -188,6 +188,7 @@ final class DonateController {
|
||||
'policy' => (string) $s['anonymity_policy'],
|
||||
'minMinor' => \StreamGoals\Core\Settings::effectiveMin( (int) $s['min_donation_minor'] ),
|
||||
'messageMax' => min( 500, (int) $s['message_max_length'] ),
|
||||
'notice' => (string) ( $s['donation_notice'] ?? '' ),
|
||||
'disableFunding' => array_values( array_filter( array( empty( $s['funding_paylater'] ) ? 'paylater' : '', empty( $s['funding_card'] ) ? 'card' : '' ) ) ),
|
||||
'goals' => $goals,
|
||||
'i18n' => array(
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use StreamGoals\Admin\Input;
|
||||
use StreamGoals\Core\Settings;
|
||||
|
||||
final class DonationNoticeTest extends TestCase {
|
||||
|
||||
public function test_default_notice_says_donations_are_non_refundable(): void {
|
||||
$d = Settings::defaults();
|
||||
$this->assertArrayHasKey( 'donation_notice', $d );
|
||||
$this->assertStringContainsString( 'non-refundable', strtolower( (string) $d['donation_notice'] ) );
|
||||
}
|
||||
|
||||
public function test_admin_input_is_plain_text_and_length_capped(): void {
|
||||
$this->assertSame( 'No refunds, sorry.', Input::text( ' No refunds, sorry. ', 200 ) );
|
||||
$this->assertStringNotContainsString( '<', Input::text( '<script>alert(1)</script><b>Hi</b>', 200 ), 'no markup survives (and it is rendered as text anyway)' );
|
||||
$this->assertStringNotContainsString( '<', Input::text( '<b>Bold</b> <i>text</i>', 200 ) );
|
||||
$this->assertSame( 200, strlen( Input::text( str_repeat( 'a', 500 ), 200 ) ) );
|
||||
$this->assertSame( '', Input::text( "\x00\x1F", 200 ) );
|
||||
}
|
||||
|
||||
public function test_form_script_renders_the_notice_with_textcontent_only(): void {
|
||||
$js = (string) file_get_contents( dirname( __DIR__, 2 ) . '/assets/donate/donate.js' );
|
||||
$this->assertMatchesRegularExpression( '/if \(C\.notice\).*sg-notice.*text: String\(C\.notice\)/s', $js, 'notice must be rendered as text, never HTML' );
|
||||
$this->assertStringNotContainsString( 'innerHTML', $js );
|
||||
}
|
||||
|
||||
public function test_form_config_passes_the_notice_through(): void {
|
||||
$php = (string) file_get_contents( dirname( __DIR__, 2 ) . '/includes/Rest/DonateController.php' );
|
||||
$this->assertStringContainsString( "'notice' => (string) ( \$s['donation_notice'] ?? '' )", $php );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user