BECSMandateForm.php
4 years ago
CheckoutInstructions.php
4 years ago
CheckoutModal.php
4 years ago
CheckoutRedirect.php
4 years ago
CreditCardForm.php
4 years ago
FormFieldMarkup.php
4 years ago
HandlePaymentIntentStatus.php
4 years ago
SEPAMandateForm.php
4 years ago
CheckoutModal.php
147 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Stripe\Traits; |
| 4 | |
| 5 | use Give\Helpers\Form\Utils as FormUtils; |
| 6 | use Give\Helpers\Gateways\Stripe; |
| 7 | |
| 8 | /** |
| 9 | * @since 2.19.0 |
| 10 | */ |
| 11 | trait CheckoutModal |
| 12 | { |
| 13 | /** |
| 14 | * @param int $formId Donation Form ID. |
| 15 | * @param array $args Donation Form Arguments. |
| 16 | * |
| 17 | * @since 2.19.0 Migrated from the legacy Give_Stripe_Checkout::showCheckoutModal implementation of the Stripe Checkout Gateway. |
| 18 | * |
| 19 | * @return string |
| 20 | */ |
| 21 | public function getCheckoutModalHTML( $formId, $args ) |
| 22 | { |
| 23 | $idPrefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : "{$formId}-1"; |
| 24 | $backgroundImageUrl = give_get_option( 'stripe_checkout_background_image', '' ); |
| 25 | $backgroundItem = 'background-color: #000000;'; |
| 26 | |
| 27 | // Load Background Image, if exists. |
| 28 | if ( ! empty( $backgroundImageUrl ) ) { |
| 29 | $backgroundImageUrl = esc_url( $backgroundImageUrl ); |
| 30 | $backgroundItem = "background-image: url('{$backgroundImageUrl}'); background-size: cover;"; |
| 31 | } |
| 32 | |
| 33 | ob_start(); |
| 34 | ?> |
| 35 | <div id="give-stripe-checkout-modal-<?php echo $idPrefix; ?>" class="give-stripe-checkout-modal"> |
| 36 | <div class="give-stripe-checkout-modal-content"> |
| 37 | <div class="give-stripe-checkout-modal-container"> |
| 38 | <div class="give-stripe-checkout-modal-header" style="<?php echo $backgroundItem; ?>"> |
| 39 | <button class="give-stripe-checkout-modal-close"> |
| 40 | <svg |
| 41 | width="20px" |
| 42 | height="20px" |
| 43 | viewBox="0 0 20 20" |
| 44 | version="1.1" |
| 45 | xmlns="http://www.w3.org/2000/svg" |
| 46 | xmlns:xlink="http://www.w3.org/1999/xlink" |
| 47 | > |
| 48 | <defs> |
| 49 | <path |
| 50 | d="M10,8.8766862 L13.6440403,5.2326459 C13.9542348,4.92245137 14.4571596,4.92245137 14.7673541,5.2326459 C15.0775486,5.54284044 15.0775486,6.04576516 14.7673541,6.3559597 L11.1238333,9.99948051 L14.7673541,13.6430016 C15.0775486,13.9531961 15.0775486,14.4561209 14.7673541,14.7663154 C14.4571596,15.0765099 13.9542348,15.0765099 13.6440403,14.7663154 L10,11.1222751 L6.3559597,14.7663154 C6.04576516,15.0765099 5.54284044,15.0765099 5.2326459,14.7663154 C4.92245137,14.4561209 4.92245137,13.9531961 5.2326459,13.6430016 L8.87616671,9.99948051 L5.2326459,6.3559597 C4.92245137,6.04576516 4.92245137,5.54284044 5.2326459,5.2326459 C5.54284044,4.92245137 6.04576516,4.92245137 6.3559597,5.2326459 L10,8.8766862 Z" |
| 51 | id="path-1" |
| 52 | ></path> |
| 53 | </defs> |
| 54 | <g |
| 55 | id="Payment-recipes" |
| 56 | stroke="none" |
| 57 | stroke-width="1" |
| 58 | fill="none" |
| 59 | fill-rule="evenodd" |
| 60 | > |
| 61 | <g |
| 62 | id="Elements-Popup" |
| 63 | transform="translate(-816.000000, -97.000000)" |
| 64 | > |
| 65 | <g id="close-btn" transform="translate(816.000000, 97.000000)"> |
| 66 | <circle |
| 67 | id="Oval" |
| 68 | fill-opacity="0.3" |
| 69 | fill="#AEAEAE" |
| 70 | cx="10" |
| 71 | cy="10" |
| 72 | r="10" |
| 73 | ></circle> |
| 74 | <mask id="mask-2" fill="white"> |
| 75 | <use xlink:href="#path-1"></use> |
| 76 | </mask> |
| 77 | <use |
| 78 | id="Mask" |
| 79 | fill-opacity="0.5" |
| 80 | fill="#FFFFFF" |
| 81 | opacity="0.5" |
| 82 | xlink:href="#path-1" |
| 83 | ></use> |
| 84 | </g> |
| 85 | </g> |
| 86 | </g> |
| 87 | </svg> |
| 88 | </button> |
| 89 | <h3><?php echo give_get_option( 'stripe_checkout_name' ); ?></h3> |
| 90 | <div class="give-stripe-checkout-donation-amount"> |
| 91 | <?php echo give_get_form_price( $formId ); ?> |
| 92 | </div> |
| 93 | <div class="give-stripe-checkout-donor-email"></div> |
| 94 | <div class="give-stripe-checkout-form-title"> |
| 95 | <?php echo get_the_title( $formId ); ?> |
| 96 | </div> |
| 97 | </div> |
| 98 | <div class="give-stripe-checkout-modal-body"> |
| 99 | <?php |
| 100 | /** |
| 101 | * This action hook will be trigger in Stripe Checkout Modal before CC fields. |
| 102 | * |
| 103 | * @since 2.7.3 |
| 104 | */ |
| 105 | do_action( 'give_stripe_checkout_modal_before_cc_fields', $formId, $args ); |
| 106 | |
| 107 | // Load Credit Card Fields for Stripe Checkout. |
| 108 | echo Stripe::showCreditCardFields( $idPrefix ); |
| 109 | |
| 110 | /** |
| 111 | * This action hook will be trigger in Stripe Checkout Modal after CC fields. |
| 112 | * |
| 113 | * @since 2.7.3 |
| 114 | */ |
| 115 | do_action( 'give_stripe_checkout_modal_after_cc_fields', $formId, $args ); |
| 116 | ?> |
| 117 | <input type="hidden" name="give_validate_stripe_payment_fields" value="0"/> |
| 118 | </div> |
| 119 | <div class="give-stripe-checkout-modal-footer"> |
| 120 | <div class="card-errors"></div> |
| 121 | <?php |
| 122 | $display_label_field = give_get_meta( $formId, '_give_checkout_label', true ); |
| 123 | $display_label_field = apply_filters( 'give_donation_form_submit_button_text', $display_label_field, $formId, $args ); |
| 124 | $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
| 125 | ?> |
| 126 | <div class="give-submit-button-wrap give-stripe-checkout-modal-btn-wrap give-clearfix"> |
| 127 | <?php |
| 128 | echo sprintf( |
| 129 | '<input type="submit" class="%1$s" id="%2$s" value="%3$s" data-before-validation-label="%3$s" name="%4$s" data-is_legacy_form="%5$s" disabled/>', |
| 130 | FormUtils::isLegacyForm() ? 'give-btn give-stripe-checkout-modal-donate-button' : 'give-btn give-stripe-checkout-modal-sequoia-donate-button', |
| 131 | "give-stripe-checkout-modal-donate-button-{$idPrefix}", |
| 132 | $display_label, |
| 133 | 'give_stripe_modal_donate', |
| 134 | FormUtils::isLegacyForm() |
| 135 | ); |
| 136 | ?> |
| 137 | <span class="give-loading-animation"></span> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | </div> |
| 142 | </div> |
| 143 | <?php |
| 144 | return ob_get_clean(); |
| 145 | } |
| 146 | } |
| 147 |