Skip to content

TIS-810 Add advise #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
19 changes: 18 additions & 1 deletion sample/order_full_flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
'credit_card_bin' => '370002',
'credit_card_number' => 'xxxx-xxxx-xxxx-1234',
'credit_card_company' => 'VISA',
'credit_card_token' => '0022334466'
'credit_card_token' => '0022334466',
'_type' => 'credit_card'

### required for checkout denied: ###
# 'authorization_error' => new Model\AuthorizationError(array(
Expand Down Expand Up @@ -192,6 +193,11 @@
$response = $transport->createCheckout($checkout);
echo PHP_EOL."Create Checkout succeeded. Response: ".PHP_EOL.json_encode($response).PHP_EOL;

#### Advise Checkout (uncomment if eligible for /advise)
//$checkout = new Model\Checkout($order_details);
//
//$response = $transport->adviseOrder($checkout);
//echo PHP_EOL."Advise Checkout succeeded. Response: ".PHP_EOL.json_encode($response).PHP_EOL;

#### Notify Checkout Denied
$response = $transport->deniedCheckout($checkout);
Expand All @@ -205,6 +211,17 @@
$order->payment_details[0]->avs_result_code = 'Y';
$order->payment_details[0]->cvv_result_code = 'N';

##REQUIRED FOR PSD2 ORDERS##
//$authenticationResult = new Model\AuthenticationResult(array(
// 'created_at' => '2019-07-17T15:00:00-05:00',
// 'eci' => '07',
// 'cavv' => '05',
// 'trans_status' => 'Y',
// 'trans_status_reason' => '01',
// 'liability_shift' => true
//));
//$order->payment_details[0]->authentication_result = $authenticationResult;

$response = $transport->createOrder($order);
echo PHP_EOL."Create Order succeeded. Response: ".PHP_EOL.json_encode($response).PHP_EOL;

Expand Down
34 changes: 34 additions & 0 deletions src/Riskified/OrderWebhook/Model/AuthenticationResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php namespace Riskified\OrderWebhook\Model;
/**
* Copyright 2013-2015 Riskified.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0.html
*
* or in the "license" file accompanying this file. This file is distributed
* 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.
*/

/**
* Class AuthenticationResult
* data model of Result of Authentication via 3DS
* @package Riskified\OrderWebhook\Model
*/
class AuthenticationResult extends AbstractModel
{

protected $_fields = array(
'created_at' => 'date optional',
'eci' => 'string /^(:?05|06|07)$/',
'cavv' => 'string optional',
'trans_status' => 'string /^(:?Y|N|U|A|C|D|R|I)$/ optional',
'trans_status_reason' => 'string /^(:?01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|80|99)$/ optional',
'liability_shift' => 'boolean optional'
);

}
31 changes: 31 additions & 0 deletions src/Riskified/OrderWebhook/Model/AuthenticationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Riskified\OrderWebhook\Model;
/**
* Copyright 2013-2015 Riskified.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0.html
*
* or in the "license" file accompanying this file. This file is distributed
* 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.
*/

/**
* Class AuthenticationType
* data model Type of Authentication for PSD2 compliance
* @package Riskified\OrderWebhook\Model
*/
class AuthenticationType extends AbstractModel
{

protected $_fields = array(
'auth_type' => 'string optional',
'exemption_method' => 'string optional'
);

}

7 changes: 7 additions & 0 deletions src/Riskified/OrderWebhook/Model/PaymentDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class PaymentDetails extends AbstractModel {
'pending_reason' => 'string optional',
'authorization_id' => 'string optional',

'_type' => 'string /^(:?credit_card|paypal)$/ optional',
'id' => 'number optional',
'gateway' => 'string optional',
'acquirer_bin' => 'string optional',
'mid' => 'string optional',
'authentication_result' => 'object \AuthenticationResult optional',

'account_number' => 'string optional',
'routing_number' => 'string optional',

Expand Down
10 changes: 10 additions & 0 deletions src/Riskified/OrderWebhook/Transport/AbstractTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ public function deniedCheckout($checkout) {
return $this->send_checkout($checkout, 'checkout_denied');
}

/**
* Send an Advise request to Riskified
* @param $checkout object Checkout to send
* @return object Response object
* @throws \Riskified\Common\Exception\BaseException on any issue
*/
public function adviseOrder($checkout) {
return $this->send_checkout($checkout, 'advise');
}

/**
* Check eligibility for Deco payment
* @param $order object Order to send (only order id required)
Expand Down