Your Location is: Home > Jquery

How to auto fill the PayPal Guest Checkout form using jquery in laravel

From: Beijing View: 2002 Imran 

Question

I have all the personal data of a customer, now I want to populate / autofill the PayPal checkout form. When I click on black button "Debit or Credit card" then I redirect to that form. How this can be done ? please see the pictures attached

  1. First Name
  2. Last Name
  3. Address
  4. City
  5. State
  6. Country
  7. Phone Number
  8. Email

paypal.blade.php

 <!-- Buttons container -->
 <table border="0" align="center" valign="top" bgcolor="#FFFFFF" style="width:39%">
 <tr>
    <td colspan="2">
        <div id="paypal-button-container"></div>
    </td>
 </tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>

 <input type='hidden' id='card-billing-first-name' name='card-billing-first-name' value="{{$order_detail->first_name}}"/>  
 <input type='hidden' id='card-billing-last-name' name='card-billing-last-name' value="{{$order_detail->last_name}}"/> 
 <input type='hidden' id='card-billing-address' name='card-billing-address' value="{{$order_detail->address}}"/> 
 <input type='hidden' id='card-billing-address-city' name='card-billing-address-city' value="{{$order_detail->city}}"/>
 <input type='hidden' id='card-billing-address-zip_code' name='card-billing-address-zip_code' value="{{$order_detail->zip_code}}"/>
 <input type='hidden' id='card-billing-address-country_name' name='card-billing-address-country_name' value="{{$country_name}}"/>
 <input type='hidden' id='card-billing-address-state_name' name='card-billing-address-state_name' value="{{$state_name}}"/>

Jquery Code

<script src="https://www.paypal.com/sdk/js?client-id=AZ5...&currency=USD"></script>

<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({

    // Set up the transaction
    createOrder: function(data, actions) {
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: '{{$order_detail->grand_total}}',
                },
            }]
        });
    },

    // Finalize the transaction
    onApprove: function(data, actions) {
        return actions.order.capture().then(function(details) {
            // Show a success message to the buyer
            alert('Transaction completed by ' + details.payer.name.given_name + '!');
        });
    },

    //Changes credit/debit button behavior to "old" version
    onShippingChange: function(data,actions){
        //if not needed do nothing..
        return actions.resolve();
    }


}).render('#paypal-button-container');
</script>

paypal buttons PayPal checkout form 2

PayPal checkout form 1

Best answer

Whether filled in automatically or manually, PayPal's standard checkouts are not designed nor permitted to be used this way and it is a violation of its terms of service to do so. Transactions will get declined and your customers' information flagged for fraud in PayPal's system. Contact PayPal's support and they will tell you this.

These checkouts are meant to be filled out by customers themselves operating on their own devices, and only by customers themselves.

For what you want to do you need a virtual terminal, or gateway solution such as Braintree.