Sample-monthlypayment

From Barion Documentation
Jump to navigation Jump to search

Online TV - service with monthly payment sample

This example is the input of v2 /Payment/Start API call for an online TV that collects monthly subscription fees. This is the simplest transaction type where the customer pays to the service provider. There are two versions of the call, an initial, where Token payment is initiated and user is redirected to the Payment GUI, and a subsequent call where the token is used to make payments from the initial funding source without user interaction. The second call shall be repeated monthly by the TV, as long as the service is active. The sum may vary from call to call, eg. if the prices drop or new programs are added; the sample shows HBO is added in February.

API Input JSON for initiating Token payment

{
    POSKey: "999FFDDA-04FF-333F-CCCC-345FCB555FFC",
    PaymentType: "Immediate",             
    PaymentWindow: "00:30:00",

    GuestCheckout : "True",
    FundingSources: [ "All" ],    

    InitiateRecurrence : "True", //If set to True, the Token will be recorder
    RecurrenceId : "345986-25646-3456346", //Token provided by merchant for subsequent payments

    PaymentRequestId: "payment-25",
    OrderNumber: "order-25",
    PayerHint: "[email protected]",

    RedirectUrl: "http://shop.example.com/thank-you-page",
    CallbackUrl: "http://shop.example.com/api/callback",

    Locale: "en-US",
    Currency: "EUR",
    
    Transactions: [
        {
            POSTransactionId: "tr-25",
            Payee: "[email protected]",
            Total: 10,
            Items: [
                {
                    Name: "TV Subscription Silver",
                    Description: "Monthly TV subscription fee 'Silver package' for January 2017",
                    Quantity: 1,
                    Unit: "pcs",
                    UnitPrice: 10,
                    ItemTotal: 10,
                    SKU: "tv-mon"
                },
            ]
        }
    ]
}

API Input JSON for subsequent Token payments, with HBO added as an extra

{
    POSKey: "999FFDDA-04FF-333F-CCCC-345FCB555FFC",
    PaymentType: "Immediate",             
    PaymentWindow: "00:30:00",

    GuestCheckout : "True",
    FundingSources: [ "All" ],    

    InitiateRecurrence : "False", //If set to False, the Token will be used to execute the payment
    RecurrenceId : "345986-25646-3456346", //Token previously recorded

    PaymentRequestId: "payment-26",
    OrderNumber: "order-26",
    PayerHint: "[email protected]",

    RedirectUrl: "http://shop.example.com/thank-you-page",
    CallbackUrl: "http://shop.example.com/api/callback",

    Locale: "en-US",
    Currency: "EUR",
    
    Transactions: [
        {
            POSTransactionId: "tr-26",
            Payee: "[email protected]",
            Total: 25,
            Items: [
                {
                    Name: "TV Subscription Silver",
                    Description: "Monthly TV subscription fee 'Silver package' for February 2017",
                    Quantity: 1,
                    Unit: "pcs",
                    UnitPrice: 10,
                    ItemTotal: 10,
                    SKU: "tv-mon"
                },
                {
                    Name: "HBO-OD",
                    Description: "Monthly HBO On Demand subscription fee for February 2017",
                    Quantity: 1,
                    Unit: "pcs",
                    UnitPrice: 15,
                    ItemTotal: 15,
                    SKU: "tv-hbood-mon"
                }
            ]
        }
    ]
}

More Code Samples