Skip to content

Commit

Permalink
add configuration fields for order amount
Browse files Browse the repository at this point in the history
set configured values in all requests
  • Loading branch information
PaylineGitHub committed Sep 2, 2017
1 parent 2ab9249 commit 9daeadd
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 250 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Requirements
------------

Compliant with PHP 5.3 and over
Requires PaylineByMonext/payline-php-sdk, just let Composer do the job
Requires PaylineByMonext/payline-php-sdk : dependency for branch dev-master of monext/payline-sdk is declared in composer.json


Author
Expand Down
178 changes: 129 additions & 49 deletions examples/demos/ajax.php

Large diffs are not rendered by default.

185 changes: 184 additions & 1 deletion examples/fieldset/order.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/fieldset/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="row">
<label for="paymentAmount">Payment amount</label>
<input type="text" name="paymentAmount" id="paymentAmount" value="<?php if(isset($_GET['amount'])) echo $_GET['amount']; else echo 1000; ?>">
<input type="text" name="paymentAmount" id="paymentAmount" value="<?php if(isset($_GET['amount'])) echo $_GET['amount']; else echo $_SESSION['PAYMENT_AMOUNT']; ?>">
</div>

<div class="row" <?php if($displayedPage == 'widgetPayment') echo "style='display:none'";?>>
Expand Down
193 changes: 5 additions & 188 deletions examples/index/configuration.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/index/updateConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
fwrite($handle, '$_SESSION[\'LOG_LEVEL\'] = '.$_POST['LOG_LEVEL'].';'.$nextLine);

fwrite($handle, $nextLine.'// payment setting'.$nextLine);
fwrite($handle, '$_SESSION[\'PAYMENT_AMOUNT\'] = \''.$_POST['PAYMENT_AMOUNT'].'\';'.$nextLine);
fwrite($handle, '$_SESSION[\'PAYMENT_CURRENCY\'] = \''.$_POST['PAYMENT_CURRENCY'].'\';'.$nextLine);
fwrite($handle, '$_SESSION[\'ORDER_CURRENCY\'] = \''.$_POST['ORDER_CURRENCY'].'\';'.$nextLine);
fwrite($handle, '$_SESSION[\'LANGUAGE_CODE\'] = \''.$_POST['LANGUAGE_CODE'].'\';'.$nextLine);
fwrite($handle, '$_SESSION[\'PAYMENT_ACTION\'] = \''.$_POST['PAYMENT_ACTION'].'\';'.$nextLine);
fwrite($handle, '$_SESSION[\'PAYMENT_MODE\'] = \''.$_POST['PAYMENT_MODE'].'\';'.$nextLine);
Expand Down
97 changes: 93 additions & 4 deletions examples/wallet/3DS_walletPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,117 @@
$doImmediateWalletPaymentRequest['version'] = $_SESSION['WS_VERSION'];

// PAYMENT
$doImmediateWalletPaymentRequest['payment']['amount'] = 1000;
$doImmediateWalletPaymentRequest['payment']['amount'] = $_SESSION['PAYMENT_AMOUNT'];
$doImmediateWalletPaymentRequest['payment']['currency'] = $_SESSION['PAYMENT_CURRENCY'];
$doImmediateWalletPaymentRequest['payment']['action'] = $_SESSION['PAYMENT_ACTION'];
$doImmediateWalletPaymentRequest['payment']['mode'] = $_SESSION['PAYMENT_MODE'];
$doImmediateWalletPaymentRequest['payment']['contractNumber'] = $_SESSION['3DS_AUTH_CONTRACT'];

// ORDER
$doImmediateWalletPaymentRequest['order']['ref'] = $_SESSION['3DS_AUTH_ORDER_REF'];
$doImmediateWalletPaymentRequest['order']['amount'] = $doImmediateWalletPaymentRequest['payment']['amount'];
$doImmediateWalletPaymentRequest['order']['amount'] = $_SESSION['orderAmount'];
$doImmediateWalletPaymentRequest['order']['date'] = date('d/m/Y H:i');
$doImmediateWalletPaymentRequest['order']['currency'] = $doImmediateWalletPaymentRequest['payment']['currency'];
$doImmediateWalletPaymentRequest['order']['currency'] = $_SESSION['orderCurrency'];
$doImmediateWalletPaymentRequest['order']['origin'] = $_SESSION['orderOrigin'];
$doImmediateWalletPaymentRequest['order']['country'] = $_SESSION['orderCountry'];
$doImmediateWalletPaymentRequest['order']['taxes'] = $_SESSION['orderTaxes'];
$doImmediateWalletPaymentRequest['order']['deliveryTime'] = $_SESSION['deliveryTime'];
$doImmediateWalletPaymentRequest['order']['deliveryMode'] = $_SESSION['deliveryMode'];

// ORDER DETAILS
$item1 = array();
$item1['ref'] = $_SESSION['orderDetailRef1'];
$item1['price'] = $_SESSION['orderDetailPrice1'];
$item1['quantity'] = $_SESSION['orderDetailQuantity1'];
$item1['comment'] = $_SESSION['orderDetailComment1'];
$item1['category'] = $_SESSION['orderDetailCategory1'];
$item1['brand'] = $_SESSION['orderDetailBrand1'];
$item1['subcategory1'] = $_SESSION['orderDetailSubcategory1_1'];
$item1['subcategory2'] = $_SESSION['orderDetailSubcategory2_1'];
$item1['additionalData'] = $_SESSION['orderDetailAdditionalData1'];
$item1['taxRate'] = $_SESSION['orderDetailTaxRate1'];
$payline->addOrderDetail($item1);

$item2 = array();
$item2['ref'] = $_SESSION['orderDetailRef2'];
$item2['price'] = $_SESSION['orderDetailPrice2'];
$item2['quantity'] = $_SESSION['orderDetailQuantity2'];
$item2['comment'] = $_SESSION['orderDetailComment2'];
$item2['category'] = $_SESSION['orderDetailCategory2'];
$item2['brand'] = $_SESSION['orderDetailBrand2'];
$item2['subcategory1'] = $_SESSION['orderDetailSubcategory1_2'];
$item2['subcategory2'] = $_SESSION['orderDetailSubcategory2_2'];
$item2['additionalData'] = $_SESSION['orderDetailAdditionalData2'];
$item2['taxRate'] = $_SESSION['orderDetailTaxRate2'];
$payline->addOrderDetail($item2);

// BUYER
$doImmediateWalletPaymentRequest['buyer']['legalStatus'] = $_SESSION['buyerLegalStatus'];
$doImmediateWalletPaymentRequest['buyer']['title'] = $_SESSION['buyerTitle'];
$doImmediateWalletPaymentRequest['buyer']['lastName'] = $_SESSION['buyerLastName'];
$doImmediateWalletPaymentRequest['buyer']['firstName'] = $_SESSION['buyerFirstName'];
$doImmediateWalletPaymentRequest['buyer']['email'] = $_SESSION['buyerEmail'];
$doImmediateWalletPaymentRequest['buyer']['mobilePhone'] = $_SESSION['mobilePhone'];
$doImmediateWalletPaymentRequest['buyer']['customerId'] = $_SESSION['customerId'];
$doImmediateWalletPaymentRequest['buyer']['accountCreateDate'] = $_SESSION['buyerAccountCreateDate'];
$doImmediateWalletPaymentRequest['buyer']['accountAverageAmount'] = $_SESSION['buyerAverageAmount'];
$doImmediateWalletPaymentRequest['buyer']['accountOrderCount'] = $_SESSION['buyerOrderCount'];
$doImmediateWalletPaymentRequest['buyer']['walletId'] = $_SESSION['buyerWalletId'];
$doImmediateWalletPaymentRequest['buyer']['walletDisplayed'] = $_SESSION['buyerWalletDisplayed'];
$doImmediateWalletPaymentRequest['buyer']['walletSecured'] = $_SESSION['buyerWalletSecured'];
$doImmediateWalletPaymentRequest['buyer']['walletCardInd'] = $_SESSION['buyerWalletCardInd'];
$doImmediateWalletPaymentRequest['buyer']['ip'] = $_SESSION['buyerIp'];
$doImmediateWalletPaymentRequest['buyer']['legalDocument'] = $_SESSION['legalDocument'];
$doImmediateWalletPaymentRequest['buyer']['birthDate'] = $_SESSION['birthDate'];
$doImmediateWalletPaymentRequest['buyer']['fingerprintID'] = $_SESSION['fingerprintID'];

// BILLING ADDRESS
$doImmediateWalletPaymentRequest['billingAddress']['title'] = $_SESSION['billingAddressTitle'];
$doImmediateWalletPaymentRequest['billingAddress']['firstName'] = $_SESSION['billingAddressFirstName'];
$doImmediateWalletPaymentRequest['billingAddress']['lastName'] = $_SESSION['billingAddressLastName'];
$doImmediateWalletPaymentRequest['billingAddress']['name'] = $_SESSION['billingAddressName'];
$doImmediateWalletPaymentRequest['billingAddress']['street1'] = $_SESSION['billingAddressStreet1'];
$doImmediateWalletPaymentRequest['billingAddress']['street2'] = $_SESSION['billingAddressStreet2'];
$doImmediateWalletPaymentRequest['billingAddress']['county'] = $_SESSION['billingAddressCounty'];
$doImmediateWalletPaymentRequest['billingAddress']['cityName'] = $_SESSION['billingAddressCity'];
$doImmediateWalletPaymentRequest['billingAddress']['zipCode'] = $_SESSION['billingAddressZipCode'];
$doImmediateWalletPaymentRequest['billingAddress']['country'] = $_SESSION['billingAddressCountry'];
$doImmediateWalletPaymentRequest['billingAddress']['state'] = $_SESSION['billingAddressState'];
$doImmediateWalletPaymentRequest['billingAddress']['phoneType'] = $_SESSION['billingAddressPhoneType'];
$doImmediateWalletPaymentRequest['billingAddress']['phone'] = $_SESSION['billingAddressPhone'];

// SHIPPING ADDRESS
$doImmediateWalletPaymentRequest['shippingAddress']['title'] = $_SESSION['shippingAddressTitle'];
$doImmediateWalletPaymentRequest['shippingAddress']['firstName'] = $_SESSION['shippingAddressFirstName'];
$doImmediateWalletPaymentRequest['shippingAddress']['lastName'] = $_SESSION['shippingAddressLastName'];
$doImmediateWalletPaymentRequest['shippingAddress']['name'] = $_SESSION['shippingAddressName'];
$doImmediateWalletPaymentRequest['shippingAddress']['street1'] = $_SESSION['shippingAddressStreet1'];
$doImmediateWalletPaymentRequest['shippingAddress']['street2'] = $_SESSION['shippingAddressStreet2'];
$doImmediateWalletPaymentRequest['shippingAddress']['county'] = $_SESSION['shippingAddressCounty'];
$doImmediateWalletPaymentRequest['shippingAddress']['cityName'] = $_SESSION['shippingAddressCity'];
$doImmediateWalletPaymentRequest['shippingAddress']['zipCode'] = $_SESSION['shippingAddressZipCode'];
$doImmediateWalletPaymentRequest['shippingAddress']['country'] = $_SESSION['shippingAddressCountry'];
$doImmediateWalletPaymentRequest['shippingAddress']['state'] = $_SESSION['shippingAddressState'];
$doImmediateWalletPaymentRequest['shippingAddress']['phoneType'] = $_SESSION['shippingAddressPhoneType'];
$doImmediateWalletPaymentRequest['shippingAddress']['phone'] = $_SESSION['shippingAddressPhone'];

// WALLET
$doImmediateWalletPaymentRequest['walletId'] = $_SESSION['3DS_AUTH_PAYMENT_DATA']['walletId'];
$doImmediateWalletPaymentRequest['walletCardInd'] = $_SESSION['3DS_AUTH_PAYMENT_DATA']['walletCardInd'];
$doImmediateWalletPaymentRequest['buyer']['walletId'] = $doImmediateWalletPaymentRequest['walletId'];
$doImmediateWalletPaymentRequest['buyer']['walletCardInd'] = $doImmediateWalletPaymentRequest['walletCardInd'];


// AUTHENTICATION 3DSECURE
$doImmediateWalletPaymentRequest['3DSecure']['md'] = $_POST['MD'];
$doImmediateWalletPaymentRequest['3DSecure']['pares'] = $_POST['PaRes'];

//PRIVATE DATA
for($i=1;$i<=8;$i++){
$privateData = array();
$privateData['key'] = $_SESSION['pvdKey'.$i] ;
$privateData['value'] = $_SESSION['pvdValue'.$i];
$payline->addPrivateData($privateData);
}

// RESPONSE
$doImmediateWalletPaymentResponse = $payline->doImmediateWalletPayment($doImmediateWalletPaymentRequest);
Expand Down
44 changes: 42 additions & 2 deletions examples/web/doWebPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,41 @@

// ORDER
$array['order']['ref'] = $_POST['ref'];
$array['order']['amount'] = $_POST['amount'];
$array['order']['currency'] = $_POST['currency'];
$array['order']['amount'] = $_SESSION['orderAmount'];
$array['order']['currency'] = $_SESSION['orderCurrency'];
$array['order']['date'] = date('d/m/Y H:i');
$array['order']['origin'] = $_SESSION['orderOrigin'];
$array['order']['country'] = $_SESSION['orderCountry'];
$array['order']['taxes'] = $_SESSION['orderTaxes'];
$array['order']['deliveryTime'] = $_SESSION['deliveryTime'];
$array['order']['deliveryMode'] = $_SESSION['deliveryMode'];

// ORDER DETAILS
$item1 = array();
$item1['ref'] = $_SESSION['orderDetailRef1'];
$item1['price'] = $_SESSION['orderDetailPrice1'];
$item1['quantity'] = $_SESSION['orderDetailQuantity1'];
$item1['comment'] = $_SESSION['orderDetailComment1'];
$item1['category'] = $_SESSION['orderDetailCategory1'];
$item1['brand'] = $_SESSION['orderDetailBrand1'];
$item1['subcategory1'] = $_SESSION['orderDetailSubcategory1_1'];
$item1['subcategory2'] = $_SESSION['orderDetailSubcategory2_1'];
$item1['additionalData'] = $_SESSION['orderDetailAdditionalData1'];
$item1['taxRate'] = $_SESSION['orderDetailTaxRate1'];
$payline->addOrderDetail($item1);

$item2 = array();
$item2['ref'] = $_SESSION['orderDetailRef2'];
$item2['price'] = $_SESSION['orderDetailPrice2'];
$item2['quantity'] = $_SESSION['orderDetailQuantity2'];
$item2['comment'] = $_SESSION['orderDetailComment2'];
$item2['category'] = $_SESSION['orderDetailCategory2'];
$item2['brand'] = $_SESSION['orderDetailBrand2'];
$item2['subcategory1'] = $_SESSION['orderDetailSubcategory1_2'];
$item2['subcategory2'] = $_SESSION['orderDetailSubcategory2_2'];
$item2['additionalData'] = $_SESSION['orderDetailAdditionalData2'];
$item2['taxRate'] = $_SESSION['orderDetailTaxRate2'];
$payline->addOrderDetail($item2);

// CONTRACT NUMBERS
$array['payment']['contractNumber'] = $_SESSION['CONTRACT_NUMBER'];
Expand Down Expand Up @@ -89,6 +121,14 @@
// MERCHANT NAME
$array['merchantName'] = $_SESSION['MERCHANT_NAME'];

// PRIVATE DATA
for($i=1;$i<=8;$i++){
$privateData = array();
$privateData['key'] = $_SESSION['pvdKey'.$i] ;
$privateData['value'] = $_SESSION['pvdValue'.$i];
$payline->addPrivateData($privateData);
}

// EXECUTE
$response = $payline->doWebPayment($array);
if(isset($response) && $response['result']['code'] == '00000'){
Expand Down
6 changes: 3 additions & 3 deletions examples/web/doWebPaymentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<span class="help">(required)</span>
</div>
<div class="row">
<label for="amount">Amount</label>
<input type="text" name="amount" id="amount" value="33300">
<label for="amount">Payment amount</label>
<input type="text" name="amount" id="amount" value="<?php echo $_SESSION['PAYMENT_AMOUNT'];?>">
<span class="help">(required)</span>
</div>
<div class="row">
<label for="currency">Currency</label>
<label for="currency">Payment currency</label>
<input type="text" name="currency" id="currency" value="<?php echo $_SESSION['PAYMENT_CURRENCY'];?>">
<span class="help">(required)</span>
</div>
Expand Down

0 comments on commit 9daeadd

Please sign in to comment.