recreate project

This commit is contained in:
root
2026-02-10 22:11:06 -05:00
commit 663c0cdbda
10149 changed files with 1379710 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
// # Get Sale sample
// Sale transactions are nothing but completed payments.
// This sample code demonstrates how you can retrieve
// details of completed Sale Transaction.
// API used: /v1/payments/sale/{sale-id}
/** @var Payment $payment */
$payment = require __DIR__ . '/../payments/CreatePayment.php';
use PayPal\Api\Payment;
use PayPal\Api\Sale;
// ### Get Sale From Created Payment
// You can retrieve the sale Id from Related Resources for each transactions.
$transactions = $payment->getTransactions();
$relatedResources = $transactions[0]->getRelatedResources();
$sale = $relatedResources[0]->getSale();
$saleId = $sale->getId();
try {
// ### Retrieve the sale object
// Pass the ID of the sale
// transaction from your payment resource.
$sale = Sale::get($saleId, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Look Up A Sale", "Sale", $sale->getId(), null, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Look Up A Sale", "Sale", $sale->getId(), null, $sale);
return $sale;
@@ -0,0 +1,52 @@
<?php
// # Sale Refund Sample
// This sample code demonstrate how you can
// process a refund on a sale transaction created
// using the Payments API.
// API used: /v1/payments/sale/{sale-id}/refund
/** @var Sale $sale */
$sale = require 'GetSale.php';
$saleId = $sale->getId();
use PayPal\Api\Amount;
use PayPal\Api\Refund;
use PayPal\Api\Sale;
// ### Refund amount
// Includes both the refunded amount (to Payer)
// and refunded fee (to Payee). Use the $amt->details
// field to mention fees refund details.
$amt = new Amount();
$amt->setCurrency('USD')
->setTotal(0.01);
// ### Refund object
$refund = new Refund();
$refund->setAmount($amt);
// ###Sale
// A sale transaction.
// Create a Sale object with the
// given sale transaction id.
$sale = new Sale();
$sale->setId($saleId);
try {
// Create a new apiContext object so we send a new
// PayPal-Request-Id (idempotency) header for this resource
$apiContext = getApiContext($clientId, $clientSecret);
// Refund the sale
// (See bootstrap.php for more on `ApiContext`)
$refundedSale = $sale->refund($refund, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Refund Sale", "Sale", $refundedSale->getId(), $refund, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Refund Sale", "Sale", $refundedSale->getId(), $refund, $refundedSale);
return $refundedSale;