Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

php - Adding metadata to Stripe PaymentIntent token

Good afternoon,

First timer here with very little knowledge of coding, but I'm in a bind and I am familiar with Stack Overflow being the "go-to" for coding solutions.

I work for a non-profit and we recently created a new website that accepts donations. We are using Stripe as the payment gateway and a PaymentIntent API.

So, we have a payment modal form on our page that is activated when the visitor goes to the donations page. Donor enters personal information along with comments or instructions (comments field can be blank as well) into this modal form and clicks "Donate Now" button. Payment is successful.

When paymentintents is created and the transaction is complete and successful, most of the information goes through to out back office in Stripe to the payment record with the exception of the "Comments" section.

Looking at the code, all the modal form field lines are "ID"'d except for the Comments field. My guess is that it is probably the reason - lack of "ID"ing.

We need the comments field value to be transferred so that we can capture it on the backend for our records and also send an email to the donor noting the metadata (e.g in honour of John Doe).

I am thinking there should be a metadata or description attribute in the first part. I just don't know how to do it, how to point it at the "Comments" field, and tie them together to be sent with the token.

I'm thinking this needs to be labeled:

<textarea rows="4" placeholder="Comments"></textarea>

Any thoughts? Input ID (like how the others fields have it), description or metadata attribute?

I have been to Stripe Support twice and they keep pointing me back to our developer. However, the developer is currently unavailable. I have a feeling this is only a one-line correction.

Any guidance will be greatly appreciated.

Here is the original redacted code:

<?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    require_once('../../../vendor/autoload.php');
    StripeStripe::setApiKey("******************(REDACTED)");
    $usamt = $_GET['amt'];
    $dollars = $usamt/100;
    $intent = StripePaymentIntent::create([
      'amount' => $usamt,
      'currency' => 'usd',
    ]);
?>
<div class="payment-modal showing">
    <div class="closeme genericon-close"></div>
    <div class="payment-contain">
        <div class="logo">
            <img alt="**********(REDACTED)" src="***********(REDACTED).png">
        </div>
        <div class="stripe-donate-form form-group">
            <h3 class="block-heading">Personal Info</h3>
<!--            <p class="rqrd">*Required</p> -->
            <div class="half-wrap">
                <input class="first-last vcheck" type="text" id="firstname" name="firstname" placeholder="First Name*">
                <input class="first-last vcheck" type="text" id="lastname" name="lastname" placeholder="Last Name*">
            </div>
            <input id="email-address" class="vmail" type="email" placeholder="Email address*">
            <textarea rows="4" placeholder="Comments"></textarea>
            <h3 class="block-heading">Credit Card Info</h3>
            <!-- placeholder for Elements -->
            <div class="security">
                <span class="genericon-lock secure"></span> This is a secure SSL encrypted payment.
            </div>
            <input id="cardholder-name" class="vcheck" type="text" placeholder="Cardholder Name*">
            <div id="card-element" class="form-control" style="margin-top: 15px;background:#f7f7f7;border:1px solid rgba(0,0,0,0.1);padding:3px 6px;"></div>
            <div id="card-errors"></div>
            <h3 class="block-heading">Billing Details</h3>
            <select required class="select-css vcheck" name="billing_country" autocomplete="country" id="billing_country" class="billing-country billing_country give-select required" required="" aria-required="true">
                <option value="" selected disabled>Select country*</option><option value="US">United States</option><option value="CA">Canada</option><option value="GB">United Kingdom</option><option value="AF">Afghanistan</option><option value="AL">Albania</option><option value="DZ">Algeria</option><option value="AS">American Samoa</option><option value="AD">Andorra</option><option value="AO">Angola</option><option value="AI">Anguilla</option><option value="AQ">Antarctica</option><option value="AG">Antigua and Barbuda</option><option value="AR">Argentina</option><option value="AM">Armenia</option><option value="AW">Aruba</option><option value="AU">Australia</option><option value="AT">Austria</option><option value="AZ">Azerbaijan</option><option value="BS">Bahamas</option><option value="BH">Bahrain</option><option value="BD">Bangladesh</option><option value="BB">Barbados</option><option value="BY">Belarus</option><option value="BE">Belgium</option><option value="BZ">Belize</option><option value="BJ">Benin</option><option value="BM">Bermuda</option><option value="BT">Bhutan</option><option value="BO">Bolivia</option><option value="BA">Bosnia and Herzegovina</option><option value="BW">Botswana</option><option value="BV">Bouvet Island</option><option value="BR">Brazil</option><option value="IO">British Indian Ocean Territory</option><option value="BN">Brunei Darrussalam</option><option value="BG">Bulgaria</option><option value="BF">Burkina Faso</option><option value="BI">Burundi</option><option value="KH">Cambodia</option><option value="CM">Cameroon</option><option value="CV">Cape Verde</option><option value="KY">Cayman Islands</option><option value="CF">Central African Republic</option><option value="TD">Chad</option><option value="CL">Chile</option><option value="CN">China</option><option value="CX">Christmas Island</option><option value="CC">Cocos Islands</option><option value="CO">Colombia</option><option value="KM">Comoros</option><option value="CD">Congo, Democratic People's Republic</option><option value="CG">Congo, Republic of</option><option value="CK">Cook Islands</option><option value="CR">Costa Rica</option><option value="CI">Cote d'Ivoire</option><option value="HR">Croatia/Hrvatska</option><option value="CU">Cuba</option><option value="CY">Cyprus Island</option><option value="CZ">Czech Republic</option><option value="DK">Denmark</option><option value="DJ">Djibouti</option><option value="DM">Dominica</option><option value="DO">Dominican Republic</option><option value="TP">East Timor</option><option value="EC">Ecuador</option><option value="EG">Egypt</option><option value="GQ">Equatorial Guinea</option><option value="SV">El Salvador</option><option value="ER">Eritrea</option><option value="EE">Estonia</option><option value="ET">Ethiopia</option><option value="FK">Falkland Islands</option><option value="FO">Faroe Islands</option><option value="FJ">Fiji</option><option value="FI">Finland</option><option value="FR">France</option><option value="GF">French Guiana</option><option value="PF">French Polynesia</option><option value="TF">French Southern Territories</option><option value="GA">Gabon</option><option value="GM">Gambia</option><option value="GE">Georgia</option><option value="DE">Germany</option><option value="GR">Greece</option><option value="GH">Ghana</option><option value="GI">Gibraltar</option><option value="GL">Greenland</option><option value="GD">Grenada</option><option value="GP">Guadeloupe</option><option value="GU">Guam</option><option value="GT">Guatemala</option><option value="GG">Guernsey</option><option value="GN">Guinea</option><option value="GW">Guinea-Bissau</option><option value="GY">Guyana</option><option value="HT">Haiti</option><option value="HM">Heard and McDonald Islands</option><option value="VA">Holy See (City Vatican State)</option><option value="HN">Honduras</option><option value="HK">Hong Kong</option><option value="HU">Hungary</option><option value="IS">Iceland</option><option value="IN">India</option><option value="ID">Indonesia</option><option value="IR">Iran</option><option value="IQ">Iraq</option><option value="IE">Ireland</option><option value="IM">Isle of Man</option><option value="IL">Israel</option><option value="IT">Italy</option><option value="JM">Jamaica</option><option value="JP">Japan</option><option value="JE">Jersey</option><option value="JO">Jordan</option><option value="KZ">Kazakhstan</option><option value="KE">Kenya</option><option value="KI">Kiribati</option><option value="KW">K

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can add metadata to your PaymentIntent object. The API reference contains information on the PaymentIntent object, as well as links to guides and documentation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...