4 |
Your order was placed with ShapeShift.io payment.
5 |
Transaction information:
6 |
DepositAddress: getDepositAddress(); ?>
7 |
Amount: getAmountDeposit(); ?>
8 |
9 |
--------------------------------------------------------------------------------
/view/frontend/web/js/view/payment/method-renderer/shape_shift.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © 2016 Magento. All rights reserved.
3 | * See COPYING.txt for license details.
4 | */
5 | /*browser:true*/
6 | /*global define*/
7 | define(
8 | [
9 | 'ko',
10 | 'Magento_Checkout/js/view/payment/default',
11 | 'Magento_Checkout/js/model/quote',
12 | 'jquery',
13 | 'Magento_Checkout/js/action/place-order',
14 | 'Magento_Checkout/js/action/select-payment-method',
15 | 'Magento_Customer/js/model/customer',
16 | 'Magento_Checkout/js/checkout-data',
17 | 'Magento_Checkout/js/model/payment/additional-validators',
18 | 'mage/url',
19 | 'Magento_Checkout/js/model/full-screen-loader',
20 | 'Magento_Checkout/js/action/redirect-on-success'
21 | ],
22 | function (ko, Component, quote, $, placeOrderAction, selectPaymentMethodAction, customer, checkoutData, additionalValidators, url, fullScreenLoader, redirectOnSuccessAction) {
23 | 'use strict';
24 |
25 | return Component.extend({
26 | defaults: {
27 | template : 'Firebear_ShapeShift/payment/form',
28 | currencyCode : '',
29 | returnAddress : '',
30 | deposit : '',
31 | newErrorMessage: ko.observable(false)
32 | },
33 |
34 | initObservable: function () {
35 |
36 | this._super()
37 | .observe([
38 | 'currencyCode', 'returnAddress'
39 | ]);
40 | return this;
41 | },
42 |
43 | getCode: function () {
44 | return 'shape_shift';
45 | },
46 |
47 | getData : function () {
48 | return {
49 | 'method' : this.item.method,
50 | 'additional_data': {
51 | 'currency_code' : this.currencyCode(),
52 | 'return_address': this.returnAddress()
53 | }
54 | };
55 | },
56 | afterPlaceOrder : function () {
57 | jQuery.ajax({
58 | url : url.build('shapeshift/api/saveTransaction'),
59 | type : 'POST',
60 | dataType : 'json',
61 | showLoader: true,
62 | data : {"depoAmount": this.deposit.amount, "depoAddress": this.deposit.address}
63 | });
64 | /*window.location.replace(url.build('shapeshift/page/success/'));*/
65 | },
66 | placeOrder : function (data, event) {
67 | var self = this;
68 |
69 | if (event) {
70 | event.preventDefault();
71 | }
72 | if (this.currencyCode()) {
73 | jQuery.ajax({
74 | url : url.build('shapeshift/api/index'),
75 | type : 'POST',
76 | dataType : "json",
77 | showLoader: true,
78 | data : {"returnAddress": this.returnAddress(), "currencyCode": this.currencyCode()},
79 | success : function (data) {
80 | self.deposit = data;
81 | if (self.deposit.error) {
82 | self.isPlaceOrderActionAllowed(true);
83 | self.newErrorMessage('Message: ' + self.deposit.error + ' Request: ' + self.deposit.url);
84 | }
85 | else {
86 | if (self.validate() && additionalValidators.validate()) {
87 | self.isPlaceOrderActionAllowed(false);
88 | self.getPlaceOrderDeferredObject()
89 | .fail(
90 | function () {
91 | self.isPlaceOrderActionAllowed(true);
92 | }
93 | ).done(function () {
94 | self.afterPlaceOrder();
95 |
96 | if (self.redirectAfterPlaceOrder) {
97 | redirectOnSuccessAction.execute();
98 | }
99 | });
100 |
101 | return true;
102 | }
103 | }
104 | }
105 | });
106 | }
107 | else
108 | {
109 | self.isPlaceOrderActionAllowed(true);
110 | self.newErrorMessage('Message: Please select Currency code');
111 | }
112 |
113 | return false;
114 |
115 | },
116 | getPlaceOrderDeferredObject: function () {
117 | return $.when(
118 | placeOrderAction(this.getData(), this.messageContainer)
119 | );
120 | },
121 |
122 | getAvailableCurrency: function () {
123 | return _.map(window.checkoutConfig.payment.shape_shift.currencyCode, function (value, key) {
124 | return {
125 | 'value' : key,
126 | 'currency_code': value
127 | }
128 | });
129 | },
130 |
131 | getPaymentDescription: function () {
132 | return window.checkoutConfig.payment.shape_shift.paymentDescription;
133 | }
134 | });
135 | }
136 | );
--------------------------------------------------------------------------------
/view/frontend/web/js/view/payment/shape_shift.js:
--------------------------------------------------------------------------------
1 | define(
2 | [
3 | 'uiComponent',
4 | 'Magento_Checkout/js/model/payment/renderer-list'
5 | ],
6 | function (Component,
7 | rendererList) {
8 | 'use strict';
9 | rendererList.push(
10 | {
11 | type : 'shape_shift',
12 | component: 'Firebear_ShapeShift/js/view/payment/method-renderer/shape_shift'
13 | }
14 | );
15 | /** Add view logic here if needed */
16 | return Component.extend({});
17 | }
18 | );
--------------------------------------------------------------------------------
/view/frontend/web/template/payment/form.html:
--------------------------------------------------------------------------------
1 |
7 |