Create a Complex Payment

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

Below you will find a full example of a payment request (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",
        "ReturnURLSuccess": null ,
        "ReturnURLFailure": null ,
        "ReturnURLCancel": null ,
        "ReturnURLProcessing": null ,
        "MerchantTransactionID": "s2ptest_i21",
        "OriginatorTransactionID": null,
        "Guaranteed": null ,
        "Language": 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,
                "DiscountValue": 0,
                "Discount": 200,
                "Type": "5"
            }
        ],
        "BillingAddress": {
            "ID": null ,
            "HouseExtension": "25",
            "HouseNumber": "22",
            "StreetNumber": "1",
            "State": "Iasi",
            "Street": "Stargatan",
            "ZipCode": "12345",
            "City": "Ankeborg",
            "Country": "SE"
        },
        "ShippingAddress": {
            "ID": null ,
            "HouseExtension": "25",
            "HouseNumber": "22",
            "StreetNumber": "1",
            "State": "Iasi",
            "Street": "Stargatan",
            "ZipCode": "12345",
            "City": "Ankeborg",
            "Country": "SE"
        },
        "Customer": {
            "ID": null ,
            "MerchantCustomerID": "0125",
            "Email": "youremail@email.com",
            "FirstName": "Example",
            "LastName": "Test",
            "Gender": "1",
            "SocialSecurityNumber": null,
            "Phone": "0765260000",
            "Company": "S2P",
            "DateOfBirth": "19800519"
        },
        "CardDetails": {
            "ID": null ,
            "HolderName": null ,
            "Number": null ,
            "Type": null ,
            "ExpirationMonth": null ,
            "ExpirationYear": null ,
            "SecurityCode": null ,
            "Installments": null 
        },
        "TokenLifetime": 10,
        "Details": {
            "AccountNumber": null,
            "AccountHolder": null ,
            "IBAN": null ,
            "Address": null ,
            "BIC": null ,
            "SerialNumbers": null ,
            "Wallet": null ,
            "PayerCountry": null ,
            "PayerEmail": null ,
            "PayerPhone": null ,
            "PayerID": null ,
            "BankCode": null ,
            "Pin": null ,
            "BankName": null ,
            "BankSortCode": null ,
            "BankAccountNumber": null ,
            "SocialSecurityNumber": null ,
            "BillingCycleStart": null ,
            "BillingCycleEnd": null ,
            "UnsubscribeInstructions": null ,
            "IsOffline": null ,
            "StoreName": null ,
            "StoreID": null ,
            "TerminalID": null ,
            "CustomerLoginID": null ,
            "PaidAmount": null ,
            "PaidCurrency": null ,
            "ProviderExchangeRate": null ,
            "PayerBankAccountID": null ,
            "IsMobileApp": null ,
            "Is3rdParty": null ,
            "RedirectUrl": null ,
            "IsMobileDevice": null ,
            "AvailableBalanceAsStr": null ,
            "CurrentBalanceAsStr": null ,
            "Installments": null ,
            "ShoppingCartType": null ,
            "PrepaidCard": "2222222222",
            "PrepaidCardPIN": "3333",
            "ReferenceNumber": "test_test_test1"
        },
        "Capture": null ,
        "PreapprovalDetails": {
            "PreapprovedMaximumAmount": null ,
            "MerchantPreapprovalID": null ,
            "Frequency": null ,
            "PreapprovalDescription": null ,
            "PreapprovalType": null ,
            "PreapprovalReturnURL": null
        },
        "SplitRequest": {
            "ID": null ,
            "SiteID": null ,
            "Amount": null ,
            "MerchantTransactionID": null ,
            "OriginatorTransactionID": null 
        },
        "RegulationAccept": null ,
        "Pin": null ,
        "SiteID": null ,
        "ProviderTransactionID": null ,
        "OriginalProviderTransactionID": null ,
        "RootProviderTransactionID": null ,
        "CustomParameters": {
            "echo": "test123asdfghddjkl;"
        }
    }
}

Response:

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

{
    "Payment": {
        "ID": 4409803,
        "InvalidRequestID": null, 
        "ReturnURLSuccess": null, 
        "ReturnURLFailure": null, 
        "ReturnURLCancel": null,
        "ReturnURLProcessing": null,
        "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": {
            "ID": null,
            "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,
            "Address": null,
            "Pin": null,
            "BankAccountNumber": null,
            "IsOffline": null,
            "StoreName": null,
            "StoreID": null,
            "TerminalID": null,
            "IsMobileApp": null,
            "Is3rdParty": null,
            "RedirectUrl": null,
            "IsMobileDevice": null,
            "PayerID": null,
            "AvailableBalanceAsStr": null,
            "CurrentBalanceAsStr": null,
            "Installments": null,
            "ShoppingCartType": 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": {
            "Address": null,
            "SortCode": null,
            "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": {
                        "Code": null,
                        "Info": null
                               }
        },
        "MethodTransactionID": null,
        "FraudCheckDetails": {
                               "Status": null,
                               "Score": null,
                               "Reason": null
                                },
        "TokenLifetime": 10,
        "OriginalMerchantTID": null,
        "Unknown": null,
        "ExecutionDate": null,
        "SplitResponse": {
                                  "ID": null,
                                  "PaymentID": null,
                                  "SiteID": null,
                                  "MerchantTransactionID": null,
                                  "OriginatorTransactionID": null,
                                  "InputDateTime": null,
                                  "Amount": null,
                                  "Currency": null,
                                  "CapturedAmount": null,
                                  "Status": {
                                           "ID": 1,
                                            "Info": "Open",
                                            "Reasons": {
                                                        "Code": null,
                                                        "Info": null
                                                 }
        },
        "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,
        "DiscountValue": 0,
        "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",
        "ReturnURLSuccess": null,
        "ReturnURLFailure": null,
        "ReturnURLCancel": null,
        "ReturnURLProcessing": null,
        "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}$;"
                }
            ]
        },
        "Fraud": null,
        "MethodTransactionID": null,
        "OriginalMerchantTID": null,
        "Unknown": false,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null,
        "Splits": null 
    }
}