I heard that authorize.net has a new API. I use an API to manage recurring payments where I send XML requests of the form shown below (in PHP, i.e. $authnet_ etc . will be replaced by actual values). Is this deprecated?
<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<ARBCreateSubscriptionRequest xmlns= \"AnetApi/xml/v1/schema/AnetApiSchema.xsd\">
<merchantAuthentication>
<name>$authnet_loginname</name>
<transactionKey>$authnet_transactionkey</transactionKey>
</merchantAuthentication>
<subscription>
<name>{$name}</name>
<paymentSchedule>
<interval>
<length>$length</length>
<unit>$unit</unit>
</interval>
<startDate>$startDate</startDate>
<totalOccurrences>$totalOccurrences</totalOccurrences>
</paymentSchedule>
<amount>$intern_amount</amount>
<payment>
<creditCard>
<cardNumber>$x_card_number</cardNumber>
<expirationDate>$expirationDate</expirationDate>
</creditCard>
</payment>
<order>
<invoiceNumber>$action_id</invoiceNumber>
<description>$description</description>
</order>
<customer>
<email>$x_email</email>
<phoneNumber> $x_phone </phoneNumber>
</customer>
<billTo>
<firstName>$intern_first_name</firstName>
<lastName>$intern_last_name</lastName>
<address>$intern_address</address>
<city>$intern_city</city>
<state>$intern_state</state>
<zip>$intern_zip</zip>
<country>$intern_country</country>
</billTo>
<shipTo>
<firstName>$intern_ship_to_first_name</firstName>
<lastName>$intern_ship_to_last_name</lastName>
<address>$intern_ship_to_address</address>
<city>$intern_ship_to_city</city>
<state>$intern_ship_to_state</state>
<zip>$intern_ship_to_zip</zip>
<country>$intern_ship_to_country</country>
</shipTo>
</subscription>
</ARBCreateSubscriptionRequest>
Authorize.Net did not deprecate XML formatted API requests. They work in parallel with the newer JSON format.
They still list it on their API Reference and documentation.
Related
I have booked a valid available service through Sabre PassengerDetailsRS and booking was successful. But in the GetReservationRS, price of the service is missing. How can we get that price. My GetReservationRQ was as below
<?xml version="1.0" encoding="UTF-8"?>
<ns7:GetReservationRQ xmlns:ns7="http://webservices.sabre.com/pnrbuilder/v1_19" Version="1.19.0">
<ns7:Locator>*pnr_number</ns7:Locator>
<ns7:RequestType>Stateful</ns7:RequestType>
<ns7:ReturnOptions PriceQuoteServiceVersion="3.2.0">
<ns7:SubjectAreas>
<ns7:SubjectArea>PRICE_QUOTE</ns7:SubjectArea>
</ns7:SubjectAreas>
<ns7:ViewName>Full</ns7:ViewName>
<ns7:ResponseFormat>STL</ns7:ResponseFormat>
</ns7:ReturnOptions>
</ns7:GetReservationRQ>
</soapenv:Body>
And in the response, that service is present which I booked in the booking step. But there is no pricing reference for that service, only the flight total price is present which is service excluded price
...
/SPORTING FIREARMS
WEAP BA NN1 LHRZRH0720N11AUG/SPORTING FIREARMS
I
BA
110.59
2019-06-16T13:03:00
. . .
How can I get the price of ode="WEAP" (<or114:FreeText>/SPORTING FIREARMS</or114:FreeText>)
you have to add ReturnOptions->SubjectArea->PRICE_QUOTE in GetReservationRQ
e.g:
<ReturnOptions PriceQuoteServiceVersion="3.2.0">
<SubjectAreas>
<SubjectArea>PRICE_QUOTE</SubjectArea>
</SubjectAreas>
</ReturnOptions>
for more details please have a look at below URL (Sabre Documentation)
`https://beta.developer.sabre.com/docs/soap_apis/management/itinerary`/Retrieve_Itinerary
I use GetPriceQuoteRQ after GetReservationRQ.
https://beta.developer.sabre.com/docs/soap_apis/air/fulfill/manage_price_quote_details
As this is an upsell for most airlines it falls under ancillary services - therefore to price them you should use: GetAncillaryOffersRQ
I'm trying to access to Google Calendar through CalDAV API with Google's API library for Ruby (I use service accounts as the application type).
I've written following code, but this doesn't work when the HTTP method is PUT or POST and outputs an error "HTTP method not allowed" with the status code 405. However, it works correctly when the method is GET or DELETE.
require 'google/api_client'
client = Google::APIClient.new(
application_name: 'test',
application_version: '1.0.0'
)
calendar_id = 'CALENDER_ID'
BASE_URL = "https://apidata.googleusercontent.com/caldav/v2/#{calendar_id}/events/"
key = Google::APIClient::KeyUtils.load_from_pkcs12('P12_FILE', 'notasecret')
client.authorization = Signet::OAuth2::Client.new(
token_credential_uri: 'https://www.googleapis.com/oauth2/v3/token',
audience: 'https://www.googleapis.com/oauth2/v3/token',
scope: 'https://www.googleapis.com/auth/calendar',
issuer: 'foobar#developer.gserviceaccount.com',
signing_key: key)
client.authorization.fetch_access_token!
body = <<EOS
BEGIN:VCALENDAR
VERSION:2.0
PRODID:test
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:CAMPHOR- Schedule 201503
BEGIN:VTIMEZONE
TZID:Asia/Tokyo
BEGIN:STANDARD
DTSTART:19700101T000000
TZOFFSETFROM:+0900
TZOFFSETTO:+0900
TZNAME:JST
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20150224T080050Z
UID:4807869c-ba02-48cc-aed5-0e0f5ff19022
DTSTART:20150331T150000
DTEND:20150331T200000
DESCRIPTION:
SUMMARY:DEST 2015-03-31 15:00:00 +0900 2015-03-31 20:00:00 +0900
END:VEVENT
END:VCALENDAR
EOS
request = Google::APIClient::Request.new(
uri: BASE_URL,
body: body,
http_method: :post,
headers: {
'Content-Type' => 'application/xml; charset=utf-8'
}
)
result = client.execute(request)
puts result.response.status
puts result.response.env
Could you tell me how should I fix this code to be able to use the all methods?
The initial problem is you can't PUT to the collection resource like that in CalDAV. See section 5.3.2 of the spec for more details. In other words, the URL should be something like ".../events/somerandomeventid.ics"
That said, you're headed down a bad path here.
The API client you're using isn't meant to be used with CalDAV.
Unless you have a good reason to use CalDAV, don't. Use the calendar API.
Calendar isn't meant to be used with non-user accounts like that. Sure, it might work, but it's not in the spirit of the product/API.
I am doing a URL rewrite in my API End point. So, the querystring is not passed by default to the backend service.
I want to create a variable with name "querystring" and format that string with the input query params. How can I do that?
For eg: apigee api url = https://myapigee-prod.agigee.net/v1/test/resource1?p1=abc&p2=123
I want to create the querystring variable as querystring = param1=abc¶m2=123
I tried
<AssignVariable>
<Name>myqs</Name>
<Value>param1={request.queryparam.p1}¶m2={request.queryparam.p2}</Value>
</AssignVariable>
<Ref> tag can be used instead of <Value> tag only if I am getting value of one parameter. To form a string, it wouldn't work.
Unfortunately you can't use the curly braces method of variable expansion within an AssignVariable.
You can do this via a JavaScript policy. Here is the JavaScript code:
var myqs = "param1=" + context.getVariable("request.queryparam.p1") +
"¶m2=" + context.getVariable("request.queryparam.p2");
context.setVariable("myqs", myqs);
Also, you can use an AssignMessage policy to do this, on the Proxy request or Target request flow.
http://apigee.com/docs/api-services/content/generate-or-modify-messages-using-assignmessage
e.g.
<AssignMessage name="GenerateRequest">
<AssignTo createNew="false" type="request">Request</AssignTo>
<Set>
<QueryParams>
<QueryParam name="p1">{request.queryparam.param1}</QueryParam>
<QueryParam name="p2">{request.queryparam.param2}</QueryParam>
</QueryParams>
</Set>
</AssignMessage>
This is the service callout policy:
<ServiceCallout name="GeoCodeClient">
<Request clearPayload="false" variable="GeocodingRequest" />
<Response>GeocodingResponse</Response>
<Timeout>30000</Timeout>
<HTTPTargetConnection>
<URL>http://maps.googleapis.com/maps/api/geocode/json</URL>
</HTTPTargetConnection>
</ServiceCallout>
Let us say I have to access a resource that is username/password protected. How do I add that basic authorization to this policy to enable me to do that?
In our project a KeyValueMaps are used to store the basic auth info at org level. The authorisation information is retrieved using the KeyValueMap policy and added as the basic auth header to the request message.
See if this approach works for you.
To add Basic Authentication header for your service callout, you can use an 'AssignMessage' policy that sets the 'Authorization' header in the 'GeocodingRequest' as follows:
<AssignMessage enabled="true" continueOnError="true" async="false" name="AssignAuthorizationHeaderPolicy">
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="http" type="request">GeocodingRequest</AssignTo>
<Add>
<Headers>
<Header name="Authorization">Basic YourAuthenticationHeader</Header>
</Headers>
</Add>
</AssignMessage>
Once you have created this policy, you will need to attach it in the request flow before the serviceCallout in the proxy.xml as flows:
<Step>
<FaultRules/>
<Name>AssignAuthorizationHeaderPolicy</Name>
</Step>
<Step>
<FaultRules/>
<Name>GeoCodeClient</Name>
</Step>
to add to what's already been said, if you need base64 encoding (and you probably will if you're using Basic Authorization), you'll need to do script callout. For instance, you can use the following Python:
import base64
if (client_secret is not None):
data = client_id + ":" + client_secret
header_value = base64.b64encode(data)
header_value = "Basic " + header_value
flow.setVariable("request.header.Authorization", header_value)
JS will be a little trickier since you need to include appropriate libraries, but I'm sure SO has plenty of more examples to follow for that.
Using Key Value Map to store sensitive data in a secure way
Step 1)Use below API to Create/Update the key Value maphttps://api.enterprise.apigee.com/v1/o/{orgname}/environments/{env}/keyvaluemaps Body:-{
"entry" : [ {
"name" : "basic_auth_system1",
"value" : "Basic XXXXXXXXXXX"
} ],
"name" : "system1_credentials"
}
Step 2) Policy used to lookup The key Value map
<KeyValueMapOperations enabled="true" continueOnError="false" async="false" name="keymap_get_credentials" mapIdentifier="system1_credentials">
<DisplayName>keymap_get_credentials</DisplayName>
<FaultRules/>
<Properties/>
<ExpiryTimeInSecs>-1</ExpiryTimeInSecs>
<Get assignTo="basic_auth_system1">
<Key>
<Parameter>basic_auth_system1</Parameter>
</Key>
</Get>
<Scope>environment</Scope>
</KeyValueMapOperations>
I'm getting an error (INVALID_SESSION_ID) when trying to send an authenticated GET request to Salesforce.com.
Here is the plug-in in its entirety, which basically just outputs the body of the REST response to whatever page has the [MembershipTables] shortcode:
if (!class_exists('WP_Http')) {
include_once(ABSPATH . WPINC . '/class-http.php');
}
// This is obviously the real username
$username = 'xxxx#xxxx.xxx';
// And this is obviously the real password concatonated with the security token
$password = 'xxxxxxxxxxxxxx';
function getMembershipTables() {
$api_url = 'https://na15.salesforce.com/services/apexrest/directory';
$headers = array('Authorization' => 'Basic ' . base64_encode("$username:$password"));
$args = array('headers' => $headers);
$request = new WP_Http;
$result = $request->request($api_url, $args);
$body = $result['body'];
echo "$body";
}
add_shortcode( 'MembershipTables', 'getMembershipTables' );
I should note that I can successfully hit this endpoint with Curl, though I use a session token I get from Salesforce using the old SOAP API to keep it equivalent (i.e., no client id/secret).
Am I doing something wrong with WP_Http? Or cannot I not authenticate a salesforce.com request using basic auth?
Thanks.
The salesforce API does not support Basic authentication, you need to call it with a sessionId. You can obtain a sessionId by various methods include interactive & programatic OAuth2 flows, and via a Soap login call.
Basis Interactive had a similar problem to solve. When I worked on the project I opted to to call the SalesForce CRM via the preset form plugin and a custom JS Cookie PHP Wordpress Plugin. We had this problem easily resolved by developing custom calls to SalesForce CRM via a getRequest in PHP passing data to the SalesForce CRM.
Test Site in Use:
http://newtest.medullan.com/wp/?page_id=3089
Here is the code and recycle the logical queries
Download Link:
http://basisinteractive.net/webdesign.html#wordpress