Create a Recurring Payment

Definition: POST /v1/payments/recurrent

A recurring payment is created in the same manner a one-off payment is created. In addition, you need to send the PreapprovalID (the PreapprovalID or Mandate received when you created/opened a preapproval) and the information specific to each payment method.

For recurring Card payments (69) and Klarna Invoice (75), you do not need a preapproval, you only need to send in the preapprovalID field the initial GlobalPay PaymentID.

If you want to get more information about a recurring payment you can use the same actions like for a one-off payment. Please check Get information on a specific payment, for more details.

  • Checkout the below example of a recurring payment request for MercadoPago (46):

    Request:

    POST https://paytest.smart2pay.com/v1/payments/recurrent
    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
     "Payment": {
       "PreapprovalID":4217,
       "MerchantTransactionID": "s2ptest_fg109",
       "Amount": 100,
       "Currency": "BRL",
       "MethodID": 46,
       "Customer": {  
         "Email" : "test_user_83022133@testuser.com"
        },
       "BillingAddress":{
         "Country": "BR"
          }
       }
    }

    Response:

    HTTP/1.1 201 Created
    Content-Type: application/json; charset=utf-8
    
    {
      "Payment": {
        "ID": 3009283,
        "SkinID": null,
        "ClientIP": null,
        "Created": "20170804065834",
        "MerchantTransactionID": "s2ptest_fg109",
        "OriginatorTransactionID": null,
        "Amount": "100",
        "Currency": "BRL",
        "CapturedAmount": null,
        "ReturnURL": null,
        "Description": "",
        "MethodID": 46,
        "MethodOptionID": null,
        "IncludeMethodIDs": null,
        "ExcludeMethodIDs": null,
        "PrioritizeMethodIDs": null,
        "SiteID": 30201,
        "NotificationDateTime": null,
        "Customer": {
          "ID": 1196,
          "MerchantCustomerID": null,
          "Email": "test_user_83022133@testuser.com",
          "FirstName": null,
          "LastName": null,
          "Gender": null,
          "SocialSecurityNumber": null,
          "Phone": null,
          "Company": null,
          "DateOfBirth": null
        },
        "BillingAddress": {
          "ID": 335,
          "City": null,
          "ZipCode": null,
          "State": null,
          "Street": null,
          "StreetNumber": null,
          "HouseNumber": null,
          "HouseExtension": null,
          "Country": "BR"
        },
        "ShippingAddress": null,
        "Articles": null,
        "Details": null,
        "ReferenceDetails": null,
        "CustomParameters": null,
        "PreapprovalID": 4217,
        "Status": {
          "ID": 2,
          "Info": "Success",
          "Reasons": null
        },
        "MethodTransactionID": null,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null
      }
    }

    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/recurrent
    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
     "Payment": {
       "PreapprovalID":4217,
       "MerchantTransactionID": "s2ptest_g108",
       "Amount": 100,
       "Currency": "BRL",
       "MethodID": 46,
       "Customer": {  
         "Email" : "test_user_4432956@testuser.com"
        },
       "BillingAddress":{
         "Country": "BR"
          }
       }
    }

    Response:

    HTTP/1.1 400 Bad Request
    Content-Type: application/json; charset=utf-8
    
    {
      "Payment": {
        "ID": 3009261,
        "SkinID": null,
        "ClientIP": null,
        "Created": "20170804065721",
        "MerchantTransactionID": "s2ptest_g108",
        "OriginatorTransactionID": null,
        "Amount": "100",
        "Currency": "BRL",
        "CapturedAmount": null,
        "ReturnURL": null,
        "Description": null,
        "MethodID": 46,
        "MethodOptionID": null,
        "IncludeMethodIDs": null,
        "ExcludeMethodIDs": null,
        "PrioritizeMethodIDs": null,
        "SiteID": 30201,
        "NotificationDateTime": null,
        "Customer": null,
        "BillingAddress": null,
        "ShippingAddress": null,
        "Articles": null,
        "Details": null,
        "ReferenceDetails": null,
        "CustomParameters": null,
        "PreapprovalID": 4217,
        "Status": {
          "ID": 4,
          "Info": "Failed",
          "Reasons": [
            {
              "Code": 114,
              "Info": "Invalid preapproval details received"
            }
          ]
        },
        "MethodTransactionID": null,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null
      }
    }
  • Checkout the below example of a recurring payment request for SEPA Direct Debit (84) that is based on the PreapprovalID (also send in the payment request the Description parameter and Country parameter – should be the same with the one sent in the Preapproval request):

    Request:

    POST https://paytest.smart2pay.com/v1/payments/recurrent
    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
     "Payment": {
       "PreapprovalID":13199,
       "MerchantTransactionID": "s2ptest_h13",
       "Amount": 100,
       "Currency": "EUR",
       "MethodID": 84,
       "Description":"SEPA DD recurrent payment",
       "BillingAddress": {
         "Country": "NL"
        }
      }
    }

    Response:

    HTTP/1.1 201 Created
    Content-Type: application/json; charset=utf-8
    
    {
        "Payment": {
            "ID": 4167022,
            "SkinID": null,
            "ClientIP": null,
            "Created": "20181101145456",
            "MerchantTransactionID": "s2ptest_h13",
            "OriginatorTransactionID": null,
            "Amount": "100",
            "Currency": "EUR",
            "CapturedAmount": null,
            "ReturnURL": null,
            "Description": "SEPA DD recurrent payment",
            "MethodID": 84,
            "MethodOptionID": null,
            "IncludeMethodIDs": null,
            "ExcludeMethodIDs": null,
            "PrioritizeMethodIDs": null,
            "SiteID": 30201,
            "NotificationDateTime": null,
            "Customer": null,
            "BillingAddress": {
                "ID": 309,
                "City": null,
                "ZipCode": null,
                "State": null,
                "Street": null,
                "StreetNumber": null,
                "HouseNumber": null,
                "HouseExtension": null,
                "Country": "NL"
            },
            "ShippingAddress": null,
            "Articles": null,
            "Details": null,
            "ReferenceDetails": null,
            "CustomParameters": null,
            "PreapprovalID": 13199,
            "Status": {
                "ID": 1,
                "Info": "Open",
                "Reasons": null
            },
            "MethodTransactionID": null,
            "TokenLifetime": null,
            "Capture": null,
            "PreapprovalDetails": null,
            "RedirectURL": null
        }
    }

    When the Direct Debit is successfully executed by the bank (1-2 banking days), you will receive a similar notification with Success Status (StatusID = 2) so you can send the product to the customer.

    You need to respond with HTTP code 204 (No Content)!

    Payment notification format:

    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
      "Payment": {
        "ID": 4167022,
        "SkinID": null,
        "ClientIP": null,
        "Created": "20181101145458",
        "MerchantTransactionID": "s2ptest_h13",
        "OriginatorTransactionID": null,
        "Amount": "100",
        "Currency": "EUR",
        "ReturnURL": "",
        "Description": null,
        "MethodID": 84,
        "MethodOptionID": null,
        "IncludeMethodIDs": null,
        "ExcludeMethodIDs": null,
        "PrioritizeMethodIDs": null,
        "SiteID": 30201,
        "NotificationDateTime": null,
        "Customer": null,
        "BillingAddress": null,
        "ShippingAddress": null,
        "Articles": null,
        "Details": null,
        "ReferenceDetails": null,
        "CustomParameters": null,
        "PreapprovalID": 13199,
        "Status": {
          "ID": 2,
          "Info": "Success",
          "Reasons": null
        },
        "MethodTransactionID": null,
        "TokenLifetime": null,
        "Capture": null,
        "PreapprovalDetails": null,
        "RedirectURL": null
      }
    }