Create a Complex Payment

Definition: POST https://paytest.smart2pay.com/v1/payments

Below you will find a full example of a payment request for Klarna payment method (with Success and Bad response). The parameters of the payment are sent in the message body as a JSON object.

A 201 HTTP response (Created) is returned if the payment was correctly initialized.

For more information about status codes, please go to Basic HTTP Status Codes.

Request:

POST https://paytest.smart2pay.com/v1/payments
Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=

{
  "Payment": {
    "Amount": 980,
    "Currency": "EUR",
    "Description": "smart2pay test",
    "MethodID": 1078,
    "MethodOptionID": 0,
    "PreapprovalID": 0,
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "MerchantTransactionID": "s2ptest_i21",
    "OriginatorTransactionID": null,
    "SkinID": 11,
    "RedirectInIframe": true,
    "RedirectMerchantInIframe": true,
    "IncludeMethodIDs": [75,23,1],
    "ExcludeMethodIDs": [9,28],
    "PrioritizeMethodIDs": [1,23,73],
    "ClientIP": "82.208.151.137",
    "Articles": [
      {
        "MerchantArticleID": "1231",
        "Name": "TEST",
        "Quantity": 1,
        "Price": 1000,
        "VAT": 1000,
        "Discount": 200,
        "Type": 5
        }
    ],
    "BillingAddress": {
      "HouseExtension": "25",
      "HouseNumber": "22",
      "StreetNumber": "1",
      "State": "Iasi",
      "Street": "Stargatan",
      "ZipCode": "12345",
      "City": "Ankeborg",
      "Country": "SE"
    },
    "ShippingAddress": {
      "HouseExtension": "25",
      "HouseNumber": "22",
      "StreetNumber": "1",
      "State": "Iasi",
      "Street": "Stargatan",
      "ZipCode": "12345",
      "City": "Ankeborg",
      "Country": "SE"
    },
    "Customer": {
        "MerchantCustomerID": "0125",
        "Email": "youremail@email.com",
        "FirstName": "Example",
        "LastName": "Test",
        "Gender": "1",
        "SocialSecurityNumber": null,
        "Phone": "0765260000",
        "Company": "S2P",
        "DateOfBirth": "19800519"
        },
    "TokenLifetime": 10,
    "Details": {    
      "PrepaidCard": "2222222222",
      "PrepaidCardPIN": "3333",
      "ReferenceNumber": "test_test_test1"
      },
    "CustomParameters": {
        "echo": "test123asdfghddjkl;"
      }
   }
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8

{
    "Payment": {
        "ID": 4409803,
        "SkinID": 11,
        "ClientIP": "82.208.151.137",
        "Created": "20190311153115",
        "MerchantTransactionID": "s2ptest_i21",
        "OriginatorTransactionID": null,
        "Amount": "980",
        "Currency": "EUR",
        "CapturedAmount": null,
        "ReturnURL": "http://demo.smart2pay.com/redirect.php",
        "Description": "smart2pay test",
        "MethodID": 1078,
        "MethodOptionID": null,
        "IncludeMethodIDs": [
            75,
            23,
            1
        ],
        "ExcludeMethodIDs": [
            9,
            28
        ],
        "PrioritizeMethodIDs": [
            1,
            23,
            73
        ],
        "SiteID": 30201,
        "NotificationDateTime": null,
        "Customer": {
            "MerchantCustomerID": "0125",
            "Email": "youremail@email.com",
            "FirstName": "Example",
            "LastName": "Test",
            "Gender": "1",
            "SocialSecurityNumber": null,
            "Phone": "0765260000",
            "Company": "S2P",
            "DateOfBirth": "19800519"
        },
        "BillingAddress": {
            "ID": 896,
            "City": "Ankeborg",
            "ZipCode": "12345",
            "State": "Iasi",
            "Street": "Stargatan",
            "StreetNumber": "1",
            "HouseNumber": "22",
            "HouseExtension": "25",
            "Country": "SE"
        },
        "ShippingAddress": {
            "ID": 896,
            "City": "Ankeborg",
            "ZipCode": "12345",
            "State": "Iasi",
            "Street": "Stargatan",
            "StreetNumber": "1",
            "HouseNumber": "22",
            "HouseExtension": "25",
            "Country": "SE"
        },
        "Articles": [
            {
                "MerchantArticleID": "1231",
                "Name": "TEST",
                "Quantity": 1,
                "Price": "1000",
                "VAT": "1000",
                "Discount": "200",
                "Type": "5",
                "TaxType": 0,
                "DiscountValue": "0"
            }
        ],
        "Details": {
            "AccountNumber": null,
            "AccountHolder": null,
            "IBAN": null,
            "BIC": null,
            "PrepaidCard": "2222222222",
            "PrepaidCardPIN": "3333",
            "SerialNumbers": null,
            "Wallet": null,
            "ReferenceNumber": null,
            "PayerCountry": null,
            "PayerEmail": null,
            "PayerPhone": null,
            "BankCode": null,
            "BankName": null,
            "BankSortCode": null,
            "SocialSecurityNumber": null,
            "BillingCycleStart": null,
            "BillingCycleEnd": null,
            "UnsubscribeInstructions": null,
            "CustomerLoginID": null,
            "PaidAmount": null,
            "PaidCurrency": null,
            "ProviderExchangeRate": 0,
            "PayerBankAccountID": null
        },
        "ReferenceDetails": {
            "BankCode": null,
            "BankName": null,
            "EntityID": null,
            "EntityNumber": null,
            "ReferenceID": null,
            "ReferenceNumber": "test_test_test1",
            "SwiftBIC": null,
            "AccountCurrency": null,
            "AccountNumber": null,
            "AccountHolder": null,
            "IBAN": null,
            "AmountToPay": null,
            "QRCodeURL": null,
            "Instructions": null,
            "BoletoURL": null
        },
        "CustomParameters": null,
        "PreapprovalID": 0,
        "Status": {
            "ID": 1,
            "Info": "Open",
            "Reasons": null
        },
        "MethodTransactionID": null,
        "TokenLifetime": 10,
        "Capture": null,
        "RedirectInIframe": true,
        "RedirectMerchantInIframe": true,
        "PreapprovalDetails": null,
        "RedirectURL": "https://apitest.smart2pay.com/Home?PaymentToken=DAFAE9E7AA8929219DDA82BF3DF2B151.4409803"
    }
}

In case of an API error, an HTTP 4xx (you did something wrong) or HTTP 5xx (we did something wrong) response is returned.

For more information about the reasons of a wrong request response see our section GlobalPay Return Codes.

Request:

POST https://paytest.smart2pay.com/v1/payments
Authorization: Basic MzAyMDE6KzlLZUd6S0Y3VzhTLzc5YTVSMzNZSlVnN0U3V0ZOY1piakdmekxWM2JYU25GQ095RnQ=

{
  "Payment": {
    "Amount": 980,
    "Currency": "EUR",
    "Description": "smart2pay test",
    "MethodID": 1078,
    "MethodOptionID": 0,
    "PreapprovalID": 0,
    "ReturnURL": "http://demo.smart2pay.com/redirect.php",
    "MerchantTransactionID": "s2ptest_i22",
    "OriginatorTransactionID": null,
    "SkinID": 11,
    "RedirectInIframe": true,
    "RedirectMerchantInIframe": true,
    "IncludeMethodIDs": [75,23,1],
    "ExcludeMethodIDs": [9,28],
    "PrioritizeMethodIDs": [1,23,73],
    "ClientIP": "82.208.151.137",
    "Articles": [
      {
        "MerchantArticleID": "1231",
        "Name": "TEST",
        "Quantity": 1,
        "Price": 1000,
        "VAT": 1000,
        "Discount": 200,
        "Type": 5
        }
    ],
    "BillingAddress": {
      "HouseExtension": "25",
      "HouseNumber": "22",
      "StreetNumber": "1",
      "State": "Iasi",
      "Street": "Stargatan",
      "ZipCode": "12345",
      "City": "Ankeborg",
      "Country": "SEE"
    },
    "ShippingAddress": {
      "HouseExtension": "25",
      "HouseNumber": "22",
      "StreetNumber": "1",
      "State": "Iasi",
      "Street": "Stargatan",
      "ZipCode": "12345",
      "City": "Ankeborg",
      "Country": "SE"
    },
    "Customer": {
        "MerchantCustomerID": "0125",
        "Email": "youremail@email.com",
        "FirstName": "Example",
        "LastName": "Test",
        "Gender": "1",
        "SocialSecurityNumber": null,
        "Phone": "0765260000",
        "Company": "S2P",
        "DateOfBirth": "19800519"
        },
    "TokenLifetime": 10,
    "Details": {    
      "PrepaidCard": "2222222222",
      "PrepaidCardPIN": "3333",
      "ReferenceNumber": "test_test_test1"
      },
    "CustomParameters": {
        "echo": "test123asdfghddjkl;"
      }
   }
}

Response:

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8

{
    "Payment": {
        "ID": 4409804,
        "SkinID": 11,
        "ClientIP": null,
        "Created": "20190311153257",
        "MerchantTransactionID": "s2ptest_i22",
        "OriginatorTransactionID": null,
        "Amount": "980",
        "Currency": "EUR",
        "CapturedAmount": null,
        "ReturnURL": "http://demo.smart2pay.com/redirect.php",
        "Description": "smart2pay test",
        "MethodID": 1078,
        "MethodOptionID": null,
        "IncludeMethodIDs": [
            75,
            23,
            1
        ],
        "ExcludeMethodIDs": [
            9,
            28
        ],
        "PrioritizeMethodIDs": [
            1,
            23,
            73
        ],
        "SiteID": 30201,
        "NotificationDateTime": "20190311153257",
        "Customer": null,
        "BillingAddress": null,
        "ShippingAddress": null,
        "Articles": null,
        "Details": null,
        "ReferenceDetails": null,
        "CustomParameters": null,
        "PreapprovalID": 0,
        "Status": {
            "ID": 4,
            "Info": "Failed",
            "Reasons": [
                {
                    "Code": "147",
                    "Info": "Address details are invalid (BillingAddress)Country - RegEx: ^[a-zA-Z]{2}$;"
                }
            ]
        },
        "MethodTransactionID": null,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null
    }
}