Skip to content

Commit 5988948

Browse files
authored
adds example of opaque data on CIM createCard
1 parent 55b6038 commit 5988948

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following gateways are provided by this package:
2626
* AuthorizeNet_SIM
2727
* AuthorizeNet_DPM
2828

29-
In addition, `Accept.JS` is supported by the AIM driver. More details are provided below.
29+
In addition, `Accept.JS` is supported by the AIM driver and CIM (create card). More details are provided below.
3030

3131
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
3232
repository.
@@ -45,15 +45,15 @@ The card is tokenized into two values returned in `opaqueData` object from Accep
4545

4646
These two values must be POSTed back to the merchant application, usually as a part of the payment form.
4747
Make sure the raw credit card details are NOT posted back to your site.
48-
How this is handled is beyond this short note, but examples are always welcome in the documentation.
48+
How this is handled is beyond this short note, but examples are always welcomed in the documentation.
4949

50-
On the server, the tokenized detailt are passed into the `payment` or `authorize` request object.
50+
On the server, the tokenized details are passed into the `payment` or `authorize` request object.
5151
You will still need to pass in the `CreditCard` object, as that contains details of the payee and
5252
recipient, but just leave the credit card details of that object blank. For example:
5353

5454
```php
5555
// $gateway is an instantiation of the AIM driver.
56-
// $dataDescriptor and $dataValue come from the paymentr form at the front end.
56+
// $dataDescriptor and $dataValue come from the payment form at the front end.
5757

5858
$request = $gateway->purchase(
5959
[
@@ -66,6 +66,56 @@ $request = $gateway->purchase(
6666
);
6767
```
6868

69+
CIM Create Card feature usage:
70+
Accept.js must be implemented on your frontend payment form, once Accept.js 'tokenizes' the customer's
71+
card, just send the two opaque fields and remove the Card's (Number, Expiration and CVV) from your post request.
72+
73+
Accept.js goal is to remove the need of Card information from ever going into your server so be sure to remove that data
74+
before posting to your server.
75+
76+
The create card feature on CIM will automatically create a Customer Profile and a Payment Profile with the
77+
'tokenized' card for each customer you request it for on your authorize.net account, you can use these Payment Profiles
78+
later to request payments from your customers.
79+
80+
In order to create a Customer & Payment Profile pass the opaque fields and the card array with the billing information
81+
to the createCard method on the CIM driver:
82+
83+
```php
84+
// $gateway is an instantiation of the CIM driver. //Omnipay::create( 'AuthorizeNet_CIM' )
85+
// $dataDescriptor and $dataValue come from the payment form at the front end.
86+
87+
$request = $gateway->createCard(
88+
[
89+
'opaqueDataDescriptor' => $dataDescriptor,
90+
'opaqueDataValue' => $dataValue,
91+
'name' => $name,
92+
'email' => $email, //Authorize.net will use the email to identify the CustomerProfile
93+
'customerType' => 'individual',
94+
'customerId' => $user_customer_id,//a customer ID generated by your system or send null
95+
'description' => 'MEMBER',//whichever description you wish to send
96+
'forceCardUpdate' => true
97+
'card' => [
98+
'billingFirstName' => $name,
99+
'billingLastName' => $last_name,
100+
'billingAddress1' => $address,
101+
'billingCity' => $city,
102+
'billingState' => $state,
103+
'billingPostcode' => $zipcode,
104+
'billingPhone' => '',
105+
//... may include shipping info but do not include card (number, cvv or expiration)
106+
],
107+
]
108+
);
109+
$response = $request->send();
110+
$data = $response->getData();
111+
112+
$data['paymentProfile']['customerProfileId'];
113+
$data['paymentProfile']['customerPaymentProfileId'];
114+
//Now you can use these 2 fields to reference this customer and this payment profile for later use with
115+
//the rest of the CIM driver features as usual.
116+
```
117+
118+
69119
## Support
70120

71121
If you are having general issues with Omnipay, we suggest posting on

0 commit comments

Comments
 (0)