To initiate Recurring Card Payments, you must generate first a credit card token. The credit card token can be obtained in two ways:
- by initiating a payment request with GenerateCreditCardToken parameter set to true. For more detailed information, please go to our section Recurring Card Payments;
- by using the following action for Card Authentication based on POST HTTP request:
Definition: POST /v1/card/authenticate
By using the Card Authentication request with all the necessary details for customer and for credit card, a token element will be sent in the response, containing the value of the newly created credit card token. The token received in the response can be used to initiate future Recurring Payments.
Request:
POST https://securetest.smart2pay.com/v1/card/authenticate
Authorization: Basic MTAxMDpnYWJp
{
"CardAuthentication": {
"Customer": {
"FirstName": "John",
"LastName": "Doe",
"Email": "testing2@test.com",
"SocialSecurityNumber": "00003456789"
},
"BillingAddress": {
"Country": "BR"
},
"Card": {
"HolderName": "John Doe",
"Number": "4111111111111111",
"ExpirationMonth": "02",
"ExpirationYear": "2019",
"SecurityCode": "312"
}
}
}
{"CardAuthentication":{"hint":"Card Authentication structure","regexp":"","type":"object","Customer":{"hint":"Customer details","regexp":"","type":"object","ID":{"hint":"Customer ID","regexp":"^\\d{1,12}$","type":"int"},"MerchantCustomerID":{"hint":"The ID of the customer in your system.","regexp":"^([0-9a-zA-Z_-]{1,50})?$","type":"string"},"Email":{"hint":"Customer\u2019s email","regexp":"^[a-zA-Z0-9\\._%+-]{1,100}@[a-zA-Z0-9\\.-]{1,40}\\.[a-zA-Z]{1,8}$","type":"string"},"FirstName":{"hint":"Customer\u2019s first name","regexp":"","type":"string"},"LastName":{"hint":"Customer\u2019s last name","regexp":"","type":"string"},"Gender":{"hint":"Customer\u2019s gender. It can have the following values: 1 - Male, 2 - Female.","regexp":"","type":"string"},"DateOfBirth":{"hint":"Customer date of birth","regexp":"^(((19|20)\\d\\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))$","type":"date"},"SocialSecurityNumber":{"hint":"Customer\u2018s social or fiscal identifier","regexp":"","type":"string"},"SocialSecurityNumber2":{"hint":"Customer social security number 2","regexp":"","type":"string"},"Phone":{"hint":"Customer\u2019s phone including prefix","regexp":"","type":"string"},"Company":{"hint":"Company name (for legal entities)","regexp":"","type":"string"},"InputDateTime":{"hint":"Customer creation date","regexp":"","type":"datetime"}},"BillingAddress":{"hint":"Billing Address details","regexp":"","type":"object","ID":{"hint":"Address ID, a unique number that identifies an address in the GlobalPay system.","regexp":"^\\d{1,12}$","type":"int"},"Country":{"hint":"Customer\u2018s country. Recommended to be sent in order to increase the conversion. If MethodID is missing, this field (taken from BillingAddress object) controls which payment methods are shown on the hosted payment pages. Format is according to ISO-3166-1 alpha-2, a two-letter code.","regexp":"^([A-Za-z]{2})?$","type":"string"},"City":{"hint":"City name","regexp":"^(.{1,255})?$","type":"string"},"ZipCode":{"hint":"Postal code","regexp":"^(.{1,255})?$","type":"string"},"State":{"hint":"State name","regexp":"^(.{1,255})?$","type":"string"},"Street":{"hint":"Street name","regexp":"^(.{1,255})?$","type":"string"},"StreetNumber":{"hint":"Street Number","regexp":"^(.{1,255})?$","type":"string"},"HouseNumber":{"hint":"House Number","regexp":"^(.{1,255})?$","type":"string"},"HouseExtension":{"hint":"House Extension","regexp":"^(.{1,255})?$","type":"string"}},"Card":{"hint":"Card details","regexp":"","type":"object","HolderName":{"hint":"Card holder name","regexp":"^[^\\d]*$","type":"string"},"Number":{"hint":"Card number","regexp":"^(\\d{16,19})$","type":"string"},"ExpirationMonth":{"hint":"Card expiration month","regexp":"^(0?[1-9]|1[0-2])$","type":"string"},"ExpirationYear":{"hint":"Card expiration year","regexp":"^(20|)([0-9]{2})$","type":"string"},"SecurityCode":{"hint":"Card security code (CVV2)","regexp":"^([0-9]){3,4}$","type":"string"},"Token":{"hint":"Card token","regexp":"","type":"string"},"MaskedNumber":{"hint":"Card masked number","regexp":"","type":"string"}}}}
Response:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"CardAuthentication": {
"Customer": {
"ID": 0,
"MerchantCustomerID": null,
"Email": "testing2@test.com",
"FirstName": "John",
"LastName": "Doe",
"Gender": null,
"SocialSecurityNumber": "00003456789",
"Phone": null,
"Company": null
},
"BillingAddress": {
"ID": 0,
"City": null,
"ZipCode": null,
"State": null,
"Street": null,
"StreetNumber": null,
"HouseNumber": null,
"HouseExtension": null,
"Country": "BR"
},
"Card": {
"HolderName": "John Doe",
"Number": "VISA-1111",
"ExpirationMonth": "02",
"ExpirationYear": "2019"
},
"CreditCardToken": {
"Value": "B531AFAC800FD51A9CCF67D0CC7B24A4",
"Active": "true"
},
"Status": {
"ID": 2,
"Info": "Success",
"Reasons": []
}
}
}
{"CardAuthentication":{"hint":"Card Authentication structure","regexp":"","type":"object","Customer":{"hint":"Customer details","regexp":"","type":"object","ID":{"hint":"Customer ID","regexp":"^\\d{1,12}$","type":"int"},"MerchantCustomerID":{"hint":"The ID of the customer in your system.","regexp":"^([0-9a-zA-Z_-]{1,50})?$","type":"string"},"Email":{"hint":"Customer\u2019s email","regexp":"^[a-zA-Z0-9\\._%+-]{1,100}@[a-zA-Z0-9\\.-]{1,40}\\.[a-zA-Z]{1,8}$","type":"string"},"FirstName":{"hint":"Customer\u2019s first name","regexp":"","type":"string"},"LastName":{"hint":"Customer\u2019s last name","regexp":"","type":"string"},"Gender":{"hint":"Customer\u2019s gender. It can have the following values: 1 - Male, 2 - Female.","regexp":"","type":"string"},"DateOfBirth":{"hint":"Customer date of birth","regexp":"^(((19|20)\\d\\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))$","type":"date"},"SocialSecurityNumber":{"hint":"Customer\u2018s social or fiscal identifier","regexp":"","type":"string"},"SocialSecurityNumber2":{"hint":"Customer social security number 2","regexp":"","type":"string"},"Phone":{"hint":"Customer\u2019s phone including prefix","regexp":"","type":"string"},"Company":{"hint":"Company name (for legal entities)","regexp":"","type":"string"},"InputDateTime":{"hint":"Customer creation date","regexp":"","type":"datetime"}},"BillingAddress":{"hint":"Billing Address details","regexp":"","type":"object","ID":{"hint":"Address ID, a unique number that identifies an address in the GlobalPay system.","regexp":"^\\d{1,12}$","type":"int"},"Country":{"hint":"Customer\u2018s country. Recommended to be sent in order to increase the conversion. If MethodID is missing, this field (taken from BillingAddress object) controls which payment methods are shown on the hosted payment pages. Format is according to ISO-3166-1 alpha-2, a two-letter code.","regexp":"^([A-Za-z]{2})?$","type":"string"},"City":{"hint":"City name","regexp":"^(.{1,255})?$","type":"string"},"ZipCode":{"hint":"Postal code","regexp":"^(.{1,255})?$","type":"string"},"State":{"hint":"State name","regexp":"^(.{1,255})?$","type":"string"},"Street":{"hint":"Street name","regexp":"^(.{1,255})?$","type":"string"},"StreetNumber":{"hint":"Street Number","regexp":"^(.{1,255})?$","type":"string"},"HouseNumber":{"hint":"House Number","regexp":"^(.{1,255})?$","type":"string"},"HouseExtension":{"hint":"House Extension","regexp":"^(.{1,255})?$","type":"string"}},"Card":{"hint":"Card details","regexp":"","type":"object","HolderName":{"hint":"Card holder name","regexp":"^[^\\d]*$","type":"string"},"Number":{"hint":"Card number","regexp":"^(\\d{16,19})$","type":"string"},"ExpirationMonth":{"hint":"Card expiration month","regexp":"^(0?[1-9]|1[0-2])$","type":"string"},"ExpirationYear":{"hint":"Card expiration year","regexp":"^(20|)([0-9]{2})$","type":"string"},"SecurityCode":{"hint":"Card security code (CVV2)","regexp":"^([0-9]){3,4}$","type":"string"},"Token":{"hint":"Card token","regexp":"","type":"string"},"MaskedNumber":{"hint":"Card masked number","regexp":"","type":"string"}},"CreditCardToken":{"hint":"Credit card token structure","regexp":"","type":"object","Value":{"hint":"Token value","regexp":"","type":"string"},"RequireSecurityCode":{"hint":"If set to false when the security code parameter is not used, it will not redirect to the form page to fill in the security code, but the payment will be directly sent to the payment provider.","regexp":"","type":"bool"},"SecurityCode":{"hint":"Token security code","regexp":"","type":"string"}},"Status":{"hint":"","regexp":"","type":"object","ID":{"hint":"Status ID","regexp":"","type":"int"},"Info":{"hint":"The description of the status","regexp":"","type":"string"},"Reasons":{"hint":"The reasons why the payment got to this status.","regexp":"","type":"array of objects","Code":{"hint":"The id of the message type transmitted in the response. See our section GlobalPay Return Codes for a complete description.","regexp":"","type":"int"},"Info":{"hint":"The message body","regexp":"","type":"string"}}}}}