Skip to content

Commit 0f229fd

Browse files
author
calvinpy
committed
Merge branch 'master' of https://github.com/aplazame/woocommerce
2 parents 954ffcd + 8904d5f commit 0f229fd

File tree

10 files changed

+63
-28
lines changed

10 files changed

+63
-28
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
*.p12
1010
*.cer
1111
*.pem
12-
sftp-config.json
12+
*-config.json
1313

1414
.build
1515
.wpcs
16+
.svn*

HISTORY.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
## Change Log
22

3-
#### [v0.0.4-dev](https://github.com/aplazame/woocommerce/tree/v0.0.3) (2015-??-??)
3+
#### [v0.0.5-dev](https://github.com/aplazame/woocommerce/tree/v0.0.5) (2015-??-??)
44

5-
[Full Changelog v0.0.4](https://github.com/aplazame/woocommerce/compare/v0.0.3...v0.0.4)
5+
[Full Changelog v0.0.5](https://github.com/aplazame/woocommerce/compare/v0.0.4...v0.0.5)
66

7+
* Fix PHP 5.3 compatibility
8+
* Minor improvements
79
* ?
810

11+
#### [v0.0.4](https://github.com/aplazame/woocommerce/tree/v0.0.4) (2015-09-25)
12+
13+
[Full Changelog v0.0.4](https://github.com/aplazame/woocommerce/compare/v0.0.3...v0.0.4)
14+
15+
* Allow empty shipping
16+
* Fix security, order session key
17+
* Fix customer serializer
918

1019
#### [v0.0.3](https://github.com/aplazame/woocommerce/tree/v0.0.3) (2015-09-15)
1120

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[ ![Image](https://aplazame.com/static/img/banners/banner-728-white-woo.png "Aplazame") ](https://aplazame.com "Aplazame")
22

3-
[![Package version](https://img.shields.io/packagist/v/aplazame/woocommerce.svg)](https://packagist.org/packages/aplazame/woocommerce) [![Build Status](http://drone.aplazame.com/api/badge/github.com/aplazame/woocommerce/status.svg?branch=master)](http://drone.aplazame.com/github.com/aplazame/woocommerce) [![Dependencies](https://www.versioneye.com/php/aplazame:woocommerce/badge.svg)](https://www.versioneye.com/php/aplazame:woocommerce)
3+
[![Package version](https://img.shields.io/packagist/v/aplazame/woocommerce.svg)](https://packagist.org/packages/aplazame/woocommerce) [![Plugin version](https://img.shields.io/wordpress/plugin/v/aplazame.svg)](https://wordpress.org/plugins/aplazame/) [![Build Status](http://drone.aplazame.com/api/badge/github.com/aplazame/woocommerce/status.svg?branch=master)](http://drone.aplazame.com/github.com/aplazame/woocommerce) [![Dependencies](https://www.versioneye.com/php/aplazame:woocommerce/badge.svg)](https://www.versioneye.com/php/aplazame:woocommerce)
44

55

66
### Install

README.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ Of course, simply select an *"Aplazame refund"* in the product detail.
108108

109109
== Changelog ==
110110

111+
#### [v0.0.4] (2015-09-25)
112+
113+
[view on Github](https://github.com/aplazame/woocommerce/tree/v0.0.4)
114+
115+
* Allow empty shipping
116+
* Fix security, order session key
117+
* Fix customer serializer
118+
111119
#### v0.0.3 (2015-09-15)
112120

113121
[view on Github](https://github.com/aplazame/woocommerce/tree/v0.0.3)
@@ -135,6 +143,6 @@ Of course, simply select an *"Aplazame refund"* in the product detail.
135143

136144
== Upgrade Notice ==
137145

138-
= v0.0.3 =
146+
= v0.0.4 =
139147

140148
The latest release has passed all quality checks.

aplazame.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Plugin Name: Aplazame
44
* Plugin URI: https://github.com/aplazame/woocommerce
5-
* Version: 0.0.3
5+
* Version: 0.0.4
66
* Description: Aplazame offers a payment method to receive funding for the purchases.
77
* Author: calvin
88
*
@@ -17,7 +17,7 @@
1717

1818
class WC_Aplazame
1919
{
20-
const VERSION = '0.0.3';
20+
const VERSION = '0.0.4';
2121
const METHOD_ID = 'aplazame';
2222
const METHOD_TITLE = 'Aplazame';
2323

classes/lib/Redirect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public static function get_the_ID()
3535

3636
public static function payload()
3737
{
38-
if (static::is_redirect()) {
38+
if (static::is_redirect() &&
39+
((string) WC()->session->redirect_order_id === $_GET['order_id'])) {
3940
Aplazame_Helpers::render_to_template('gateway/redirect.php');
4041
}
4142
}

classes/sdk/Serializers.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public static function woo_version()
1010
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
1111
}
1212

13-
return get_plugins('/woocommerce')['woocommerce.php']['Version'];
13+
$woo = get_plugins('/woocommerce');
14+
return $woo['woocommerce.php']['Version'];
1415
}
1516

1617
public static function get_meta()
@@ -52,18 +53,24 @@ public function get_articles($items)
5253
return $articles;
5354
}
5455

55-
public function get_customer($customer)
56+
public function get_user($user)
5657
{
57-
$serializer = array(
58-
'id' => (string) $customer->id,
59-
'type' => 'n',
58+
return array(
59+
'id' => (string) $user->id,
60+
'type' => 'e',
6061
'gender' => 0,
61-
'email' => $customer->user_email,
62-
'first_name' => $customer->first_name,
63-
'last_name' => $customer->last_name,
64-
'date_joined' => date(DATE_ISO8601, $customer->user_registered));
62+
'email' => $user->user_email,
63+
'first_name' => $user->first_name,
64+
'last_name' => $user->last_name,
65+
'date_joined' => date(DATE_ISO8601, $user->user_registered));
66+
}
6567

66-
return $serializer;
68+
public function get_customer($billing_email)
69+
{
70+
return array(
71+
'type' => 'n',
72+
'gender' => 0,
73+
'email' => $billing_email);
6774
}
6875

6976
public function get_address($order, $type)
@@ -106,7 +113,7 @@ public function get_shipping_info($order)
106113
public function get_order($order)
107114
{
108115
$serializer = array(
109-
'id' => $order->id,
116+
'id' => (string) $order->id,
110117
'articles' => $this->get_articles($order->get_items()),
111118
'currency' => get_woocommerce_currency(),
112119
'total_amount' => Aplazame_Filters::decimals($order->get_total()),
@@ -116,9 +123,9 @@ public function get_order($order)
116123
return $serializer;
117124
}
118125

119-
public function get_checkout($order, $checkout_url, $customer)
126+
public function get_checkout($order, $checkout_url, $user)
120127
{
121-
return array(
128+
$serializer = array(
122129
'toc' => true,
123130
'merchant' => array(
124131
'confirmation_url' => home_url(
@@ -130,11 +137,19 @@ public function get_checkout($order, $checkout_url, $customer)
130137
'success_url' => html_entity_decode(
131138
$order->get_checkout_order_received_url())
132139
),
133-
'customer' => $this->get_customer($customer),
140+
'customer' => $user->id?$this->get_user(
141+
$user):$this->get_customer($order->billing_email),
134142
'order' => $this->get_order($order),
135143
'billing' => $this->get_address($order, 'billing'),
136-
'shipping' => $this->get_shipping_info($order),
137144
'meta' => static::get_meta());
145+
146+
$shipping_method = $order->get_shipping_method();
147+
148+
if (!empty($shipping_method)) {
149+
$serializer['shipping'] = $this->get_shipping_info($order);
150+
}
151+
152+
return $serializer;
138153
}
139154

140155
public function get_history($qs)

classes/wc-aplazame-gateway.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function payment_fields()
5555
public function process_payment($order_id)
5656
{
5757
$url = get_permalink(Aplazame_Redirect::get_the_ID());
58+
WC()->session->redirect_order_id = $order_id;
5859

5960
return array(
6061
'result' => 'success',
@@ -96,7 +97,7 @@ public function checks()
9697
echo '<div class="error"><p>' . $msg . '</p></div>';
9798
};
9899

99-
if ($this->settings['public_api_key'] || !$this->settings['private_api_key']) {
100+
if (!$this->settings['public_api_key'] || !$this->settings['private_api_key']) {
100101
$_render_to_notice(sprintf(__(
101102
'Aplazame gateway requires the API keys, please ' .
102103
'<a href="%s">contact us</a> and take your keys.', 'aplazame'),

l10n/es/default.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#, fuzzy
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: Aplazame v0.0.3\n"
9+
"Project-Id-Version: Aplazame v0.0.4\n"
1010
"Report-Msgid-Bugs-To: \n"
1111
"POT-Creation-Date: 2015-09-12 01:59+0200\n"
12-
"PO-Revision-Date: 2015-09-14 00:00+0200\n"
12+
"PO-Revision-Date: 2015-09-25 00:00+0200\n"
1313
"Last-Translator: Aplazame <[email protected]>\n"
1414
"Language-Team: Aplazame <[email protected]>\n"
1515
"Language: es_ES\n"

templates/gateway/redirect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
global $woocommerce;
88

99
$cart = $woocommerce->cart;
10-
$customer = wp_get_current_user();
10+
$user = wp_get_current_user();
1111
$order = new WC_Order($_GET['order_id']);
1212
$serializer = new Aplazame_Serializers();
1313
?>
1414

1515
<script type="text/javascript">
1616
aplazame.checkout(<?php echo json_encode($serializer->get_checkout(
17-
$order, $cart->get_checkout_url(), $customer), 128) ?>);
17+
$order, $cart->get_checkout_url(), $user), 128) ?>);
1818
</script>

0 commit comments

Comments
 (0)