コード例 #1
0
// Usage: php order_full_flow.php
include __DIR__ . '/../src/Riskified/autoloader.php';
use Riskified\Common\Riskified;
use Riskified\Common\Env;
use Riskified\Common\Validations;
use Riskified\Common\Signature;
use Riskified\OrderWebhook\Model;
use Riskified\OrderWebhook\Transport;
# Replace with the 'shop domain' of your account in Riskified
$domain = "[your shop domain as registered to Riskified]";
# Replace with the 'auth token' listed in the Riskified web app under the 'Settings' Tab
$authToken = "[your authentication token string]";
Riskified::init($domain, $authToken, Env::SANDBOX, Validations::ALL);
$order_details = array('id' => 'ch567', 'name' => '#1234', 'email' => '*****@*****.**', 'created_at' => '2010-01-10T11:00:00-05:00', 'closed_at' => null, 'currency' => 'CAD', 'updated_at' => '2010-01-10T11:00:00-05:00', 'gateway' => 'mypaymentprocessor', 'browser_ip' => '124.185.86.55', 'total_price' => 113.23, 'total_discounts' => 5.0, 'cart_token' => '1sdaf23j212', 'additional_emails' => array('*****@*****.**', '*****@*****.**', 'third!2@email.rr.com'), 'note' => 'Shipped to my hotel.', 'referring_site' => 'google.com', 'line_items' => array(new Model\LineItem(array('price' => 100, 'quantity' => 1, 'title' => 'ACME Widget', 'product_id' => '101', 'sku' => 'ABCD')), new Model\LineItem(array('title' => 'Giftcard', 'price' => 100, 'quantity' => 1, 'requires_shipping' => false, 'delivered_at' => '2017-03-10T11:00:00-05:00')), new Model\LineItem(array('price' => 200, 'quantity' => 4, 'title' => 'ACME Spring', 'product_id' => '202', 'sku' => 'EFGH', 'category' => 'ACME Spring Category', 'sub_category' => 'ACME Spring Sub Category'))), 'discount_codes' => new Model\DiscountCode(array('amount' => 19.95, 'code' => '12')), 'shipping_lines' => new Model\ShippingLine(array('title' => 'FedEx', 'price' => 123.0, 'code' => 'Free')), 'payment_details' => new Model\PaymentDetails(array('credit_card_bin' => '370002', 'credit_card_number' => 'xxxx-xxxx-xxxx-1234', 'credit_card_company' => 'VISA')), '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')), 'billing_address' => 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')), 'shipping_address' => 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')), 'charge_free_payment_details' => new Model\ChargeFreePaymentDetails(array('gateway' => 'giftcard', 'amount' => '50')));
# Create a curl transport to the Riskified Server
$transport = new Transport\CurlTransport(new Signature\HttpDataSignature());
$transport->timeout = 10;
#### Create Checkout
$checkout = new Model\Checkout($order_details);
$response = $transport->createCheckout($checkout);
echo PHP_EOL . "Create Checkout succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
#### Notify Checkout Denied
# $response = $transport->deniedCheckout($checkout);
# echo PHP_EOL . "Denied Checkout succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
#### Create and Submit Order
$order = new Model\Order($order_details);
$order->checkout_id = $order->id;
$order->id = 'or1234';
$order->payment_details->avs_result_code = 'Y';
$order->payment_details->cvv_result_code = 'N';
$response = $transport->createOrder($order);
コード例 #2
0
$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;
}
コード例 #3
0
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
// A simple example of uploading historical orders from the command line.
// Usage: php upload_historical.php
include __DIR__ . '/../src/Riskified/autoloader.php';
use Riskified\Common\Riskified;
use Riskified\Common\Env;
use Riskified\Common\Signature;
use Riskified\OrderWebhook\Model;
use Riskified\OrderWebhook\Transport;
# Replace with the 'shop domain' of your account in Riskified
$domain = "[your shop domain as registered to Riskified]";
# Replace with the 'auth token' listed in the Riskified web app under the 'Settings' Tab
$authToken = "[your authentication token string]";
Riskified::init($domain, $authToken, Env::SANDBOX);
$first_order = new Model\Order(array('id' => '1234', 'name' => '#1234', 'email' => '*****@*****.**', 'created_at' => '2010-01-10T11:00:00-05:00', 'closed_at' => null, 'currency' => 'CAD', 'updated_at' => '2010-01-10T11:00:00-05:00', 'gateway' => 'mypaymentprocessor', 'browser_ip' => '124.185.86.55', 'total_price' => 113.23, 'total_discounts' => 5.0, 'cart_token' => '1sdaf23j212', 'note' => 'Shipped to my hotel.', 'referring_site' => 'google.com'));
$second_order = new Model\Order(array('id' => '1235', 'name' => '#1235', 'email' => '*****@*****.**', 'created_at' => '2010-01-10T11:00:00-05:00', 'closed_at' => null, 'currency' => 'CAD', 'updated_at' => '2010-01-10T11:00:00-05:00', 'gateway' => 'mypaymentprocessor', 'browser_ip' => '124.185.86.55', 'total_price' => 113.23, 'total_discounts' => 5.0, 'cart_token' => '1sdaf23j212', 'note' => 'Shipped to my hotel.', 'referring_site' => 'google.com'));
$orders = array($first_order, $second_order);
# Create a curl transport to the Riskified Server
$transport = new Transport\CurlTransport(new Signature\HttpDataSignature());
$transport->timeout = 10;
try {
    $response = $transport->sendHistoricalOrders($orders);
    echo PHP_EOL . "Upload succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
} catch (\Riskified\OrderWebhook\Exception\UnsuccessfulActionException $uae) {
    echo PHP_EOL . "Upload failed. Status code was: " . $uae->statusCode . " and body was: " . json_encode($uae->jsonResponse) . PHP_EOL;
} catch (Exception $e) {
    echo PHP_EOL . "Upload failed. Exception: " . $e->getMessage() . PHP_EOL;
}
コード例 #4
0
 * Date: 3/29/15
 * Time: 5:03 PM
 */
// A simple example of submitting an order.
// Usage: php order_simple_submit.php
include __DIR__ . '/../src/Riskified/autoloader.php';
use Riskified\Common\Riskified;
use Riskified\Common\Env;
use Riskified\Common\Validations;
use Riskified\Common\Signature;
use Riskified\OrderWebhook\Model;
use Riskified\OrderWebhook\Transport;
# Replace with the 'shop domain' of your account in Riskified
$domain = "test.com";
# Replace with the 'auth token' listed in the Riskified web app under the 'Settings' Tab
$authToken = "1388add8a99252fc1a4974de471e73cd";
Riskified::init($domain, $authToken, Env::DEV, Validations::IGNORE_MISSING);
# Order
$settings = new Model\MerchantSettings(array('settings' => array('version' => '1234', 'gws' => 'Adyen,CC')));
echo "\n MERCHANT SETTINGS:" . PHP_EOL . json_encode(json_decode($settings->toJson())) . PHP_EOL;
# Create a curl transport to the Riskified Server
$transport = new Transport\CurlTransport(new Signature\HttpDataSignature());
$transport->timeout = 10;
try {
    $response = $transport->updateMerchantSettings($settings);
    echo PHP_EOL . "Update Merchant Settings succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
} catch (\Riskified\OrderWebhook\Exception\UnsuccessfulActionException $uae) {
    echo PHP_EOL . "Update Merchant Settings not succeeded. Status code was: " . $uae->statusCode . " and json body was: " . json_encode($uae->jsonResponse) . PHP_EOL;
} catch (Exception $e) {
    echo PHP_EOL . "Update Merchant Settings not succeeded. Exception: " . $e->getMessage() . PHP_EOL;
}
コード例 #5
0
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
// A simple example of creating a marketplace order.
// Usage: php order_marketplace_create.php
include __DIR__ . '/../src/Riskified/autoloader.php';
use Riskified\Common\Riskified;
use Riskified\Common\Env;
use Riskified\Common\Validations;
use Riskified\Common\Signature;
use Riskified\OrderWebhook\Model;
use Riskified\OrderWebhook\Transport;
# Replace with the 'shop domain' of your account in Riskified
$domain = "test.com";
# Replace with the 'auth token' listed in the Riskified web app under the 'Settings' Tab
$authToken = "1388add8a99252fc1a4974de471e73cd";
Riskified::init($domain, $authToken, Env::SANDBOX, Validations::IGNORE_MISSING);
# Order
$order = new Model\Order(array('id' => '1234', 'name' => '#1234', 'email' => '*****@*****.**', 'created_at' => '2010-01-10T11:00:00-05:00', 'closed_at' => null, 'currency' => 'CAD', 'updated_at' => '2010-01-10T11:00:00-05:00', 'gateway' => 'mypaymentprocessor', 'browser_ip' => '124.185.86.55', 'total_price' => 113.23, 'total_discounts' => 5.0, 'cart_token' => '1sdaf23j212', 'additional_emails' => array('*****@*****.**', '*****@*****.**'), 'note' => 'Shipped to my hotel.', 'referring_site' => 'google.com', 'line_items' => array(new Model\LineItem(array('price' => 100, 'quantity' => 1, 'title' => 'ACME Widget', 'product_id' => '101', 'sku' => 'ABCD', 'condition' => 'mint', 'seller' => new Model\Seller(array('customer' => new Model\Customer(array('email' => '*****@*****.**', 'first_name' => 'SellerFirstname', 'last_name' => 'SellerLastname', 'id' => '4567', 'created_at' => '2008-01-10T11:00:00-05:00', 'orders_count' => 16, 'account_type' => 'premium', 'verified_email' => true)), 'correspondence' => 77, 'price_negotiated' => false, 'starting_price' => 100.3))))), 'discount_codes' => new Model\DiscountCode(array('amount' => 19.95, 'code' => '12')), 'shipping_lines' => new Model\ShippingLine(array('price' => 123.0, 'code' => 'Free')), 'payment_details' => 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')), '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', 'social' => array(new Model\SocialDetails(array('network' => 'internal', 'public_username' => 'donnie7', 'community_score' => 68, 'profile_picture' => 'http://img.com/abc.png', 'email' => '*****@*****.**', 'bio' => 'avid mountaineer...', 'account_url' => 'http://shop.com/user/donnie7', 'following' => 231, 'followed' => 56, 'posts' => 10)), new Model\SocialDetails(array('network' => 'facebook', 'public_username' => '7231654'))))), 'billing_address' => 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')), 'shipping_address' => 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')), 'nocharge_amount' => new Model\RefundDetails(array('refund_id' => '1235', 'amount' => 20, 'currency' => 'USD', 'reason' => 'wallet'))));
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->createOrder($order);
    echo PHP_EOL . "Create Order succeeded. Response: " . PHP_EOL . json_encode($response) . PHP_EOL;
} catch (\Riskified\OrderWebhook\Exception\UnsuccessfulActionException $uae) {
    echo PHP_EOL . "Create Order not succeeded. Status code was: " . $uae->statusCode . " and json body was: " . json_encode($uae->jsonResponse) . PHP_EOL;
} catch (Exception $e) {
    echo PHP_EOL . "Create Order not succeeded. Exception: " . $e->getMessage() . PHP_EOL;
}