Arborescence des pages

Vous regardez une version antérieure (v. /display/DT/PW+-+Widget+Integration) de cette page.

afficher les différences afficher l'historique de la page

« Afficher la version précédente Vous regardez la version actuelle de cette page. (v. 7) afficher la version suivante »

Contents


    



Integration

The Widget integration (column / tab or Lightbox mode), takes place in only 3 steps :

  1. Initialization of payment : from your server you use the doWebPayment function of Web Payment API to initiate a payment on Payline payment pages.
  2. From web page, add a script and  <DIV> tag in body of your web page : Payline will use that tag to display the payment form.
  3. Payment Result : from your server you use the getWebPaymentDetails function of  Web Payment API to get payment result.

The minimum HTML page for generating a payment form is as follows:

Code HTML
<html>
 <head>
   <script src="https://homologation-payment.payline.com/scripts/widget-min.js"></script>
 </head>
 <body>
 <div id="PaylineWidget" 
    data-token="the token obtained in doWebPayment Response" 
    data-template="column"
    data-embeddedredirectionallowed="false" 
 />
 </body>
</html>

The data-token is the session token for authentication and is obtained in response to the request to initialize a payment (doWebPayment). In order to avoid that a new initialization is performed during each refresh of the page, you must either use a session on your server to store it, or check if the current URL already contains a payment token in a GET parameter named paylinetoken. Here is an example to reuse the token present in the URL:

Code PHP
<?php $paylineToken = ( is_empty($_GET['paylinetoken']) ) ? createNewWebPayment() : $_GET['paylinetoken']; ?>

Additional attributes that you can use in the <div> tag allow you to customize the display of the form. For example; if you do not want the payment form to appear automatically when viewing your page :

ParamètreDescriptionvaleur
data-template
The name of the template to use for initializing the form.
  • tab
  • column
  • lightbox
  • shortcut
data-auto-init
Defines whether the form should initialize as soon as the web page has finished loading (auto-init to "true"), or if it must wait for an initialization request (auto-init to "false")
data-embeddedredirectionallowed

Used to present the 3DSecure authentication page in iframe mode (integrated in the payment page) value true or in redirection mode (full-screen redirection in a new page) value false.

Check with the support that the bank is in the white list for authorization in lightbox.

  • true
  • false

data-partnerreturnurl

The parameter allows you to specify a return url for a defined list of partners, for now: AmazonPay

When the buyer clicks on the AmazonPay button, he is redirected to the partner to authenticate. Once authenticated, it is redirected to the specified URL.

<div id="PaylineWidget"
data-template="shortcut"
data-partnerreturnurl="https://maboutique.com/checkout">


According to the parameters, here are the examples of integration :

InShop Tab mode InShop Column mode LightBox mode Shortcut mode 


Payline forces column  page display  of payment pages when you use tab mode and the size of the device used by the consumer is too small to display properly. This enhancement simplifies your technical integration when you have a "responsive desktop / mobile" store.

Style sheet

To get the form of the payment form formatted, you have to integrate the CSS Payline style sheet by adding the following line in the <head> tag:

Code HTML
<link href="https://homologation-payment.payline.com/styles/widget-min.css" rel="stylesheet" />

The URLs of the script and CSS are different between the test and production environments. We recommend that you configure them in environment variables.

JavaScript API

In order to interact with the payment form, Payline offers a JavaScript API to keep your hand on the form. The available functions of your IS are:

FunctionDescriptionExample
endToken()

Ends the life of the web session token (token obtained via DoWebPayment).

Parameters  :
(  additionnalData : any,
  callback : Function,
  spinner : any,
  handledByMerchant : boolean )


Payline.Api.endToken(null, function() {
window.location.href = Payline.Api.getCancelAndReturnUrls().cancelUrl;
}, null, true);

// valuing handledByMerchant to true, 
// the payment session will be associated with return code 02014
// returned by getWebPaymentDetails.
// Otherwise the code 02319 is returned.
finalizeShortCut()Triggers the finalization of the payment ShortCut (to call in context.state PAYMENT_TRANSITIONAL_SHORTCUT)
getBuyerShortCut()

Returns a complex object containing buyer data from the shortcut partner.

This function is available in a context of state = PAYMENT_TRANSITIONAL_SHORTCUT.

{  "firstName": "DUPONT",
  "lastName": "Jean",
   "email": "jean.dupont@yopmail.com",
   "cityName": "Aix",
   "country": "FR",
   "street1": "5 rue de Marseille",
   "street2": "Batiment 2",
  "zipCode": "13390"
}
getCancelAndReturnUrls()Returns a complex object containing the returnUrl and the cancelUrl from the DoWebPayment
For example, you can create a cancel button that triggers the following actions:


function cancel() {
  Payline.Api.endToken();
// end the token's life 

window.location.href =
Payline.Api.getCancelAndReturnUrls().cancelUrl;
// redirect the user to cancelUrl

getContextInfo(key)Returns a context information with its key from the following values:
{  "PaylineAmountSmallestUnit": 100,
  "PaylineCurrencyDigits": 2,
   "PaylineCurrencyCode": "EUR",
   "PaylineBuyerFirstName": "Jean",
   "PaylineBuyerLastName": "DUPONT",
   "PaylineBuyerShippingAddress.street2": "Batiment 2",
   "PaylineBuyerShippingAddress.country": "FR",
   "PaylineBuyerShippingAddress.name": "Perso",
   "PaylineBuyerShippingAddress.street1": "5 rue de Marseille",
   "PaylineBuyerShippingAddress.cityName": "Aix",
   "PaylineBuyerShippingAddress.zipCode": "13390"
   "PaylineBuyerMobilePhone": "0605040302",
"PaylineBuyerShippingAddress.phone": "0605040302",
   "PaylineBuyerIp": "127.126.125.100",
   "PaylineFormattedAmount": "EUR1.00",
   "PaylineOrderDate": "05/26/2008 10:00",
   "PaylineOrderRef": "170630111901",
   "PaylineOrderDeliveryMode": "4",
   "PaylineOrderDeliveryTime": "1",
   "PaylineOrderDetails": [
     { "ref": "1",
       "price": 998,
       "quantity": 1,
       "comment": "commentaire1",
       "category": "1",
       "brand": "66999",
       "subcategory1": "",
       "subcategory2": "",
       "additionalData": ""
     }
   ],
 }

getCssIframeWhiteList()

Returns the list of accepted CSS primitives for stylizing protected fields (Credit Card, CVV, ...)

getCssIframeWhiteList(): any

getFragmentedPaymentInfo()

In a context of fragmented payment (Carrefour Gift Card, soon ANCV, ...), allows to recover the various payments registered so far.

{

                "amount": "100,00 EUR", // Montant global de la commande
                "amountLeft": "50,00 EUR", // Montant restant à payer
                "recaps": [

                               503200XXXXXXXXX1166: "50,00 EUR"

                ]

}

getLanguage()Return the widget's language key (passed in the DoWebPayment frame)"en", "fr", …
getOrderInfos()

Retrieves a complex object containing:

  • the amount with the currency all formatted
  • the order reference
  • the name of the point of sale
  • a complex object representing the address with:
    • address1
    • address 2
    • city
    • Postal code
Payline.Api.getOrderInfos()

We get :

Object {
   amountCurrency: "15.00 EUR"
   orderRef: "order-123456789"
   pointOfSale: "POS_Demo"
   pointOfSaleAddress:
Object {
       addess1: "260 rue Claude Nicolas Ledoux"
       addess2: "ZI Les Milles"
       city: "Aix en Provence"
       zipCode: "13290" }}

getRecurringDetails()

Retrieves the payment schedule. 

See the integration details: payment N times and recurring payment.

To display the schedule N times:

Payline.Underscore.forEach( Payline.Api.getRecurringDetails().schedules, function(key, value) { console.log(value + " " + key) } );



To retrieve recurring payment details:

Payline.Api.getRecurringDetails().schedules;


getToken()

Returns the current token with which the Widget was initialized.

getToken()
hide()Request to hide the payment form.
Payline.Api.hide(): void

init()

Request to initialize the payment form. During initialization, the Payline widget builds the form according to the context of the payment request: amount, proposed payment method, etc.


isSandBox()Allows to know the environment: production or homologation. The function returns true or false.
Payline.Api.isSandbox(); 
reset()Totally reset the widget with the token and template passed as parameter.
Payline.Api.reset(token: string = null, template: string = null): void


show()Request to display the payment form.
Payline.Api.show(): void
toggle()If the widget is displayed, this method hides it, otherwise it displays it.
updateWebpaymentData()Update of the payment session information (addresses, amount, ...) after the initialization of the widget and before the finalization of the payment.
Payline.Api.updateWebpaymentData(Payline.Api.getToken(), JSON, callBack);

Contents of the JSON:  
{
"payment": {
    "amount": "252",
    "currency": "978" },
"order":
  {
    "amount": "255",
    "currency": "978",
    "ref": "123",
    "deliveryTime ": "1",
    "deliveryMode ": "1",
    "deliveryExpectedDate": "30/09/2016",
    "deliveryExpectedDelay": "1",
    "details": {
        "details":

     [  { "ref": "00001 (ref1)",
          "price": "50",
         "quantity": "1",
         "comment": "comment1 (rem1)",
         "category": "1",
         "brand": "My HERMES (brd1)",
         "subcategory1": "BOSS",
         "subcategory2": "MONTRE",
         "additionalData": "LegalAge=18;Discount=0105",
         "taxRate ": "1234"
        },
        { "ref": "00002 (ref2)",
          "price": "50",
          "quantity": "1",
          "comment": "comment2 (rem2)",
          "category": "1",
          "brand": "My HERMES (brd2)",
          "subcategory1": "HERMES",
          "subcategory2": "FOULARD",
          "additionalData": "LegalAge=18;Discount=0105",
          "taxRate ": "1234"
         },
         { "ref": "00003 (ref3)",
         "price": "50",
         "quantity": "1",
         "comment": "comment3 (rem3)",
         "category": "1",
         "brand": "My HERMES (brd3)",
         "subcategory1": "HERMES",
         "subcategory2": "MONTRE",
         "additionalData": "LegalAge=19;Discount=0105",
         "taxRate ": "1234"
          }
      ]
    }
  },
"buyer": {
"shippingAddress": {
"title": "2",
"name": "BUYER (shipping)",
"lastName": "PAYLINE (shipping)",
"firstName": "Validation Team (shipping)",
"street1": "Colombus Circle (shipping)",
"street2": "Central Park (shipping)",
"cityName": "New York (shipping)",
"zipCode": "NY 10023",
"country" : "FR",
"phone" : "0123458789",
"state": "NYC (state)",
"county": "Upper East Side (shipping)",
"phoneType": "1"
},
"billingAddress": {
"title": "3",
"name": "BUYER (billing)",
"lastName": "TUPU (billing)",
"firstName": "Christian (billing)",
"street1": "15 rue LEDOUX (billing)",
"street2": "Z.I. les Milles (billing)",
"cityName": "Aix-en-Provence (billing)",
"zipCode": "13902",
"country" : "FR",
"phone" : "0223458789",
"state": "FRANCE (state)",
"county": "Bouches-du-Rhone",
"phoneType": "4"
}
}
}


Example to hide and then display the payment form:

  • Payline.Api.hide (): void
  • Payline.Api.show (): void

Example to change the label on Pay button:

  • You can change it using the JavaScript statement Payline.jQuery ('. Pl-pay-btn'). Text (' button label ');

Example to change the label on Pay button:

  • You must recover the amount  in the language of the buyer via a call to the function Payline.Api.getContextInfo ('PaylineFormattedAmount');
  • You can change the text of the button with the function:  Payline.jQuery ("<class of the element to modify>"). Text ('<replacement text>'));

(avertissement)  Warning, always use the classes for these instructions, never the id of the element that is generated on the fly

  • To display the amount in the button. The statement is therefore Payline.jQuery (".paylineWidget .pl-pay-btn, .PaylineWidget .pl -btn"). Text ('Pay' + Payline.Api.getContextInfo ('PaylineFormattedAmount'));
  • This statement must be called when the widget triggers the " didshowstate " event with the PAYMENT_METHODS_LIST state .

CSS customization

Customizing the style of the payment form is possible by overloading the default style sheet provided by Payline. The possibilities of customization are endless, here are some simple examples:

DescriptionParamètre
The color of the banner Sign
#PaylineWidget .pl-header-title-wrapper { background-color: #ABCDEF; }
The color of the sign's text
#PaylineWidget .pl-header-title-content h4 { color: #ABCDEF; }
The color of the text of the amount to be paid
#PaylineWidget .pl-header-title-content p { color: #ABCDEF; }
The color of the payment button
#PaylineWidget .pl-pay-btn { background-color: #ABCDEF; }
#PaylineWidget .pl-pay-btn:hover { background-color: #ABCDEF; }
The background color of the form
#PaylineWidget .pl-body { background-color: #ABCDEF; }
The color of the area of ​​payment
#PaylineWidget .pl-pmContainer {
  background-color: #ABCDEF;
  border-color: #ABCDEF; }
The color of the button close the lightbox
#PaylineWidget .pl-icon-close { color: #ABCDEF; }

The size of the window is optimized in the following configuration:

  • minimum width of the div PaylineWidget: 500px
  • maximum recommended width of the PaylineWidget div: 900px

Below and above the indicated dimensions, it is recommended to adjust the margins and fields.

To hide the labels, you must remove the labels and delete the margin to the left of the fields.

.PaylineWidget.pl-container-default .pl-pmContainer .pl-label-input 
{ display: none;} .PaylineWidget.pl-container-default .pl-pmContainer .pl-input-group-container
 { margin-left: 0; }

Payline proposes to reduce the margins in order to adjust the window above 900px wide, for that it is enough to decrease the width of the label (xx%), and to decrease the margin to the left of the fields (yy% by default 30% ).
.PaylineWidget.pl-container-default .pl-pmContainer .pl-label-input
{ width: xx%; } .PaylineWidget.pl-container-default .pl-pmContainer .pl-input-group-container,
.PaylineWidget.pl-container-default .pl-form-container label.pl-remember-container
{ margin-lef: yy%; }

For more information on the list of tags, find the information here.

Life cycle callback

The customization functions of the Widget in lightbox mode and in-shop mode (tab / column).

For the merchant to follow the evolution of the widget in his page, Payline offers Callback. These Callbacks will be called by the widget as it runs synchronously.

To use these callbacks, the marketer uses the usual mechanism for setting the widget, the data- * attributes in the PaylineWidget div. The passed value must correspond to a classic JavaScript function, declared in the Window scope, as in the following example:

<html>
	<head>
		<!-- Import from widget, ... -->
		<script>
			function maFonction() {
				// Actions to do
			}
		</script>
	</head>
	<body>
		<div id="PaylineWidget" data-token="123" data-event-nomdeletape="maFonction"/>
	</body>
</html>

In the previous example, the function "myFunction" will be called when the life cycle of the widget reaches the step "chunkname".


The steps for which you can specify a Callback are:

Callback IDDescriptionParametersReturn valuesFrom version

data-embeddedredirectionallowed

Set to 'false' to prevent the ACS 3DS from being embedded in iframe in the Widget, and force a redirection to it.

This makes it possible to test the two use cases (3DS via iframe or via redirection).

true / false

data-event-willinitThe widget has loaded on the browser and is about to initialize..

4.46.1
data-event-willshowThe widget has made its first initialization and is about to appear. This event occurs before the widget has recovered from the server.

4.46.1
data-event-finalstatehasbeenreachedThe widget will show the user an end state (where no more interaction is possible) to the buyer.

The name of the state reaches.

Example of a past object:

{
	state: "PAYMENT_SUCCESS"
}

Voir § suivant pour toutes les valeurs possibles

If the callback of the merchant returns

false

then the widget will not handle the new state.

4.46.1
data-event-didshowstateThe widget has recovered its status from the server and displayed the result.

The name of the state that appeared

Example of a past object :

{
	state: "PAYMENT_METHODS_LIST"
}

See below for all possible values.


4.49
data-event-willdisplaymessageManage the message display

The callback can take as argument a complex object of the form:

{ id: [l'id du champ message], type: [le type de message (voir les 
valeurs possibles), key: [la clé du message à afficher (voir les valeurs
 possibles)], message: [le message] }

Possible values ​​for the "type": 
success, info, error, warn.

    • TRUE: the widget behavior is not changed, ie the widget will still display the message
    • FALSE: the behavior of the widget is impacted, the widget will not display the message
4.50
data-event-willremovemessageManagement of the withdrawal of the message

The callback can take as argument a complex object of the form:

{ id: [l'id du champ message] }
    • TRUE: the behavior of the widget is not changed, ie the widget will still remove the message;
    • FALSE: the behavior of the widget is impacted, the widget will not remove the message.
4.50
data-event-beforepayment

Event when clicking the Pay button, after the data validation and before Payline completes the transaction.

Then Payline triggers the final eventStateHasBeenReached?

The event can be triggered several times during a payment session, for example when the buyer clicks on the Wallet and he has to enter the CVV and then clicks a second time on Pay. Then the event will have been triggered twice. The merchant must be able to manage the idempotency of this event.

The event is not raised during a call to Payline.Api.finalizeShortcut ()

<div id="PaylineWidget"
    data-token="1fe9zY4eaJo0VPJSM1571456927334471"
    data-template="lightbox"
    data-event-beforepayment="myBusinessFunction">
</div>
<script>
    function myBusinessFunction()
{    -- Check values         
     -- Provisioning         
     -- If Provisioning OK return true         
     -- Return false     }
</script>
  • TRUE: triggered payment
  • FALSE: secure payment
4.54.1
Possible values ​​for "state"

The set of possible values ​​for the "state" property of the objects passed in parameter by the callbacks:

ID StatusDescriptionFinalRelease
PAYMENT_METHODS_LISTThe payment session is valid and the list of payment methods is displayed.No
PAYMENT_CANCELEDThe session was invalidated at the request of the merchant and a failure message is displayed.Yes
PAYMENT_SUCCESSThe payment session is over and a ticket is displayed.Yes
PAYMENT_FAILUREThe payment session is over and a failure message is displayed.Yes
PAYMENT_FAILURE_WITH_RETRYThe payment session is over, a failure message is displayed along with a button proposing to use another payment method.No
TOKEN_EXPIREDThe payment session is complete, a failure message is displayed indicating the expiration of the payment session.Yes
BROWSER_NOT_SUPPORTEDThe browser is detected as incompatible, a screen offers the buyer to switch to the classic payment pages.Yes
PAYMENT_METHOD_NEEDS_MORE_INFOSThe means of payment selected by the user indicates that it is necessary to confirm information (CV for wallet, validation of credit file etc ..).No

PAYMENT_REDIRECT_NO_RESPONSE

The payment request completed in redirection request (3DS authentication, partner such as Paypal).No
MANAGE_WEB_WALLETSame PAYMENT_METHOD_LIST but for the management of the portfolios.No

ACTIVE_WAITING

A payment has been started and new information is expected to continue

No

4.51

PAYMENT_CANCELED_WITH_RETRY

The buyer has canceled his payment, either via our pages or via the pages of a partner on which he was redirected, but he has the possibility to choose a new means of payment

No

4.51

PAYMENT_ONHOLD_PARTNER

The payment method will answer us later, we indicate to the buyer that he will get the answer from the merchant

Yes

4.51

PAYMENT_SUCCESS_FORCE_TICKET_DISPLAY

The buyer has successfully completed his payment, and automatic redircetion is disabled (ticket display)

Yes

4.51

PAYMENT_METHODS_LIST_SHORTCUT

The buyer is on the list of shortcut payment method

No

4.51

PAYMENT_TRANSITIONAL_SHORTCUT

The intermediate state after a shortcut request (getting buyer data: buyer, shippingAddress, billingAddress via API JS)

No

4.51

Features Fee Management

The expense management is present on the payment form and corresponds to the Transaction insert:

Back office : Configure the payment methodBack office : transaction detailsPayment page

Fee management excludes in the following cases:

  • Wallet Payment
  • ShortCut Payment
  • Payment Rec / NX



  • Aucune étiquette