data: {status: 400, params: {meta_data: “meta_data is not of type array.”}}
message: “Invalid parameter(s): meta_data”
Here is a code snippet:
data = {
payment_details : {
method_id: paymentData.method_id,
method_title: paymentData.method_title,
paid: true
},
billing: this.newOrder.billing,
shipping: this.newOrder.shipping,
line_items: orderItems,
meta_data: {
“vets_name”: this.newOrder.meta_data.vets_name,
“vets_city”: this.newOrder.meta_data.vets_city,
“vets_state”: this.newOrder.meta_data.vets_state,
“vets_phone”: this.newOrder.meta_data.vets_phone,
}
Without the meta_data, the order is created without a problem.
Thanks!
]]>The app is mobile version of my web main platfrom built with WordPress + Woocommerce. User can checkout the order from app and pay with bank transfer (BACS on Woocommerce). No instant payment using credit card, google play, or app store payment. That’s why my Android app not using in-app purchase plugin. I am using the same method to iOS app.
Everything runs well on iOS app development with Ionic Serve. Checkout page and flow runs perfect. But when it comes to iOS simulator and real iPhone device, app failed to get Woocommerce API on checkout page shows blank. I have no idea what wrong it is.
Error msg: Fetch API cannot load ‘link’ due to access control checks.
Please refer: https://prnt.sc/n6vd62
I read some documentations and probably my iOS app needs in-app purchase plugin and configuration. But, my app not providing instant purchase. I am not using credit card payment either. And everthing runs well on Android/Google Play.
Please enlight. Thanks
]]>Now I am trying to do the same with woocommerce products to get the products listed. I have tried the oauth v1 because the data has to be safe from potential hackers. I get that. But how do you implement that in Javascript? I have referred to the documentation at
https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#authentication-over-http
and https://github.com/woocommerce/wc-api-node
What to do from here. I can’t get anywhere. I have added the package to the project as well but can’t seem to know how to implement it.
Any help would be appreciated.
Thanks.
Now I am trying to do the same with woocommerce products to get the products listed. I have tried the oauth v1 because the data has to be safe from potential hackers. I get that. But how do you implement that in Javascript? I have referred to the documentation at
https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#authentication-over-http
and https://github.com/woocommerce/wc-api-node
What to do from here. I can’t get anywhere. I have added the package to the project as well but can’t seem to know how to implement it.
Any help would be appreciated.
Thanks.`
var googDevToken = notification.regid;
alert (googDevToken);
var data = {};
data.os= ‘Android’;
data.token= googDevToken;
$http({
method : ‘POST’,
url : ‘https://padraandishan.ir/pnfw/register/’,
data : ‘os=Android&token=’+googDevToken,
headers : {‘Content-Type’: ‘application/x-www-form-urlencoded’}
}).success(function(){
alert (‘sent to server successfully’);
}).error(function(err){
alert(JSON.stringify(err));
});
})
content-encoding: gzip
x-powered-by: php/5.5.9-1ubuntu4.21
connection: keep-alive
content-length: 3361
keep-alive: timeout=5, max=95
access-control-allow-headers: accept, authorization, cache-control, cookie, content-type, origin
server: apache/2.4.7 (ubuntu)
x-frame-options: allow-from *
vary: accept-encoding
access-control-allow-methods: get, post, options, head, put, delete, trace, connect, patch
content-type: text/html; charset=utf-8
access-control-allow-origin: *
access-control-expose-headers: cache-control, cookie, content-type, origin
cache-control: no-cache, must-revalidate, max-age=0
No matter what I do I get some CORS error. The most recent is:
Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
The JWT plugin also had in docs some mention of editing .htaccess and wp-config.php, which I did. Tried several combinations of htacces edit and/or plugins. But same or similar error pops up.
This is my code, based on doc of JWT plugin (credentials/url valid!):
var apiHost = 'https://dev.imok.ro/authworks/wp-json';
$http.post( apiHost + '/jwt-auth/v1/token', {
username: 'admin',
password: 'admin!@#'
})
.then( function( response ) {
console.log( 'siker', response.data )
})
.catch( function( error ) {
console.error( 'Errorrrr', error );
});
.htaccess:
#<ifModule mod_headers.c>
# Header always set Access-Control-Allow-Origin: *
## Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
## Header always set Access-Control-Allow-Headers "content-type"
#</ifModule>
<IfModule mod_rewrite.c>
#SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
RewriteEngine On
RewriteBase /authworks/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /authworks/index.php [L]
</IfModule>
Thanks for your help!
Magor