summaryrefslogtreecommitdiff
path: root/ord.c
diff options
context:
space:
mode:
Diffstat (limited to 'ord.c')
-rw-r--r--ord.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/ord.c b/ord.c
index cf7bd12..a429879 100644
--- a/ord.c
+++ b/ord.c
@@ -3,6 +3,7 @@
#include "request.h"
#include "icclient/catalog.h"
#include "icclient/product.h"
+#include "icclient/member.h"
#include "icclient/ord.h"
typedef struct icclient_catalog icclient_catalog;
@@ -83,6 +84,82 @@ void icclient_ord_order(const char *sku, const icclient_catalog *catalog,
request(NULL, NULL, NULL, "%s%s", "order?mv_arg=", sku);
}
+void icclient_ord_checkout(struct icclient_ord_order *order,
+ struct icclient_member *member)
+{
+ struct curl_httppost *post, *last = NULL;
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "mv_todo",
+ CURLFORM_COPYCONTENTS, "submit",
+ CURLFORM_END);
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "mv_action",
+ CURLFORM_COPYCONTENTS, "refresh",
+ CURLFORM_END);
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "mv_order_profile",
+ CURLFORM_PTRCONTENTS, order->profile,
+ CURLFORM_END);
+ if (member->fname)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "fname",
+ CURLFORM_PTRCONTENTS, member->fname,
+ CURLFORM_END);
+ if (member->lname)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "lname",
+ CURLFORM_PTRCONTENTS, member->lname,
+ CURLFORM_END);
+ if (member->address1)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "address1",
+ CURLFORM_PTRCONTENTS, member->address1,
+ CURLFORM_END);
+ if (member->address2)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "address2",
+ CURLFORM_PTRCONTENTS, member->address2,
+ CURLFORM_END);
+ if (member->city)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "city",
+ CURLFORM_PTRCONTENTS, member->city,
+ CURLFORM_END);
+ if (member->state)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "state",
+ CURLFORM_PTRCONTENTS, member->state,
+ CURLFORM_END);
+ if (member->zip)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "zip",
+ CURLFORM_PTRCONTENTS, member->zip,
+ CURLFORM_END);
+ if (member->email)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "email",
+ CURLFORM_PTRCONTENTS, member->email,
+ CURLFORM_END);
+ if (member->phone_day)
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "phone_day",
+ CURLFORM_PTRCONTENTS, member->phone_day,
+ CURLFORM_END);
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "mv_same_billing",
+ CURLFORM_COPYCONTENTS,
+ member->preferences->mv_same_billing? "1" : "0",
+ CURLFORM_END);
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "email_copy",
+ CURLFORM_COPYCONTENTS, member->preferences->email_copy? "1" : "0",
+ CURLFORM_END);
+ last = NULL;
+ request(NULL, NULL, post, "%s", "ord/checkout");
+ curl_formfree(post);
+ post = NULL;
+}
+
void icclient_ord_free(struct icclient_ord_order *order)
{
for (size_t i = 0; i < order->nitems; i++)