An order transaction.
Inheritance: extends PayPal\Common\PayPalResourceModel
コード例 #1
0
ファイル: OrderTest.php プロジェクト: johnmicahmiguel/yodaphp
 public function testSerializeDeserialize()
 {
     $o1 = $this->order;
     $o2 = new Order();
     $o2->fromJson($o1->toJson());
     $this->assertEquals($o1, $o2);
 }
コード例 #2
0
ファイル: Order.php プロジェクト: r8filipe/LAPR
 /**
  * Retrieve details about an order by passing the order_id in the request URI.
  *
  * @param string         $orderId
  * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
  * @return Order
  */
 public static function get($orderId, $apiContext = null, $restCall = null)
 {
     ArgumentValidator::validate($orderId, 'orderId');
     $payLoad = "";
     $json = self::executeCall("/v1/payments/orders/{$orderId}", "GET", $payLoad, null, $apiContext, $restCall);
     $ret = new Order();
     $ret->fromJson($json);
     return $ret;
 }
コード例 #3
0
 /**
  * @dataProvider mockProvider
  * @param Order $obj
  */
 public function testAuthorize($obj, $mockApiContext)
 {
     $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock();
     $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(AuthorizationTest::getJson()));
     $authorization = new Authorization();
     $result = $obj->authorize($authorization, $mockApiContext, $mockPPRestCall);
     $this->assertNotNull($result);
 }
コード例 #4
0
ファイル: OrderGet.php プロジェクト: Roc4rdho/app
<?php

// #Get Order Sample
// Specify an order ID to get details about an order.
// API used: GET /v1/payments/orders/<Order-Id>
/** @var \PayPal\Api\Payment $payment */
$payment = (require __DIR__ . '/ExecutePayment.php');
// ### Approval Status
// Determine if the user approved the payment or not
if (isset($_GET['success']) && $_GET['success'] == 'true') {
    $transactions = $payment->getTransactions();
    $transaction = $transactions[0];
    $relatedResources = $transaction->getRelatedResources();
    $relatedResource = $relatedResources[0];
    $order = $relatedResource->getOrder();
    try {
        $result = \PayPal\Api\Order::get($order->getId(), $apiContext);
        // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
        ResultPrinter::printResult("Get Order", "Order", $result->getId(), null, $result);
    } catch (Exception $ex) {
        // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
        ResultPrinter::printError("Get Order", "Order", null, null, $ex);
        exit(1);
    }
    return $result;
} else {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printResult("User Cancelled the Approval", null);
    exit;
}