This function allows you to update a credit card payment method on a customer. It returns the updated Payment Method on success, which will have a new Fusebill generated ID. Using this method of editing a Payment Method exposes you to PCI Compliance requirements. If you wish to minimize your PCI Compliance risk please use the Transparent Redirect method instead.
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.
GET/PUT pattern
Since the DTO returned by the GET methods contain masked card numbers (e.g. '***1234'), the usual GET/PUT pattern does not work for updating credit cards. To update a credit card, read the DTO from a GET, then add in the unmasked
cardNumber
andcvv
. Use that JSON as the payload for this PUT request
Request Parameters
Property | Type | Description |
---|---|---|
customerId | Integer | This is the customer Id for the customer that this payment method is attached to. |
cardNumber | String | This is the credit card number |
firstName | String | This is the first name associated with the card. Max Length: 50 characters] |
lastName | String | This is the last name associated with the card. Max Length: 50 characters] |
expirationMonth | Integer | This is the month the credit card expires. |
expirationYear | Integer | This is the year the credit card expires. format: YY |
cvv | String | This is the credit card cvv value. |
address1 | String | standard line 1 of an address. [Max Length: 50 characters] |
address2 | String | standard line 2 of an address. [Max Length: 50 characters] |
countryId | Integer | This is the Fusebill generated country code. Call Read Country ID to find the appropriate code |
stateId | Integer | This is the Fusebill generated state code. Call Read Country ID to find the appropriate code |
city | String | This is the city associated with the address associated with the card. This is required if Address Verification Services is in use. [Max Length: 50 characters] |
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. [Max Length: 10 characters] |
id | Integer | This is the unique ID of the Payment Method to update. |
paymentCollectOptions | Object. Defined below. | If the card is validated successfully, this object is used to collect a specified amount |
Payment Collect Options Object
Property | Type | Description |
---|---|---|
collectionAmount | Decimal | The amount to be collected |
curl -X PUT "https://secure.fusebill.com/v1/paymentMethods/creditCard" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{id:{paymentMethodId},customerId:{customerId},cardNumber:'4111111111111111',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}"
//Json Payload
string jsonData =
"{id:{paymentMethodId},customerId:{cutomerId},cardNumber:'4111111111111111',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}";
//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 = "PUT";
//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 = {"cardNumber":"4242424242424242","cardType":"Visa","expirationMonth":11,"expirationYear":17,"cvv":"123","customerId":186838,"firstName":"matt","lastName":"larr","address1":None,"address2":None,"countryId":None,"country":"","stateId":None,"state":"","city":None,"postalZip":None,"isDefault":"false","externalCustomerId":None,"externalCardId":None,"storedInFusebillVault":"true","id":{id},"uri":None}
#Pass in your URI, Payload and Headers
r = requests.put('https://secure.fusebill.com/v1/paymentMethods/creditCard', data=json.dumps(payload), headers=headers)
print(r.content)
{
"cardNumber": "4242424242424242",
"cvv":"123",
"cardType": "Visa",
"expirationMonth": 2,
"expirationYear": 23,
"customerId": 611718,
"firstName": "Veronica",
"lastName": "Betties",
"address1": "10 Dodge St",
"address2": "",
"countryId": 124,
"country": "CAN",
"stateId": 1,
"state": "Alberta",
"city": "Columbia",
"postalZip": "V9V 9V9",
"isDefault": false,
"externalCustomerId": null,
"externalCardId": null,
"storedInFusebillVault": true,
"email": null,
"modifiedDate": "2019-11-28T21:07:22.9648586Z",
"originalPaymentMethodId": null,
"isUsedForBillingPeriodOverride": false,
"id": 214608,
"uri": null
}
{
"maskedCardNumber":"************4242",
"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": "Cannot edit payment method 214608 because it has been deleted."
}
]
}