paypal/PayPal-PHP-SDK

Paypal billing agreement - (Sale & Payments & Transactions) - Got confused.

yalmazkhalil opened this issue · 1 comments

Hello,

I`m using paypal recurring payments in my current project.
I already created billing plans, and the user can subscribe to the plans.

The only way I know to get transaction ID in order to create billing history for the user, is by searching for transactions history and get results from Paypal directly by the REST API:

Agreement::searchTransactions('Agrrement ID', 'Dates from and to', 'apiContext');

I already receive payment completed notifications as below:

array:8 [
  "id" => "WH-78A66682X6254454N-xxxxx"
  "event_version" => "1.0"
  "create_time" => "2019-10-25T00:25:49.587Z"
  "resource_type" => "sale"
  "event_type" => "PAYMENT.SALE.COMPLETED"
  "summary" => "Payment completed for $ 20.0 USD"
  "resource" => array:12 [
    "id" => "1X431032H7986792A"
    "state" => "completed"
    "amount" => array:3 [
      "total" => "20.00"
      "currency" => "USD"
      "details" => array:1 [
        "subtotal" => "20.00"
      ]
    ]
    "payment_mode" => "INSTANT_TRANSFER"
    "protection_eligibility" => "ELIGIBLE"
    "protection_eligibility_type" => "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"
    "transaction_fee" => array:2 [
      "value" => "1.08"
      "currency" => "USD"
    ]
    "invoice_number" => null
    "billing_agreement_id" => "I-8E4H1ALXDPDC"
    "create_time" => "2019-10-25T00:25:41Z"
    "update_time" => "2019-10-25T00:25:41Z"
    "links" => array:2 [
      0 => array:3 [
        "href" => "https://api.sandbox.paypal.com/v1/payments/sale/1X431032H7986792A"
        "rel" => "self"
        "method" => "GET"
      ]
      1 => array:3 [
        "href" => "https://api.sandbox.paypal.com/v1/payments/sale/1X431032H7986792A/refund"
        "rel" => "refund"
        "method" => "POST"
      ]
    ]
  ]

as shown in the resource it gives me the payment ID (1X431032H7986792A).
My question, are the payment ID and transaction ID same? because when I login to my sandbox account, the only IDs I have are the agreement ID and the transaction ID which is different from payment ID that I receive from the webhooks, so do we have another way to retrieve transaction ID instead of searching by calling and getting the entire transactions for the user Agreement::searchTransactions.

it will be really easy if we receive the transaction id with the payment completed notification, so we can store them in the database and create payments history for the user.

Hi @yalmazkhalil , yes 1X431032H7986792A is the merchant side transaction_id. It should be the same when you login in to the merchant account.