SwagUp API: Placing the Order and Submitting Payment

Place the order

Now that we have approved your proofs, we are left to finish this journey and place an order. Once produced, these products will be held in our warehouse for you to send them on demand. We charge an amount for holding items in the warehouse, thus this charge will be included in the order invoice. We will charge a one-time warehouse fee of $4.00 per swag pack.

 

To get the final quote, make sure to make a GET a request to:

 

https://api.swagup.com/api/v1/opportunities/9901/

 

The response will include the total_plus_tax key with the updated value according to the current quantities changes.

 

Example response*:
...
"total_plus_tax": "2206.00",
...
* The response examples in this guide have been truncated to show less data.

 

❗ Note: Be aware that on top of total_plus_tax there will be a warehouse fee of $4.00 per swag pack (i.e. 200 * $4.00 = $ 800.00)


Create a Payment Profile


If you want to place an order, pay an invoice, send swag, buy credits, or do any other payment-related action, you will need first to create a payment profile. This payment profile is going to be used to charge your card. 

 

We don't keep sensitive payment profile information in our database. Instead, we use Authorize.net to provide a secure & private process. That means when you create a payment profile you need to connect to Authorize.net first to create this profile and then with the keys they return, you are able to connect them with our database, then later we can use their platform for the payment. 

 

You can create several payment profiles, but only one of them is going to be the default one. The first one created will be that default payment method, then when others are created, the default one could be switched in between all the available profiles. We always use the default payment profile to charge, so if you want to be charged with a certain payment profile, be sure first that you have set that one as default.

 

All the documentation about this can be found here: https://developer.authorize.net/api/reference/index.html

The first request to Authorize.net can be done like this:

secureData = { 
authData: {
clientKey: AUTHORIZE_API_PUBLIC_KEY,
apiLoginID: AUTHORIZE_API_LOGIN_KEY },
cardData = {
cardNumber: <value>,
fullName: <value>,
cardCode: <value>,
month: <value>,
year: <value> }
}

AUTHORIZE_API_PUBLIC_KEY and AUTHORIZE_API_LOGIN_KEY must be asked to the Authorize platform.

Then the request would be similar to:

 

const result = await new Promise(resolve => {
   const responseHandler = ({ messages, opaqueData }) =>
     resolve(messages.resultCode === 'Error' ? messages : opaqueData);
   window.Accept.dispatchData(secureData, responseHandler);
 });
  return result;

After this connection with Authorize, you are going to receive a result response object that contains 2 keys: dataValue and dataDescriptor.  Both are going to be used for creating the payment profile with our API through the next way:

You must make a POST request to:  

https://api.swagup.com/api/v1/accounts/{Account_ID}/payment-profiles/

Account_ID is the ID associated with your account when you have successfully finished the Sign-up process and you have an account with us. 

Example payload:
{
 "default": true,
 "dataValue": "<value-returned-from-authorize>",
 "dataDescriptor": "<value-returned-from-authorize>",
 "bill_to": {
   "first_name": "John",
   "last_name": "Doe",
   "email": "john@company.com",
   "company": "John Company",
   "force_address": true,
   "address1": "<address1>",
   "address2": "<address2-optional>",
   "city": "<city>",
   "state": "<state>",
   "zip_code": "<code>",
   "country": "<country>"
 },
 "payment_profile_name": "my custom Visa"
}

The response will be quite similar object to the payment profile information.

 

Example response:
{
 "default": true,
 "customer_profile_id": "1518370292",
 "customer_payment_profile_id": "504561212",
 "payment_method": "Credit Card",
 "bank_account": null,
 "credit_card": {
   "card_number": "XXXX1111",
   "expiration_date": "XXXX",
   "card_type": "Visa"
 },
 "bill_to": {
   "first_name": "John",
   "last_name": "Doe",
   "company": "John Company",
   "address1": "<address1>",
   "address2": “<address2-optional>”,
   "city": "<city>",
   "state": "<state>",
   "zip_code": "<code>",
   "country": "<country>",
   "phone_number": "<phone>"
 },
 "payment_profile_name": "my custom Visa"
}

 

 If you want to get all the payment profiles you can make a GET request to:

 

https://api.swagup.com/api/v1/accounts/{Account_ID}/payment-profiles/

 

Inside that response, you can find the field customer_payment_profile_id that can be used later for switching the default profile, in case you want to add several of them.

 

For switching profiles and setting a different default one, you must make a PATCH request to: 

 

https://api.swagup.com/api/v1/accounts/{Account_ID}/payment-profiles/{customer_payment_profile_id}/

 

With the next payload:

 

{
default: true
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Articles in this section

Ask a question
Not sure how something works or how to make changes? Don’t worry, we’ll answer all your questions.
Our help desk hours:
9:00am - 4:00pm EST Monday to Friday
Follow us on Twitter
Get the latest news and updates first