Create a Preapproval

Definition: POST /v1/preapprovals

To initiate a preapproval, you must create a preapproval object. The parameters of the preapproval are sent in the message body as a JSON object. Below you can see 2 examples of a preapproval request: one for MercadoPago (46) and one for SEPA Direct Debit (84).

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

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

    Request:

    POST https://paytest.smart2pay.com/v1/preapprovals
    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
     "Preapproval": {
       "MerchantPreapprovalID": "s2ptest_g107",
       "Description": "1 year subscription",
       "ReturnURL": "http://demo.smart2pay.com/redirect.php",
       "MethodID": 46, 
       "Customer": {
          "FirstName": "John",
          "LastName": "Doe",
          "Email": "test_user_83022133@testuser.com",
          "Phone": "0765260000"
         },
       "BillingAddress": {
          "Street": "Tonelero",
          "StreetNumber": "1",
          "ZipCode": "23900-000",
          "City": "Rio de Janeiro",
          "Country": "BR"
          }
       }
    }

    Response:

    HTTP/1.1 201 Created
    Content-Type: application/json; charset=utf-8
    
    {
      "Preapproval": {
        "ID": 4217,
        "Created": "20170804065155",
        "MethodID": 46,
        "SiteID": 30201,
        "MerchantPreapprovalID": "s2ptest_g107",
        "RecurringPeriod": 0,
        "PreapprovedMaximumAmount": null,
        "Currency": null,
        "ReturnURL": "http://demo.smart2pay.com/redirect.php",
        "Description": "1 year subscription",
        "Customer": {
          "ID": 3627,
          "MerchantCustomerID": null,
          "Email": "test_user_83022133@testuser.com",
          "FirstName": "John",
          "LastName": "Doe",
          "Gender": null,
          "SocialSecurityNumber": null,
          "Phone": "0765260000",
          "Company": null,
          "DateOfBirth": null
        },
        "BillingAddress": {
          "ID": 1257,
          "City": "Rio de Janeiro",
          "ZipCode": "23900-000",
          "State": null,
          "Street": "Tonelero",
          "StreetNumber": "1",
          "HouseNumber": null,
          "HouseExtension": null,
          "Country": "BR"
        },
        "Status": {
          "ID": 1,
          "Info": "Pending",
          "Reasons": null
        },
        "RedirectURL": "https://europaytest.smart2pay.com/MercadoPago2/Landing/PreapprovalLanding.aspx?ID=628&Hash=47CEEF7559CDD192E188D91F0C7B7978",
        "MethodOptionID": 0,
        "PreapprovedFrequency": null,
        "MandateReference": null
      }
    }

    Redirect the customer to the RedirectURL where he will approve the automatic debit.

  • Checkout the below example of a preapproval request for SEPA Direct Debit (84):

    For SEPA Direct Debit preapproval requests MethodOptionID parameter is mandatory to be sent in the initial payment request.

    Please note that if you have a Company, you also need to send the Company parameter in the request.

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

    Request: 

    POST https://paytest.smart2pay.com/v1/preapprovals
    Authorization: Basic MzAyMDE6aEo1Um9iWXg5cjdGZk53Q3ZIWTlMWEhxcXIrRkV6cmM3YUp2UVFrNEdhejFtZzdSeXk=
    
    {
      "Preapproval": {
        "MerchantPreapprovalID": "s2ptest_h11",
        "Description": "SEPA DD preapproval request",
        "ReturnURL": "http://demo.smart2pay.com/redirect.php",
        "MethodID": 84,
        "Customer": {
          "FirstName": "John",
          "LastName": "Doe",
          "Email": "youremail@gmail.com",
          "Phone": "+31651111111"
        },
        "BillingAddress": {
          "Street": "Brink",
          "StreetNumber": "27c",
          "ZipCode": "1251",
          "City": "Laren",
          "Country": "NL"
        },
        "MethodOptionID": 1
      }
    }

    Response:

    HTTP/1.1 201 Created
    Content-Type: application/json; charset=utf-8
    
    {
        "Preapproval": {
            "ID": 13199,
            "Created": "20181101142508",
            "MethodID": 84,
            "SiteID": 30201,
            "MerchantPreapprovalID": "s2ptest_h11",
            "RecurringPeriod": 0,
            "PreapprovedMaximumAmount": null,
            "Currency": null,
            "ReturnURL": "http://demo.smart2pay.com/redirect.php",
            "Description": "SEPA DD preapproval request",
            "Customer": {
                "ID": 135127,
                "MerchantCustomerID": null,
                "Email": "youremail@gmail.com",
                "FirstName": "John",
                "LastName": "Doe",
                "Gender": null,
                "SocialSecurityNumber": null,
                "SocialSecurityNumber2": null,
                "Phone": "+31651111111",
                "Company": null,
                "DateOfBirth": null
            },
            "BillingAddress": {
                "ID": 5103,
                "City": "Laren",
                "ZipCode": "1251",
                "State": null,
                "Street": "Brink",
                "StreetNumber": "27c",
                "HouseNumber": null,
                "HouseExtension": null,
                "Country": "NL"
            },
            "Status": {
                "ID": 1,
                "Info": "Pending",
                "Reasons": null
            },
            "RedirectURL": "https://europaytest.smart2pay.com/SlimPay/Landing/PreapprovalLanding.aspx?ID=10084&Hash=CD71CA781BD1F59F52F8F0B2D20A807E",
            "MethodOptionID": 1,
            "PreapprovedFrequency": null,
            "MandateReference": null
        }
    }

    Redirect the customer to the RedirectURL where he will approve the automatic debit. Once the Customer approves the debit, he will receives via email the digital signed mandate.