Additional payment instrument creation examples
Creating a payment instrument with all attributes
Below is an example of creating a payment instrument passing all supported attributes.
Request
- JSON
{
"id": "ecec3635-7989-4c6f-91a6-a940e9093b78",
"paymentMethod": "CREDIT_CARD",
"billingAddress": {
"firstName": "Dev,
"lastName": "User",
"street1": "123 Fake St.",
"street2": "floor 2",
"city": "Somerville",
"country": "US",
"state": "MA",
"zip": "02114",
"phone": "(508)-213-1534",
"phoneExtension": "x787",
"fax": "(508)-253-1334",
"faxExtension": "x727"
},
"accountDisplay": "1111",
"creditCard": {
"name": "Bob Jones",
"number": "4111111111111111",
"expirationMonth": "12",
"expirationYear": "2020",
"securityCode": "111"
},
"isDefault": "true",
"parameters":{
"issuer":"Citibank",
"maskedPan":"*************111"
}
}
- XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<paymentInstrument>
<id>ecec3635-7989-4c6f-91a6-a940e9093b78</id>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<firstName>Dev</firstName>
<lastName>User</lastName>
<street1>123 Fake St.</street1>
<street2>floor 2</street2>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<zip>02114</zip>
<phone>(508)-213-1534</phone>
<phoneExtension>x787</phoneExtension>
<fax>(508)-253-1334</fax>
<faxExtension>x727</faxExtension>
</billingAddress>
<accountDisplay>1111</accountDisplay>
<creditCard>
<name>Bob Jones</name>
<number>4111111111111111</number>
<expirationMonth>12</expirationMonth>
<expirationYear>2020</expirationYear>
<securityCode>111</securityCode>
</creditCard>
<isDefault>true</isDefault>
<parameters>
<issuer>Citibank</issuer>
<maskedPan>*************111</maskedPan>
</parameters>
</paymentInstrument>
Response
- JSON
Status Code: 201 Created
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 568
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 16:25:17 GMT
Expires: 0
Location: http://www.appdirect.com/api/billing/v1/paymentInstruments/0c3a9e49-cdb9-46ac-b42b-142b09111932
Pragma: no-cache
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
{
"id": "0c3a9e49-cdb9-46ac-b42b-142b09111932",
"company": {
"-id": "2e983f07-99d1-46cd-920a-dd0c8de5bc48",
"-href": "http://www.appdirect.com/api/account/v1//companies/2e983f07-99d1-46cd-920a-dd0c8de5bc48"
},
"user": {
"-id": "5019a0a6-a1e3-4d6a-85d3-6b6993afe96d",
"-href": "http://www.appdirect.com/api/account/v1//users/5019a0a6-a1e3-4d6a-85d3-6b6993afe96d"
},
"accountDisplay": "1111",
"paymentMethod": "CREDIT_CARD",
"billingAddress": {
"city": "Somerville",
"country": "US",
"state": "MA",
"street1": "123 Fake St.",
"street2": "floor 2",
"zip": "02114",
"firstName": "Dev",
"lastName": "User",
"phone": "(508)-213-1534",
"phoneExtension": "x787",
"fax": "(508)-253-1334",
"faxExtension": "x727"
},
"creditCard": {
"expirationMonth": "12",
"expirationYear": "2020",
"type": "VISA"
},
"createdOn": "2015-08-11T10:25:17.474-06:00",
"isDefault": "true",
"parameters":{
"issuer":"Citibank",
"maskedPan":"*************111"
}
}
- XML
Status Code: 201 Created
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 568
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 16:25:17 GMT
Expires: 0
Location: http://www.appdirect.com/api/billing/v1/paymentInstruments/0c3a9e49-cdb9-46ac-b42b-142b09111932
Pragma: no-cache
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
<?xml version="1.0" encoding="UTF-8" standalone="yes"?--><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<paymentInstrument>
<id>0c3a9e49-cdb9-46ac-b42b-142b09111932</id>
<company id="2e983f07-99d1-46cd-920a-dd0c8de5bc48" href="http://www.appdirect.com/api/account/v1//companies/2e983f07-99d1-46cd-920a-dd0c8de5bc48"/>
<user id="5019a0a6-a1e3-4d6a-85d3-6b6993afe96d" href="http://www.appdirect.com/api/account/v1//users/5019a0a6-a1e3-4d6a-85d3-6b6993afe96d"/>
<accountDisplay>1111</accountDisplay>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<street1>123 Fake St.</street1>
<street2>floor 2</street2>
<zip>02114</zip>
<firstName>Dev</firstName>
<lastName>User</lastName>
<phone>(508)-213-1534</phone>
<phoneExtension>x787</phoneExtension>
<fax>(508)-253-1334</fax>
<faxExtension>x727</faxExtension>
</billingAddress>
<creditCard>
<expirationMonth>12</expirationMonth>
<expirationYear>2020</expirationYear>
<type>VISA</type>
</creditCard>
<createdOn>2015-08-11T10:25:17.474-06:00</createdOn>
<isDefault>true</isDefault>
<parameters/>
</paymentInstrument>
Creating a payment instrument with several attributes
Below is an example of creating a payment instrument passing several commonly used attributes.
Request
- JSON
{
"paymentMethod": "CREDIT_CARD",
"billingAddress": {
"firstName": "Dev",
"lastName": "User,
"street1": "123 Fake St.",
"street2": "floor 2",
"city": "Somerville",
"country": "US",
"state": "MA",
"zip": "02114",
"phone": "(508)-213-1534",
"phoneExtension": "x787"
},
"accountDisplay": "1111",
"creditCard": {
"name": "Bob Jones",
"number": "4111111111111111",
"expirationMonth": "12",
"expirationYear": "2020",
"securityCode": "111"
},
"isDefault": "true"
}
- XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<paymentInstrument>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<firstName>Dev</firstName>
<lastName>User</lastName>
<street1>123 Fake St.</street1>
<street2>floor 2</street2>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<zip>02114</zip>
<phone>(508)-213-1534</phone>
<phoneExtension>x787</phoneExtension>
</billingAddress>
<accountDisplay>1111</accountDisplay>
<creditCard>
<name>Bob Jones</name>
<number>4111111111111111</number>
<expirationMonth>12</expirationMonth>
<expirationYear>2020</expirationYear>
<securityCode>111</securityCode>
</creditCard>
<isDefault>true</isDefault>
</paymentInstrument>
Response
- JSON
Status Code: 201 Created
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 568
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 16:25:17 GMT
Expires: 0
Location: http://www.appdirect.com/api/billing/v1/paymentInstruments/0c3a9e49-cdb9-46ac-b42b-142b09111932
Pragma: no-cache
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
{
"id": "0c3a9e49-cdb9-46ac-b42b-142b09111932",
"company": {
"-id": "2e983f07-99d1-46cd-920a-dd0c8de5bc48",
"-href": "http://www.appdirect.com/api/account/v1//companies/2e983f07-99d1-46cd-920a-dd0c8de5bc48"
},
"user": {
"-id": "5019a0a6-a1e3-4d6a-85d3-6b6993afe96d",
"-href": "http://www.appdirect.com/api/account/v1//users/5019a0a6-a1e3-4d6a-85d3-6b6993afe96d"
},
"accountDisplay": "1111",
"paymentMethod": "CREDIT_CARD",
"billingAddress": {
"city": "Somerville",
"country": "US",
"state": "MA",
"street1": "123 Fake St.",
"street2": "floor 2",
"zip": "02114",
"firstName": "Dev",
"lastName": "User",
"phone": "(508)-213-1534",
"phoneExtension": "x787"
},
"creditCard": {
"expirationMonth": "12",
"expirationYear": "2020",
"type": "VISA"
},
"createdOn": "2015-08-11T10:25:17.474-06:00",
"isDefault": "true"
}
- XML
Status Code: 201 Created
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 568
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 16:25:17 GMT
Expires: 0
Location: http://www.appdirect.com/api/billing/v1/paymentInstruments/0c3a9e49-cdb9-46ac-b42b-142b09111932
Pragma: no-cache
Server: Apache-Coyote/1.1
Vary: Accept-Encoding
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
<?xml version="1.0" encoding="UTF-8" standalone="yes"?--><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<paymentInstrument>
<id>0c3a9e49-cdb9-46ac-b42b-142b09111932</id>
<company id="2e983f07-99d1-46cd-920a-dd0c8de5bc48" href="http://www.appdirect.com/api/account/v1//companies/2e983f07-99d1-46cd-920a-dd0c8de5bc48"/>
<user id="5019a0a6-a1e3-4d6a-85d3-6b6993afe96d" href="http://www.appdirect.com/api/account/v1//users/5019a0a6-a1e3-4d6a-85d3-6b6993afe96d"/>
<accountDisplay>1111</accountDisplay>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<street1>123 Fake St.</street1>
<street2>floor 2</street2>
<zip>02114</zip>
<firstName>Dev</firstName>
<lastName>User</lastName>
<phone>(508)-213-1534</phone>
<phoneExtension>x787</phoneExtension>
</billingAddress>
<creditCard>
<expirationMonth>12</expirationMonth>
<expirationYear>2020</expirationYear>
<type>VISA</type>
</creditCard>
<createdOn>2015-08-11T10:25:17.474-06:00</createdOn>
<isDefault>true</isDefault>
<parameters/>
</paymentInstrument>
Creating a payment instrument missing required data
Below is an example of creating a payment instrument with a bad request caused by missing required data, specifically the credit card field.
Request
- JSON
{
"paymentMethod":"CREDIT_CARD",
"billingAddress":{
"firstName":"Demo",
"lastName":"User",
"street1":"50 Grove St",
"city":"Somerville",
"country":"US",
"state":"MA",
"zip":"02114",
"phone":"4159991100"
}
}
- XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<paymentInstrument>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<firstName>Demo</firstName>
<lastName>User</lastName>
<street1>50 Grove St</street1>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<zip>02114</zip>
<phone>4159991100</phone>
</billingAddress>
</paymentInstrument>
Response
- JSON
Status Code: 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Content-Length: 144
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 04:31:28 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=BA90F20336DFCBAB0F115B26AF3457B7; Path=/; HttpOnly
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
{
"code": "CREDIT_CARD_MISSING",
"message": "Credit Card is missing."
}
- XML
Status Code: 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Content-Length: 144
Content-Type: application/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 04:31:28 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=BA90F20336DFCBAB0F115B26AF3457B7; Path=/; HttpOnly
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<errors>
<error>
<code>CREDIT_CARD_MISSING</code>
<message>Credit Card is missing.</message>
</error>
</errors>
Creating a payment instrument with a bad request
Below is an example of creating a payment instrument with a bad request. In this case, the JSON object is missing a comma, while the XML is missing a closing tag.
Request
- JSON
{
"paymentMethod":"CREDIT_CARD"
"billingAddress":{
"firstName":"Demo",
"lastName":"User",
"street1":"50 Grove St",
"city":"Somerville",
"country":"US",
"state":"MA",
"zip":"02114",
"phone":"4159991100"
},
"creditCard":{
"name":"Demo User",
"number":"4111111111111111",
"expirationMonth":"5",
"expirationYear":"2017",
"securityCode":111,
"type":"VISA"
}
}
- XML
<xml version="1.0" encoding="UTF-8" standalone="yes">
lt;paymentInstrument>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<firstName>Demo</firstName>
<lastName>User</lastName>
<street1>50 Grove St</street1>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<zip>02114</zip>
<phone>4159991100</phone>
</billingAddress>
<creditCard>
<name>Demo User</name>
<number>4111111111111111</number>
<expirationMonth>5</expirationMonth>
<expirationYear>2017</expirationYear>
<securityCode>111</securityCode>
<type>VISA</type>
</creditCard>
Response
- JSON
Status Code: 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Content-Length: 120
Content-Type: application/json;charset=UTF-8
Date: Tue, 11 Aug 2015 12:34:55 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=F7C61C4351EE8174CB05E22F15FF1B99; Path=/; HttpOnly
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
{
"code": "Bad Request",
"message": "Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries"
}
- XML
Status Code: 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Connection: close
Content-Length: 133
Content-Type: text/xml;charset=UTF-8
Date: Tue, 11 Aug 2015 12:38:55 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<errors>
<error>
<code>Bad Request</code>
<message>HTTP 400 Bad Request</message>
</error>
</errors>
Creating a payment instrument that already exists
Below is an example of creating a payment instrument for a user that already has an existing default payment instrument.
Request
- JSON
{
"paymentMethod":"CREDIT_CARD",
"billingAddress":{
"firstName":"Demo",
"lastName":"User",
"street1":"50 Grove St",
"city":"Somerville",
"country":"US",
"state":"MA",
"zip":"02114",
"phone":"4159991100"
},
"creditCard":{
"name":"Demo User",
"number":"4111111111111111",
"expirationMonth":"5",
"expirationYear":"2017",
"securityCode":111,
"type":"VISA"
}
}
- XML
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<paymentInstrument>
<paymentMethod>CREDIT_CARD</paymentMethod>
<billingAddress>
<firstName>Demo</firstName>
<lastName>User</lastName>
<street1>50 Grove St</street1>
<city>Somerville</city>
<country>US</country>
<state>MA</state>
<zip>02114</zip>
<phone>4159991100</phone>
</billingAddress>
<creditCard>
<name>Demo User</name>
<number>4111111111111111</number>
<expirationMonth>5</expirationMonth>
<expirationYear>2017</expirationYear>
<securityCode>111</securityCode>
<type>VISA</type>
</creditCard>
</paymentInstrument>
Response
- JSON
Status Code: 409 Conflict
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 175
Content-Type: application/xml;charset=UTF-8
Date: Mon, 10 Aug 2015 16:09:40 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=EF55CB7ED3B901B9617F04C5D621ADB4; Path=/; HttpOnly
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
{
"code": "PAYMENT_INSTRUMENT_ALREADY_EXIST",
"message": "Default paymentInstrument already exists."
}
- XML
Status Code: 409 Conflict
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 175
Content-Type: application/xml;charset=UTF-8
Date: Mon, 10 Aug 2015 16:09:40 GMT
Expires: 0
Pragma: no-cache
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=EF55CB7ED3B901B9617F04C5D621ADB4; Path=/; HttpOnly
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
x-content-type-options: nosniff
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<code>PAYMENT_INSTRUMENT_ALREADY_EXIST</code>
<message>Default paymentInstrument already exists.</message>
</error>
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!