-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Holder-Chow Lin On
committed
May 30, 2014
0 parents
commit de84f85
Showing
24 changed files
with
1,088 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# override like so: make dependencies COMPOSER=$(which composer.phar) | ||
COMPOSER = ./build/composer.phar | ||
|
||
.PHONY : test | ||
test: | ||
php ./test/Affirm.php | ||
|
||
.PHONY : dependencies | ||
dependencies: | ||
$(COMPOSER) update --dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[](https://affirm.com) | ||
|
||
**Compatible with** | ||
|
||
Magento CE 1.4.0.1+ | ||
|
||
Install | ||
------- | ||
|
||
**To install using [modgit](https://github.com/jreinke/modgit):** | ||
|
||
``` | ||
cd MAGENTO_ROOT | ||
modgit -i extension/:. add Magento_Affirm [email protected]:Affirm/Magento_Affirm.git | ||
``` | ||
to update: | ||
``` | ||
modgit update Magento_Affirm | ||
``` | ||
|
||
**To install using [modman](https://github.com/colinmollenhour/modman):** | ||
|
||
``` | ||
cd MAGENTO_ROOT | ||
modman clone [email protected]:Affirm/Magento_Affirm.git | ||
``` | ||
to update: | ||
``` | ||
modman update Magento_Affirm | ||
``` | ||
|
||
**To install using Affirm's deploy script:** | ||
|
||
1. Download the [Makefile](https://gist.githubusercontent.com/perfmode/ad8cf189bbbaeeae1181/raw/6fb5e861a6dddc8cd6685573e492b0662c498a15/Makefile) (requires wget) | ||
2. Copy to MAGENTO_ROOT | ||
3. To install, run `make install` | ||
4. To update, run `make update` | ||
|
||
Configure | ||
--------- | ||
|
||
1. Log in to your Magento Admin portal. | ||
2. Visit System > Configuration > Payment Methods (under Sales) > Affirm | ||
3. Set the API URL. In a test environment, use ```https://sandbox.affirm.com```. On your live site, use ```https://www.affirm.com```. | ||
4. Provide your 3 keys (merchant API key, secret key, financial product key) | ||
5. Adjust the order total minimum and maximum options to control when Affirm is | ||
shown to your customers. | ||
|
||
 | ||
|
||
|
||
Contribute | ||
---------- | ||
|
||
1. Fork the repo | ||
2. Create your feature branch (```git checkout -b my-new-feature```). | ||
3. Commit your changes (```git commit -am 'Added some feature'```) | ||
4. Push to the branch (```git push origin my-new-feature```) | ||
5. Create a Pull Request | ||
|
||
**To run the tests:** | ||
|
||
``` | ||
make dependencies | ||
make test | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "affirm/affirm-php", | ||
"description": "Affirm PHP bindings", | ||
"keywords": [ | ||
"affirm", | ||
"api", | ||
"consumer finance", | ||
"credit", | ||
"e-commerce", | ||
"payment method" | ||
], | ||
"homepage": "https://affirm.com/", | ||
"authors": [ | ||
{ | ||
"name": "The Affirm Technology Team", | ||
"homepage": "https://www.affirm.com/company" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.2" | ||
}, | ||
"require-dev": { | ||
"zendframework/zendframework1": "1.12.6", | ||
"simpletest/simpletest": "1.1.*" | ||
}, | ||
"autoload": { | ||
"classmap": ["extension/lib/Affirm/"] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions
60
extension/app/code/community/Affirm/Affirm/Block/Payment/Form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
class Affirm_Affirm_Block_Payment_Form extends Mage_Payment_Block_Form | ||
{ | ||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
// TODO(brian): refactor this into a 3 step process to make the state | ||
// change more explicit | ||
$this->replaceLabel(); | ||
} | ||
|
||
protected function _toHtml() | ||
{ | ||
// TODO(brian): extract this html block to a template | ||
// TODO(brian): extract css | ||
$msg = "You'll complete your payment after you place your order."; | ||
|
||
$html = "<ul class=\"form-list\" id=\"payment_form_affirm\" style=\"display:none;\">"; | ||
$html .= "<li class=\"form-alt\">"; | ||
|
||
// heading | ||
$html .= "<div style=\"color:#034082; font-size:16px; \">"; | ||
$html .= "Pay over time in 3 easy payments"; | ||
$html .= "</div>"; | ||
|
||
// sub | ||
$html .= "<div style=\"color:#6f6f6f; font-size:14px; \">"; | ||
$html .= "just enter your basic details and get"; | ||
$html .= "<br>"; | ||
$html .= "approved instantly."; | ||
$html .= "</div>"; | ||
|
||
$html .= "</li>"; | ||
$html .= "</ul>"; | ||
|
||
return $html; | ||
} | ||
|
||
/* Replaces default label with custom image, conditionally displaying text | ||
* based on the Affirm product. | ||
* | ||
* Context: Payment Information step of Checkout flow | ||
*/ | ||
private function replaceLabel() | ||
{ | ||
$this->setMethodTitle(""); // removes default title | ||
|
||
// TODO(brian): extract html to template | ||
// TODO(brian): conditionally load based on env config option | ||
// This is a stopgap until the promo API is ready to go | ||
$logoSrc = "https://cdn1.affirm.com/images/badges/affirm-card_78x54.png"; | ||
$html = "<img src=\"" . $logoSrc . "\" width=\"39\" height=\"27\" class=\"v-middle\" /> "; | ||
|
||
// TODO(brian): conditionally display based on payment type | ||
// alt message: $html.= "Buy Now and Pay Later"; | ||
$html.= "3 Monthly Payments with Split Pay"; | ||
|
||
$this->setMethodLabelAfterHtml($html); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
extension/app/code/community/Affirm/Affirm/Block/Payment/Info.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
class Affirm_Affirm_Block_Payment_Info extends Mage_Payment_Block_Info | ||
{ | ||
|
||
protected function _toHtml() | ||
{ | ||
$html = '<a href="https://www.affirm.com/u/">Affirm Split Pay</a>'; | ||
return $html; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
extension/app/code/community/Affirm/Affirm/Block/Payment/Redirect.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
class Affirm_Affirm_Block_Payment_Redirect extends Mage_Core_Block_Abstract | ||
{ | ||
protected function _toHtml() | ||
{ | ||
$order = $this->getOrder(); | ||
$payment_method = $order->getPayment()->getMethodInstance(); | ||
|
||
$html = '<html><body>'; | ||
$html.= '<script type="text/javascript" src="'. trim($payment_method->getBaseApiUrl(), "/") . '/js/v2/affirm.js"></script>'; | ||
$html.= '<script type="text/javascript">'; | ||
$html.= 'affirm.checkout(' . json_encode($payment_method->getCheckoutObject($order)) . ');'; | ||
$html.= 'affirm.ui.error.on("close", function(){ window.location= "' . Mage::helper('checkout/url')->getCheckoutUrl() . '";});'; | ||
$html.= 'affirm.checkout.post();'; | ||
$html.= '</script>'; | ||
$html.= '</body></html>'; | ||
return $html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
class Affirm_Affirm_Helper_Data extends Mage_Core_Helper_Abstract | ||
{ | ||
|
||
} |
Oops, something went wrong.