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
Property | Type | Description | Required |
---|---|---|---|
customerId | Integer | This is the customer ID for the customer that this payment method is to be associated with | Yes |
cardNumber | String | This is the credit card number | Yes |
firstName | String | This is the first name associated with the card. Max Length: 50 characters] | Yes |
lastName | String | This is the last name associated with the card. Max Length: 50 characters] | Yes |
expirationMonth | Integer | This is the month the credit card expires. | Yes |
expirationYear | Integer | This is the year the credit card expires. format: YY | Yes |
address1 | String | standard line 1 of an address. "h-0": "Property", | Yes if Address Verification Services is in use |
address2 | String | standard line 2 of an address. "h-0": "Property", | Yes if Address Verification Services is in use |
countryId | Integer | This is the Fusebill generated country code. Call Read Country ID to find the appropriate code | Yes if Address Verification Services is in use |
stateId | Integer | This is the Fusebill generated state code. Call Read Country ID to find the appropriate code | Yes If countryId is used or Address Verification Services is in use |
city | String | This 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 |
postalZip | String | This 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 th | Optional |
makeDefault | Boolean | This value indicates if this is to be the default payment method. | Optional |
Email | String | Mandatory when using Fusebill Payments | Yes, if using Fusebill Payments |
clientIP | String | Mandatory when using Fusebill Payments | Yes, if using Fusebill Payments |
riskToken | String | Mandatory when using Fusebill Payments read more | Yes, if using Fusebill Payments |
cvv | String | The card verification value | Yes |
paymentCollectOptions | Object. Defined below | If the card is validated successfully, this object is used to collect a specified amount | Optional |
Payment Collect Options Object
Property | Type | Description |
---|---|---|
collectionAmount | Decimal | The amount to be collected |
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
}
{
"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"
}
]
}