Create Credit Card Payment Method

The CreditCard Payment Methods resource represents the details of a credit card configured on a customer. The actions available for CreditCard Payment Methods allow you to develop a customer self service feature where the customer can update the method they use to pay for their services.

🚧

PCI Compliance

We strongly recommended that you use the Transparent Redirect or the AJAX Redirect in order to comply with PCI compliance requirements when submitting payment method information to Fusebill.

Directly submitting payment method information through the API exposes your company to PCI compliance requirements. If your company is already PCI compliant, this could potentially allow for more advanced payment method entry scenarios.

Do not use this endpoint if your company is not PCI compliant and does not intend to adhere to these requirements.

Request Parameters

PropertyTypeDescriptionRequired
customerIdIntegerThis is the customer ID for the customer that this payment method is to be associated withYes
cardNumberStringThis is the credit card numberYes
firstNameStringThis is the first name associated with the card. Max Length: 50 characters]Yes
lastNameStringThis is the last name associated with the card.
Max Length: 50 characters]
Yes
expirationMonthIntegerThis is the month the credit card expires.Yes
expirationYearIntegerThis is the year the credit card expires. format: YYYes
address1Stringstandard line 1 of an address. "h-0": "Property",
Yes if Address Verification Services is in use
address2Stringstandard line 2 of an address. "h-0": "Property",
Yes if Address Verification Services is in use
countryIdIntegerThis is the Fusebill generated country code. Call Read Country ID to find the appropriate codeYes if Address Verification Services is in use
stateIdIntegerThis is the Fusebill generated state code. Call Read Country ID to find the appropriate codeYes If countryId is used or Address Verification Services is in use
cityStringThis is the city associated with the address associated with the card. This is required if Address Verification Services is in use. -1": "Integer",
"0-2":
Optional
postalZipStringThis is the regional location code (eg. ZIP code in the USA) associated with the address associated with the card. This is required if Address Verification Services is in use. omer ID for the customer thOptional
makeDefaultBooleanThis value indicates if this is to be the default payment method.Optional
EmailStringMandatory when using Fusebill PaymentsYes, if using Fusebill Payments
clientIPStringMandatory when using Fusebill PaymentsYes, if using Fusebill Payments
riskTokenStringMandatory when using Fusebill Payments read moreYes, if using Fusebill Payments
cvvStringThe card verification valueYes
paymentCollectOptionsObject. Defined belowIf the card is validated successfully, this object is used to collect a specified amountOptional

Payment Collect Options Object

PropertyTypeDescription
collectionAmountDecimalThe amount to be collected
Examples
curl -X POST "https://secure.fusebill.com/v1/paymentMethods/creditCard" \
	-H "Content-Type: application/json" \
	-H "Authorization: Basic {APIKey}" \
	-d "{customerId:{customerId},cardNumber:'4111111111111111',firstName:'John',lastName:'Doe',expirationMonth:1,expirationYear:20,cvv:'123',address1:'232 Herzberg Road',address2:'Suite 203',countryId:124,stateId:9,city:'Kanata',postalZip:'K2K 2A1',isDefault:true}"
//Json Payload
string jsonData ="{customerId:{customerId},cardNumber:'4111111111111111',firstName:'John',lastName:'Doe',expirationMonth:1,expirationYear:20,cvv:'123',address1:'232 Herzberg Road',address2:'Suite 203',countryId:124,stateId:9,city:'Kanata',postalZip:'K2K 2A1',isDefault:true}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/paymentMethods/creditCard");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "POST";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
  streamWriter.Write(jsonData);
  streamWriter.Flush();
  streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
  result = streamReader.ReadToEnd();
}
#Import library JSON
import json
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in a dictionary to the Payload parameter
payload = {"customerId":{id},"cardNumber":{cardNumber},"firstName":'John',"lastName":'Doe',"expirationMonth":10,"expirationYear":20,"cvv":123,"address1":'232 Herzberg Road',"address2":'Suite 203',"countryId":124,"stateId":9,"city":'Kanata',"postalZip":'K2K 2A1',"isDefault":"true"}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/paymentMethods/creditCard', data=json.dumps(payload), headers=headers)
print(r.content)
{
  "cardNumber": "4242424242424242",
  "expirationMonth": 2,
  "expirationYear": 23,
  "cvv": "123",
  "firstName": "Karen",
  "lastName": "Wood",
  "address1": "10 Dodge St",
  "address2": "",
  "city": "Columbia",
  "stateId": 1,
  "countryId": 124,
  "source":"Manual",
  "postalZip": "V9V 9V9",
  "makeDefault": true,
  "customerId": 12345678
}
Response
{ 
   "maskedCardNumber":"************1111",
   "cardType":"Visa",
   "expirationMonth":1,
   "expirationYear":20,
   "customerId":172677,
   "firstName":"John",
   "lastName":"Doe",
   "address1":"232 Herzberg Road",
   "address2":"Suite 203",
   "countryId":124,
   "country":"CAN",
   "stateId":9,
   "state":"Ontario",
   "city":"Kanata",
   "postalZip":"K2K 2A1",
   "isDefault":false,
   "externalCustomerId":null,
   "externalCardId":null,
   "storedInFusebillVault":true,
   "isUsedForBillingPeriodOverride": false,
   "id":82620,
   "uri":null
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "Api Error",
            "Value": "There was an error validating the payment method"
        }
    ]
}
Language
Authorization