paypal płatność kartą kredytową - poszukuję skryptu

0

cześć, dawno mnie nie było niestety :)

radzę sobie jakoś od niedawna z php
właśnie walczę z paypalem i wszystko było pięknie póki nie dowiedziałem się, że "gotowiec", który posiadam działa na sandboxie i niewiele ma wspólnego z poprawnym działającym skryptem w wersji produkcyjnej

poszukuję kogoś kto mógłby rzucić skryptem php, sprawdzonym, który po prostu zrealizowałby płatność kartą poprzez paypal

no ni jak mi nie wychodzi a szukajka googla tylko utrudnia wszystko

korzystałem ze skryptu:

 

<form action="#" method="POST"> 
                    <h2>Pay with my debit or credit card</h2>
                    <hr/>
                    <center> <h3>Billing Information</h3></center>
                    <input type="hidden" name="paymentType" value="Sale"/>
                    <input type="hidden" name="id" value="MQ=="/>
                    <table style="width:100%">
                        <tr>
                            <td id="td-label">First name : </td>
                            <td><input type="text" name="firstName" id="firstName" placeholder="Enter first name"></td>		

                        </tr>
                        <tr>
                            <td id="td-label">Last name : </td>
                            <td><input type="text" name="lastName" id="lastName" placeholder="Enter last name"></td>		

                        </tr>
                        <tr>
                            <td id="td-label">Card type : </td>
                            <td>
                                <select name="creditCardType" id='creditCardType'> 
                                    <option value="MasterCard">MasterCard</option> 
                                </select>
                            </td>		

                        </tr>
                        <tr>

                            <td id="td-label">Card number : </td>
                            <td><input type="text" name="creditCardNumber" id="creditCardNumber" placeholder="Enter card number" required="true"></td>		

                        </tr>

                        <tr>

                            <td id="td-label">Expiry date : </td>
                            <td><div id="date-div"><select name="expDateMonth" id='expDateMonth'> 
                                        <option value="11">11</option> 
                                    </select></div>
                                <div id="year-div">

                                    <select name="expDateYear" id='expDateYear'>					
 
                                        <option value="2020">2020</option>						
                                    </select>
                                </div></td>		

                        </tr>

                        <tr>

                            <td id="td-label">CVV : </td>
                            <td><div id="date-div"><input type="text" name="cvv2Number" id="cvv2Number" placeholder="cvv" required="true"></div></td>		

                        </tr>
                        <tr>

                            <td id="td-label">Amount( USD ) : </td>
                            <td><input type="text" name="amount" id="name" placeholder="Enter amount " value="0.1" disabled="true"></td>		

                        </tr>
                    </table> 
					<input type='submit' value='1' name='dpot'/>
            </form>

	<?php

if(!empty($_POST['dpot'])){
	//open connection
	$ch = curl_init();

	$client="a";
	$secret="b";

	curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/oauth2/token"); 
	
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($ch, CURLOPT_USERPWD, $client.":".$secret);
	curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials");

	$result = curl_exec($ch);

	if(empty($result))die("Error: No response.");
	else
	{
		$json = json_decode($result);
		print_r($json->access_token);
	}

	// Now doing txn after getting the token 

	if(!empty($json->access_token)){
	$ch = curl_init();

	$data = '{
	  "intent":"sale",
	  "redirect_urls":{
		"return_url":"http://localhost/payment.php",
		"cancel_url":"http://localhost/payment_cancel.php"
	  },
	  "payer": {
		"payment_method": "credit_card",
		"funding_instruments": [
		  {
			"credit_card": {
			  "number": "9999999999999999",
			  "type": "mastercard",
			  "expire_month": 11,
			  "expire_year": 2020,
			  "cvv2": 693,
			  "first_name": "Tester",
			  "last_name": "Tester"
			}
		  }
		]
	  },
	  "transactions":[
		{
		  "amount":{
			"total":"0.10",
			"currency":"USD"
		  },
		  "description":"This is the payment transaction description."
		}
	  ]
	}
	';

	curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.paypal.com/v1/payments/payment"); 
	curl_setopt($ch, CURLOPT_POST, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Authorization: Bearer ".$json->access_token));

	$result = curl_exec($ch);


	if(empty($result))die("Error: No response.");
	else
	{
		$json = json_decode($result);
		print_r($json);
	}

	}

}

?>
0

Witam,

jeśli masz konto PayPal Pro to po prostu usuń z endpointa 'sandbox.' oraz wstaw ilive: clientId i secret

1 użytkowników online, w tym zalogowanych: 0, gości: 1