Skip to content

Commit f84375f

Browse files
author
Lydia Koller
committed
Create customer profile from transaction
1 parent a0da7d7 commit f84375f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/elixir_authorizenet/customer.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ defmodule AuthorizeNet.Customer do
140140
%AuthorizeNet.Customer{profile | profile_id: profile_id}
141141
end
142142

143+
@spec create_from_transaction(
144+
String.t, String.t, String.t, String.t
145+
) :: AuthorizeNet.Customer.t | no_return
146+
def create_from_transaction(id, transaction_id, description, email) do
147+
profile = new id, nil, description, email
148+
profile_xml = to_xml profile
149+
doc = Main.req :createCustomerProfileFromTransactionRequest, [
150+
customer: profile_xml,
151+
transId: transaction_id,
152+
]
153+
profile_id = xml_one_value_int doc, "//customerProfileId"
154+
%AuthorizeNet.Customer{profile | profile_id: profile_id}
155+
end
156+
143157
@doc """
144158
Deletes a customer profile by customer profile ID. See:
145159
http://developer.authorize.net/api/reference/index.html#manage-customer-profiles-delete-customer-profile

test/resources/AnetApiSchema.xsd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,10 @@
24112411

24122412
<!--
24132413
===================================================================
2414-
bla bla
2414+
createCustomerProfileFromTransactionRequest
2415+
This method is used to create a new customer profile along with any
2416+
customer payment profiles and customer shipping addresses for the customer profile.
2417+
The merchant must be signed up for the CIM service to use it.
24152418
===================================================================
24162419
-->
24172420
<xs:element name="createCustomerProfileFromTransactionRequest">
@@ -2420,6 +2423,7 @@
24202423
<xs:extension base="anet:ANetApiRequest">
24212424
<xs:sequence>
24222425
<xs:element name="transId" type="anet:numericString" minOccurs="1" maxOccurs="1" />
2426+
<xs:element name="customer" type="anet:customerProfileType" />
24232427
</xs:sequence>
24242428
</xs:extension>
24252429
</xs:complexContent>

0 commit comments

Comments
 (0)