I'm trying to verify subscriptions and save information to the database, in my last question I was setting up a checkout that allows dual checkout, for orders and subscriptions. I am verifying orders here:
<?php
namespace Sample;
require __DIR__ . '/vendor/autoload.php';
use SamplePayPalClient;
use PayPalCheckoutSdkOrdersOrdersGetRequest;
require 'paypal-client.php';
$orderID = $_GET['orderID'];
class GetOrder
{
public static function getOrder($orderId)
{
// 3. Call PayPal to get the transaction details
$client = PayPalClient::client();
$response = $client->execute(new OrdersGetRequest($orderId));
$orderID = $response->result->id;
$email = $response->result->payer->email_address;
$name = $response->result->purchase_units[0]->shipping->name->full_name;
$payerid = $response->result->payer->payer_id;
$id = $_GET["UserID"];
include "include/connect.php";
//echo "#################### $orderID ###### $email ######### $name ######### $payerid";
$stmt = $conn->prepare("UPDATE User SET Active='2', OrderID='$orderID', PPemail='$email', PPname='$name', PPID='$payerid' WHERE ID = $id");
$stmt->execute();
if(!$stmt){
echo "error" . mysqli_error($con);
}else{
header("Location:success.php?id=$id");
}
?>
<pre>
<?php
//echo json_encode($response->result, JSON_PRETTY_PRINT);
?>
</pre>
<?php
}
}
/**
*This driver function invokes the getOrder function to retrieve
*sample order details.
*
*To get the correct order ID, this sample uses createOrder to create an order
*and then uses the newly-created order ID with GetOrder.
*/
if (!count(debug_backtrace()))
{
GetOrder::getOrder($orderID, true);
}
?>
But I also need to get subscription details to save that as well, I can't find any good tutorials on subscriptions.
See Question&Answers more detail:os