$order->line_items = array($lineItem1, $lineItem2);
# DiscountCodes
$discountCode = new Model\DiscountCode(array('amount' => 19.95, 'code' => '12'));
$order->discount_codes = $discountCode;
# ShippingLines
$shippingLine = new Model\ShippingLine(array('price' => 123.0, 'code' => 'Free'));
$order->shipping_lines = $shippingLine;
# PaymentDetais
$paymentDetails = new Model\PaymentDetails(array('credit_card_bin' => '370002', 'avs_result_code' => 'Y', 'cvv_result_code' => 'N', 'credit_card_number' => 'xxxx-xxxx-xxxx-1234', 'credit_card_company' => 'VISA'));
$order->payment_details = $paymentDetails;
# Customer
$customer = new Model\Customer(array('email' => '*****@*****.**', 'first_name' => 'Firstname', 'last_name' => 'Lastname', 'id' => '1233', 'created_at' => '2008-01-10T11:00:00-05:00', 'orders_count' => 6, 'verified_email' => true, 'account_type' => 'free'));
$order->customer = $customer;
# BillingAddress
$billingAddress = new Model\Address(array('first_name' => 'John', 'last_name' => 'Doe', 'address1' => '108 Main Street', 'company' => 'Kansas Computers', 'country' => 'United States', 'country_code' => 'US', 'phone' => '1234567', 'city' => 'NYC', 'name' => 'John Doe', 'address2' => 'Apartment 12', 'province' => 'New York', 'province_code' => 'NY', 'zip' => '64155'));
$order->billing_address = $billingAddress;
# ShippingAddress
$shippingAddress = new Model\Address(array('first_name' => 'John', 'last_name' => 'Doe', 'address1' => '108 Main Street', 'company' => 'Kansas Computers', 'country' => 'United States', 'country_code' => 'US', 'phone' => '1234567', 'city' => 'NYC', 'name' => 'John Doe', 'address2' => 'Apartment 12', 'province' => 'New York', 'province_code' => 'NY', 'zip' => '64155'));
$order->shipping_address = $shippingAddress;
echo "\nORDER REQUEST:" . PHP_EOL . json_encode(json_decode($order->toJson())) . PHP_EOL;
# Create a curl transport to the Riskified Server
$transport = new Transport\CurlTransport(new Signature\HttpDataSignature());
$transport->timeout = 10;
try {
    $response = $transport->submitOrder($order);
    echo PHP_EOL . "Submit Order succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
} catch (\Riskified\OrderWebhook\Exception\UnsuccessfulActionException $uae) {
    echo PHP_EOL . "Submit Order not succeeded. Status code was: " . $uae->statusCode . " and json body was: " . json_encode($uae->jsonResponse) . PHP_EOL;
} catch (Exception $e) {
    echo PHP_EOL . "Submit Order not succeeded. Exception: " . $e->getMessage() . PHP_EOL;
}
Пример #2
0
 private function getOrder($model)
 {
     $gateway = 'unavailable';
     if ($model->getPayment()) {
         $gateway = $model->getPayment()->getMethod();
     }
     $order_array = array('id' => $this->getOrderOrigId($model), 'name' => $model->getIncrementId(), 'email' => $model->getCustomerEmail(), 'created_at' => $this->formatDateAsIso8601($model->getCreatedAt()), 'currency' => $model->getOrderCurrencyCode(), 'updated_at' => $this->formatDateAsIso8601($model->getUpdatedAt()), 'gateway' => $gateway, 'browser_ip' => $this->getRemoteIp($model), 'cart_token' => Mage::helper('full')->getSessionId(), 'note' => $model->getCustomerNote(), 'total_price' => $model->getGrandTotal(), 'total_discounts' => $model->getDiscountAmount(), 'subtotal_price' => $model->getBaseSubtotalInclTax(), 'discount_codes' => $this->getDiscountCodes($model), 'taxes_included' => true, 'total_tax' => $model->getBaseTaxAmount(), 'total_weight' => $model->getWeight(), 'cancelled_at' => $this->formatDateAsIso8601($this->getCancelledAt($model)), 'financial_status' => $model->getState(), 'fulfillment_status' => $model->getStatus(), 'vendor_id' => $model->getStoreId(), 'vendor_name' => $model->getStoreName());
     if (Mage::getSingleton('admin/session')->isLoggedIn()) {
         unset($order_array['browser_ip']);
         unset($order_array['cart_token']);
     }
     $order = new Model\Order(array_filter($order_array, 'strlen'));
     $order->customer = $this->getCustomer($model);
     $order->shipping_address = $this->getShippingAddress($model);
     $order->billing_address = $this->getBillingAddress($model);
     $order->payment_details = $this->getPaymentDetails($model);
     $order->line_items = $this->getLineItems($model);
     $order->shipping_lines = $this->getShippingLines($model);
     if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
         $order->client_details = $this->getClientDetails($model);
     }
     Mage::helper('full/log')->log("getOrder(): " . PHP_EOL . json_encode(json_decode($order->toJson())));
     return $order;
 }