PayPal

 

PayPal is currently in BETA.

PayPal is a popular eWallet, whereby their users are able to send and receive money using funds directly from their wallet and/or from their credit/debit card. Link your existing PayPal account to Judopay, to enable an easy integration of PayPal alongside other payment methods. Reconcile your PayPal payments within the Judopay Portal.

 

Integrating PayPal (BETA)

Step One: Set Up the Web SDK

Contact Developer Support to link your production PayPal account to your Judopay account.
Currently, you are only able to link your production PayPal account. For more details on testing, contact Developer Support.

 To set up the Web SDK on your payment page:

To automatically receive non-breaking changes, you can pin to the minor version (0.0) rather than the current patch version (0.0.25).

  1. Include Judopay's JavaScript page on your website by adding a script tag in your HTML code:

<script     
    src="https://web.judopay.com/js/0.0.25/judopay.min.js">
</script>
  1. Include a div in the iframe page with a unique ID value:

<div id="payment-iframe" width="100%"></div>
  1. Create an instance of the JudoPay object to call the createCardDetails function.

  2. Provide the iframe div ID as a parameter. This function will return a reference to the card fields.:

var judo = new JudoPay("api_token", true);
Var payment = judo.createCardDetails('payment-iframe');

 

Step Two: Display the PayPal Button

To display the PayPal button:

judo.getPayPalButton(configuration)  
.then(button => {   
button.render('#paypal-button-container');  
}) 
.catch(error => console.error(error));

 

For more information on the PayPal button, see Button Render Options.

 

Step Three: Create a Payment Session

Prerequisite

You are using Judopay's API version 6.0.0.0 or higher.

 

Call the Judopay Transaction API to create a paymentSession.

Target endpoint: /paymentSession

HTTP Method: POST


    "judoId": "100915867",
    "amount": 5.10,
    "currency": "GBP",
    "yourConsumerReference": 'your_consumer_reference',
    "yourPaymentReference": 'your_payment_reference'
    }

 

Parameter

Description

judoId

String

Required

Unique ID supplied by Judopay.

Specific to a merchant and/or location.

Format:

  • 100100100

  • Maximum length 9 characters.

  • Do not include spaces or dashes.

amount

Decimal

Required

The amount to process. 

Format:

  • Two decimal places

For currencies using a different structure please contact Judopay for support.

currency

String

Required

The currency of the transaction.

 Any ISO 4217 alphabetic currency code:

  • GBP

  • USD

  • EUR

yourConsumerReference

String

Required

Unique reference to anonymously identify your customer.

Advisable to use GUIDs.

Must be below 40 characters.

yourPaymentReference

String

Required

Your unique reference for this payment. 

Format:

  • Maximum length 50 characters.

This value should be unique in order to protect your customers against duplicate transactions. 

With a server side integration, if a payment reference is not supplied, the transaction will not be processed.

Response Model

 

The paymentSession will expire in 30 minutes, unless an ExpiryDate is set in the /paymentSession request body.

The expiry date must be within one year: "ExpiryDate": "2022-10-06T17:43:21+01:00"

 

For more information, see Transaction API /paymentSession

 

Step Four: Create a PayPal Payment

Currently /payments (immediate capture) is supported when implementing PayPal via the Web SDK.

When the PayPal Button is clicked, the createCardDetails method will be called from the Web SDK.

To make a transaction:

  1. Set the details of the configuration object:

Copy
const configuration = {      
  style: { color: 'blue', height: 34 },      
    merchantId : 'your_paypal_merchant_id',                           
    amount: '1.05',        
    currency: 'GBP',      
    merchantPaymentReference: 'your-payment-reference',       
    judoId: '100915867',                                   
    dynamicDescriptor: ' dynamic-descriptor',                                    
    paymentSession: 'your-payment-session',              
    consumer: {        
        merchantConsumerReference: 'your-consumer-reference',         
        firstName: 'John',                                                
        surname: 'Smith',                                                  
        emailAddress: 'example@domain.com'                                         
            },  
    billingAddress: {        
        address1: 'My house',           
        address2: 'My street',           
        address3: '',           
        town: 'My town',               
        city: 'My city',               
        country: 'My country',            
        postcode: 'TR14 8PA',         
            },  
    shippingAddress: {        
        address1: 'My house',         
        address2: 'My street',         
        address3: '',         
        town: 'My town',             
        city: 'My city',             
        country: 'My country',          
        postcode: 'TR14 8PA',  
        },      
    onSuccess,       
    onError    
};

 

Parameter

Description

style

String

Optional

Set the style for the PayPal button.

For a full list of styling options, see Styling.

merchantId

String

Optional

Your PayPal Merchant ID.

To get your PayPal Merchant ID: Navigate to your PayPal Account Settings -> Business Information -> PayPal Merchant ID:

amount

Float

Required

The amount to process. 

Format:

  • Two decimal places

For currencies using a different structure please contact Judopay for support.

currency

String

Required

The currency of the transaction. Any ISO 4217 alphabetic currency code:

  • GBP

  • USD

  • EUR

merchantPaymentReference

String

Required

Your unique reference for this payment. 

Format:

  • Maximum length 50 characters.

This value should be unique in order to protect your customers against duplicate transactions. If you set this reference it will be used. Otherwise a reference will be internally generated.

judoId

String

Required

Unique ID supplied by Judopay.Specific to a merchant and/or location.

Format:

  • 100100100

  • Maximum length 9 characters.

  • Do not include spaces or dashes.

dynamicDescriptor

String

Optional

The merchant’s ‘Trading Name’ that will appear on the consumer’s statement.

The value is returned in the response within the appearsOnStatement field.

Format:

  • Maximum 25 characters in length.

paymentSession

String

Required

The additional way to authenticate a 3D Secure 2 payments or preauths transaction.

For more information on how to create a paymentSession, see .Option One - Create PaymentSession

consumer

Object

Required

Consumer details:

  • merchantConsumerReference

  • firstName

  • surname

  • emailAddress

billingAddress

Object

Required

Billing address details:

  • address1

  • address2

  • address3

  • town

  • city

  • country

  • postcode

shippingAddress

Object

Optional

Shipping address details:

  • address1

  • address2

  • address3

  • town

  • city

  • country

  • postcode

onSuccess

Object

Required

Callback invoked when the payment is successful.

The response object is provided as a parameter, with the following properties:

  • receiptId

  • orderId

  • transactionType

  • createdAt

  • status

onError

Object

Required

Callback invoked when the payment fails.

The error object is provided as a parameter.

 

Step Five: Handle the Call Backs

Sample Success Response:
const onSuccess = (response) => {  const 
{ receiptId, orderId, transactionType, createdAt, status } = response;  
console.log(`[PayPal Result]      
    receiptId: ${receiptId},      
    orderId: ${orderId},      
    transactionType: ${transactionType},       
    createdAt: ${createdAt},      
    status: ${status}`
    );
};
Sample Error Response:
const onError = (error) => {  
    console.error(error);
};