Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

Use the current Subscriptions API, or register for Subscriptions webhook events.

There is no supported server SDK for any of these things; use direct HTTPS integration, or if desired adapt the Checkout SDK's source to perform these other calls.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...