for a customer I need to charge an applicationFee for each order that has been processed on their site from the sub customers. The whole code is working with authentication and everything.
But from the moment I'm adding:
'applicationFee' => $applicationFee
to the call I receive this error:
Error executing API call (422: Unprocessable Entity): Unable to process application request for this account. Documentation: https://docs.mollie.com/guides/handling-errors"
The content of "$applicationFee" is correct, that I was able to check already.
The $shop_mollie_data->profile_id containts the different websiteprofileId's found on the Mollie dashboard.
$provider = new MollieConnectProvider($request, $clientId, $clientSecret, $redirectUrl);
$newAccessToken = $provider->getRefreshTokenResponse($shop_mollie_data->refresh_token);
$mollie = new MollieApiClient();
$mollie->setAccessToken($newAccessToken['access_token']);
$payment = $mollie->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => (string) (sprintf("%.2f", $order_total))
],
'description' => ucfirst($shop->name) . ' - Order #' . $order_nm,
'webhookUrl' => $url_callback,
'redirectUrl' => $url_success,
'method' => 'bancontact',
'locale' => $language_id,
'metadata' => [
"order_id" => $ref,
"shop id" => $shop->id
],
'profileId' => $shop_mollie_data->profile_id,
'testmode' => true,
'applicationFee' => $applicationFee
]);
Related
I am using the marketing API to create ads with curl in PHP.
Creating Campaign Groups and Campaigns in this way is working perfectly fine. The basic creation of a creative and an ad is also working. The only problem is that i can’t add a destination URL and some other info’s like the description and Call-to-Action. But the destination URL or content Landing Page like it’s called in the documentation really is fundamental.
This is my code for the creative data:
$data = [
"creative" => [
"inlineContent" => [
"post" => [
"adContext" => [
"dscAdAccount" => "urn:li:sponsoredAccount:".$this->params->get('app.linkedin_my_acc_id'),
"dscStatus" => "ACTIVE"
],
"author" => "urn:li:organization:".$this->params->get('app.linkedin_my_org_id'),
"commentary" => $job->getCommentary(),
"visibility" => "PUBLIC",
"lifecycleState" => "PUBLISHED",
"isReshareDisabledByAuthor" => false,
"contentCallToActionLabel" => "DOWNLOAD",
"contentLandingPage" => "https://google.com",
"content" => [
"media" => [
"title" => "This is a test!",
"id" => $image
]
]
]
],
"campaign" => "urn:li:sponsoredCampaign:".$myCampaignId,
"intendedStatus" => "ACTIVE"
]
];
The structure is the same as in the documentation (https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-creatives-new?view=li-lms-2023-01&tabs=http#creatives-inline-schema).
So what am I doing wrong? Why is LinkedIn ignoring my contentLandingPage and contentCallToActionLabel values? The request is working and Im not getting an unpermitted fields error so it seems to be correct…
Can someone help? I also can provide the code of the Campaign Group and the Campaign if needed.
Not sure if this is important but the objectiveType of my Campaign is “WEBSITE_VISIT” and the type is “SPONSORED_UPDATES”.
When I try to get the token I get the error:
The provided value for the 'redirect_uri' is not valid. The value must exactly match the redirect URI used to obtain the authorization code.
My redirect uri exactly matches so I don't understand why it is happening.
$TOKEN_ENDPOINT = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
$params = array(
'grant_type' => 'authorization_code',
'code' => $azureCode,
'clientId' => '7c09ab71-***-****-****-53d7c4438112',
'clientSecret' => 'bnot*******20*[',
'redirect_uri' => 'https://testing.****.com/outlookOauthCallback.php',
'urlAuthorize' => $AUTHORIZATION_ENDPOINT,
'urlAccessToken' => $TOKEN_ENDPOINT,
'urlResourceOwnerDetails' => '',
'scope' => 'Calendars.ReadWrite User.Read'
);
$response = $client->getAccessToken($TOKEN_ENDPOINT, 'authorization_code', $params);
(Trust me the part I turned into stars is exactly the same because I copy pasted)
Even in the response where I returned the params it is exactly the same:
Array
(
[grant_type] => authorization_code
[code] => M51b1b*****-daeec54627b2
[clientId] => 7c09ab71-a*****d7c4438112
[clientSecret] => bnotxds&*&QB***cVLF20*[
[redirect_uri] => https://testing.****.com/outlookOauthCallback.php
[urlAuthorize] => https://login.microsoftonline.com/common/oauth2/v2.0/authorize
[urlAccessToken] => https://login.microsoftonline.com/common/oauth2/v2.0/token
[urlResourceOwnerDetails] =>
[scope] => Calendars.ReadWrite User.Read
)
So how can it still be giving me this error? What am I missing here?
You need specify the redirect_uri in the request url. Something like
var href = 'login.microsoftonline.com/common/oauth2/…'; href += client_id + '&resource=webdir.online.lync.com&redirect_uri=' + window.location.href;
I'm trying to figure out why I can't seem to update a tracking number using the eBay API. Here is the page I'm referencing:
http://developer.ebay.com/DevZone/merchant-data/CallRef/SetShipmentTrackingInfo.html
Based on that, I've got the following code in Perl:
use Net::eBay;
my $ebay = new Net::eBay( {
SiteLevel => 'prod',
DeveloperKey => 'x',
ApplicationKey => 'xxxx',
CertificateKey => 'xxx',
Token => 'xxxx',
} );
$ebay->setDefaults( { API => 2, compatibility => 900 } );
my $result = $ebay->submitRequest( "SetShipmentTrackingInfoRequest",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
OrderID => 1234546, # not the real order ID I'm using :)
ShipmentTrackingDetails => {
ShipmentTrackingNumber => "12345",
ShippingCarrierUsed => "Hermes"
}
});
print $IN->header;
use Data::Dumper;
print Dumper($result);
When running it, I get an error in $result:
$VAR1 = {
'Errors' => {
'ErrorClassification' => 'RequestError',
'SeverityCode' => 'Error',
'ShortMessage' => 'Unsupported API call.',
'ErrorCode' => '2',
'LongMessage' => 'The API call "SetShipmentTrackingInfoRequest" is invalid or not supported in this release.'
},
'xmlns' => 'urn:ebay:apis:eBLBaseComponents',
'Timestamp' => '2016-10-21 07:03:04',
'Build' => '18007281',
'Version' => '900',
'Ack' => 'Failure'
};
I'm a bit confused, as it looks like SetShipmentTrackingInfoRequest is the API call I need to be making? I've not really done much with the eBay API, so it's possible I'm missing something stupid.
UPDATE: As per feedback below, I'm now using the CompleteSale API call:
http://developer.ebay.com/Devzone/XML/docs/Reference/eBay/CompleteSale.html
my $result = $ebay->submitRequest( "CompleteSale ",
{
DetailLevel => "ReturnAll",
ErrorLevel => "1",
SiteId => "1",
OrderID => 1933420817015,
Shipment => {
ShipmentTrackingDetails => {
ShipmentTrackingNumber => "77293124902615",
ShippingCarrierUsed => "Hermes"
}
}
});
When I run it, I now get the error:
'LongMessage' => 'XML Error Text: "; nested exception is:
org.xml.sax.SAXParseException: Attribute name "Request" associated with an element type "CompleteSale" must be followed by the
\' = \' character.".',
Enabling debugging, the XML being sent is:
<?xml version='1.0' encoding='utf-8'?>
<CompleteSale Request xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>xxxx</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
<ErrorLevel>1</ErrorLevel>
<OrderID>xxxxx</OrderID>
<Shipment>
<ShipmentTrackingDetails>
<ShipmentTrackingNumber>xxxx</ShipmentTrackingNumber>
<ShippingCarrierUsed>Hermes</ShippingCarrierUsed>
</ShipmentTrackingDetails>
</Shipment>
<SiteId>1</SiteId>
</CompleteSale Request>
From looking at the eBay API doc link you posted doesn't the second 'Note' entirely explain why it doesn't work as a single API call?
Note: SetShipmentTrackingInfo cannot be issued on its own like an ordinary API call, using an endpoint
It then goes on to say:
In the Trading API, the CompleteSale call provides similar functionality that you can invoke directly
So perhaps looking there should be the next step
I'm using the Amazon AWS SDK for PHP (namely, version 2.7.16) to upload files to an S3 bucket. How can I set a timeout for http/tcp operations (connection, upload, etc.)? Although I've googled a lot I wasn't able to find out how.
Sample code I'm using:
$awsS3Client = Aws\S3\S3Client::factory(array(
'key' => '...',
'secret' => '...'
));
$awsS3Client->putObject(array(
'Bucket' => '...',
'Key' => 'destin/ation.file',
'ACL' => 'private',
'Body' => 'content'
));
so I'd like to set a timeout on the putObject() call.
Thanks!
Eventually I helped myself:
$awsS3Client = Aws\S3\S3Client::factory(array(
'key' => '...',
'secret' => '...'
'curl.options' => array(
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 10,
)
));
Looks like AWS PHP uses curl internally, so network related options are set this way.
With SDK version 3 this can be configured using the http configuration key.
$awsS3Client = Aws\S3\S3Client([
'key' => '...',
'secret' => '...',
'http' => [
'connect_timeout' => 5,
'timeout' => 10,
]
]);
I have the Auth component working perfectly for an application running Cake 2.4.1, and I need to copy it to another application that is also running Cake 2.4.1. I copied over everything I could think of that has to do with Auth stuff, but it just does not work in the second application. It refuses to log me in. The call to $this->Auth->login() fails even though it gets exactly the same data as the application that works.
Both applications are using exactly the same database and user login.
Both applications get exactly the same request data in the POST request.
First of all, here is my setup.
In AppController.php:
public $uses = array ('User');
public $components = array ( 'Session',
'CPRACL.CPRACL' => array (),
'Auth' => array (
// 'loginAction' => array ('controller' => 'users', 'action' => 'login'),
// 'logoutRedirect' => '/users/login',
// 'loginRedirect' => '/',
'authenticate' => array (
'Form' => array (
'fields' => array ('username' => 'email_address'),
'scope' => array ('User.active' => 1)
)
),
'authorize' => array ('Controller'),
// 'unauthorizedRedirect' => '/' // when going to a page the user is not authorized to go to
)
);
The commented out lines use the defaults, but they are included for reference to their default values. This is exactly the same in both applications. CPRACL is a plugin component that I am using instead of Cake's ACL component, but it fails long before it gets to any of that.
Also in AppController.php:
public function beforeFilter ()
{
$login_user = $this->User->find ('first', array ('conditions' => array ('id' => $this->Auth->user ('id'))));
if (!empty ($login_user))
$this->set ('login_user', $login_user ['User']);
}
public function isAuthorized ($user = null)
{
// This never gets called in the application that does not work, but it does get called in the one that works.
}
In both applications, it sets up the Auth component as defined in AppController.php, then it calls beforeFilter to check to see if the user is already logged in. This is a convenience so that when they get redirected to a different page, the application can display the username of the user who is logged in. It works fine and I don't think it is causing any problems.
The next thing that happens is it calls UsersController::login()
public function login ()
{
$redirect_url = $this->Auth->redirectUrl ();
if ($this->Auth->loggedIn ())
return $this->redirect ($redirect_url);
//die (print_r ($this->request->data, true));
if ($this->request->is ('post'))
{
//die (Debugger::dump ($this->Auth));
if ($this->Auth->login ())
return $this->redirect ($redirect_url);
else
return $this->redirect ($this->Auth->loginAction);
}
}
I used the two commented out lines to compare what is happening between the two applications. The two applications get exactly the same data in the post. For the dump of the Auth object, here is what I get:
object(AuthComponent) {
components => array(
(int) 0 => 'Session',
(int) 1 => 'RequestHandler'
)
authenticate => array(
'Form' => array(
[maximum depth reached]
)
)
authorize => array(
(int) 0 => 'Controller'
)
ajaxLogin => null
flash => array(
'element' => 'default',
'key' => 'auth',
'params' => array([maximum depth reached])
)
loginAction => array(
'controller' => 'users',
'action' => 'login',
'plugin' => null
)
loginRedirect => null
logoutRedirect => array(
'controller' => 'users',
'action' => 'login',
'plugin' => null
)
authError => 'You are not authorized to access that location.'
unauthorizedRedirect => true
allowedActions => array(
(int) 0 => 'register',
(int) 1 => 'login',
(int) 2 => 'logout'
)
request => object(CakeRequest) {}
response => object(CakeResponse) {}
settings => array(
'authenticate' => array(
[maximum depth reached]
),
'authorize' => array(
[maximum depth reached]
)
)
Session => object(SessionComponent) {}
[protected] _authenticateObjects => array()
[protected] _authorizeObjects => array()
[protected] _user => array()
[protected] _methods => array(
(int) 0 => 'index',
(int) 1 => 'view',
(int) 2 => 'add',
(int) 3 => 'register',
(int) 4 => 'login',
(int) 5 => 'logout',
(int) 6 => 'toggleactive',
(int) 7 => 'changePassword',
(int) 8 => 'passwordHash',
(int) 10 => 'edit_pwd',
(int) 11 => 'edit_your_pwd',
(int) 12 => 'isAuthorized'
)
[protected] _Collection => object(ComponentCollection) {}
[protected] _componentMap => array(
'Session' => array(
[maximum depth reached]
),
'RequestHandler' => array(
[maximum depth reached]
)
)
}
That is what both applications return from the Auth object dump when I send the login request. It says the user is not authorized to access that location, but I think that is because it hasn't actually logged the user in yet, so I don't think the dump of that Auth object is of much value, but I included it here anyway.
But here is the most important part because it is the only thing that is obviously different between the two applications. When I perform the login on the working application, it logs me in successfully and my layout (which displays the most recent query) shows this query. Notice the id field. The id field is correct in the query and it works.
SELECT `User`.`id`, `User`.`user_id`, `User`.`email_address`, `User`.`first_name`, `User`.`last_name`, `User`.`password`, `User`.`active`, `User`.`created`, `User`.`modified` FROM `brian_cake_test`.`users` AS `User` WHERE `id` = '529f9a8c-3460-46a2-a97c-6a6242a26b88' LIMIT 1
But when I do exactly the same thing for the application that does not work, everything happens exactly the same way except that it redirects me back to the login page, which it should do if it fails to login, and it displays this query in my layout.
SELECT `User`.`id`, `User`.`user_id`, `User`.`email_address`, `User`.`first_name`, `User`.`last_name`, `User`.`password`, `User`.`active`, `User`.`created`, `User`.`modified` FROM `brian_cake_test`.`users` AS `User` WHERE `id` IS NULL LIMIT 1
Notice how the id is NULL in the second query. I have no idea why this is happening.
My User.php model is just an empty class, exactly the same in both application, but one works perfectly and the other does not.
<?php
App::uses ('AppModel', 'Model');
class User extends AppModel
{
public $name = 'User';
}
I have racked my brain trying to figure out what is different between these two applications, and I can't think of anything, and nothing I try will make it work. I don't want to post hundreds of lines of code when I know that 99% of it has nothing to do with this problem, but I have no idea why it works in one but not the other. I will gladly post more information if you think you might know what the problem is. Any help would be much appreciated. This is very important to me.
Actually if its exactly the same code and DB it shouldn't be a reason not to work.
Have you tried clearing the cache folders? Those files sometimes mess up the app.