Enable GitHub Actions through REST API - rest

I have an on-prem GitHub instance with an org with many repos. Some seem to have actions Actions disabled:
However, if I query this through the REST API:
GET https://my.github.example.com/api/v3/repos/myorg/the-repository/actions/permissions results in:
{
"enabled": true,
"allowed_actions": "selected",
"selected_actions_url":
"https://my.github.example.com/repositories/21251/actions/permissions/selected-actions"
}
And even if I try to forcefully enable it, according to the docs:
PUT https://my.github.example.com/api/v3/orgs/myorg/actions/permissions/repositories/the-repository I get:
{
"message": "Conflict",
"errors": "GitHub Actions is enabled for all repositories",
"documentation_url": "https://docs.github.com/enterprise/3.4/rest/reference/actions#enable-a-selected-repository-for-github-actions-in-an-organization"
}
As for the button in the UI (the screenshot above), this works. The code behind it is:
<form class="" method="post" action="/myorg/the-repository/actions/enable">
<input class="btn btn-primary my-3" type="submit" value="Enable Actions on this repository">
<input type="hidden" name="authenticity_token" value="asdlkjflasdkjflaskjflasdkjflkasdjf">
</form>
However it doesn't post to the REST API but the Web UI (obviously)..

Related

Unable to receive form submissions on Netlify deploys

I am using a simple form that was taken from one of the Netlify related docs:
<form name="contact" action="/" method="post" data-netlify="true">
<div className="field">
<label htmlFor="name">Name</label>
<input type="text" name="name" id="name" value="dave"/>
</div>
<div className="field">
<label htmlFor="email">Email</label>
<input type="text" name="email" id="email" value="email#email.com" />
</div>
<div className="field">
<label htmlFor="message">Message</label>
<textarea name="message" id="message" rows="6"></textarea>
</div>
<input type="submit" value="Send Message" className="" />
</form>
In using gatsby develop and working with/submitting the form, things seem to work fine. I get no errors and get redirected to the home page as expected.
After deploying the site with Netlify and trying to submit the form, I get the following page error:
In my Netlify backend, the form appears in the console but I cannot/do not receive submissions.
I am using a barebones gatsby-config.js, only incorporating gatsby-source-wordpress and gatsby-plugin-google-analytics.
I also tried adding /no-cache=1 to form action.
Can anybody advise?
It might also be worth noting that I have coded my form as a component and am importing it into my footer as such. In that way, it may be imported multiple times on different pages as mentioned in point 3 of this StackOverflow answer.
Thanks.
I learned that because I'm using Gatsbyjs, and Gatsby + Netlify = javascript forms, I needed to add another input type="hidden" to my form:
<form name="my-form" ... >
<input type="hidden" name="form-name" value="my-form" />
The documentation for this wasn't immediately clear but below are some links that address this:
Here's a link to an article that pointed me to the answer: How to
Integrate Netlify’s Form Handling in a React App
Here's another one if you're building in Vue: How to Integrate
Netlify Forms in a Vue App
And all about Netlify Forms
If you are using any redirect method then you have to add _redirects file in your root folder and add paths to it so that redirect can work.
It's may be confusing but you can visit this link for more help.

Why Am I Getting Paypal generic error page in production but not in sandbox

Have been successfully using PayPal Cart buttons in PayPal Express for 2 years. Suddenly, when I click any "Cart button on my Store page, I get the dreaded ""Things don't appear to be working at the moment. Please try again later."
I tried the exact same transaction in the PayPal Sandbox and it processed fine. Now, however, that transaction draws the generic error page in "Live PayPal"
The only differences in the are in the action url, the business email, and the return url and store url:
Sandbox version of action attrbute:
<form id="form107" onsubmit="return CheckForm(this);"
action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_self">`
Live Version of action attribute:
<form id="form107" onsubmit="return CheckForm(this);"
action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_self">
(the javascript "CheckForm" function just checks data on the page to determine whether to show or hide a size dropdown)
The Sandbox integration URLs:
<input name="return" type="hidden" value="http://localhost:52980/Open/Congratulations/107/store">
<input name="shopping_url" type="hidden" value="http://localhost:52980/Store">
The "Live" integration URLS:
<input name="return" type="hidden" value="http://www.(mydomain).org/Open/Congratulations/107/store">
<input name="shopping_url" type="hidden" value="http://www.(mydomain).org/Store">
The code has worked up through 16 April 2018. No changes were made. As of 18 April 2018, we are now getting the PayPal generic error page upon clicking the Cart button

Paypal sandbox: this transaction is invalid

I am trying to integrate paypal express checkout(test) with no luck. Not sure what i am doing wrong. I have followed the documentation but i get "This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow." when i try to redirect to the browser to the sandbox login page.
<form method=post action=https://api-3t.sandbox.paypal.com/nvp>
<input type=hidden name=USER value=j***-1_api1.g*******s.com.au>
<input type=hidden name=PWD value=Q8P*******U6>
<input type=hidden name=SIGNATURE value=AFc************fH>
<input type=hidden name=VERSION value=124.0>
<input type=hidden name=PAYMENTREQUEST_0_PAYMENTACTION
value=Sale>
<input name=PAYMENTREQUEST_0_AMT value=19.95>
<input type=hidden name=RETURNURL
value=http://localhost/moes/paypal_complete.php>
<input type=hidden name=CANCELURL
value=http://localhost/moes/paypal_complete.php>
<input type=submit name=METHOD id="submit_paypal" value=SetExpressCheckout>
</form>
have also tried this on my site live in case localhost is causing the troubles, but still the same.
The ACK response i get back is success:
TOKEN=EC-83V63085L7957480A
TIMESTAMP=20150901T14:14:08Z
CORRELATIONID=ffb632c840981
ACK=Success
VERSION=124.0
BUILD=000000
But when i use the redirectURL in the documentation with the token i get the invalid transcation error.
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=EC-83V63085L7957480A
I am logged into developer.paypal.com when i try it, still every time is an invalid transaction.
the URL of the invalid transaction:
//http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_flow&SESSION=xa6gvld5X3qDZhYbt7pnz6rWMCzBdIFvAREoxohX4E5zH_3ydrzEQBnpQFW&dispatch=50a222a57771920b6a3d7b606239e4d529b525e0b7e69bf0224adecfb0124e9b61f737ba21b0819803370655d2811b9456e01fe893c80ec2
ideas?
You can get sample Express Checkout Code from the PayPal Wizard:
PayPal Express Checkout Code Wizard
<form action='expresscheckout.php' METHOD='POST'>
<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>
</form>
You will need to download the expresscheckout.php and the paypalfunctions.php files from the PayPal Code Wizard. Typically your PayPal API Signature goes in a separate php file. The paypalfunctions.php on the code wizard has the API credentials stored.
The below snippet is from the paypal.php file and it is the portion of the code for the sandbox endpoints.
if ($SandboxFlag == true)
{
$API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
$PAYPAL_URL = "https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=";
}
Also with Express Checkout you need to call Mark Express Checkout which is normally done in one of your PHP files.
You can get the complete php code from the code wizard.
Here is more documentation on Express Checkout from the PayPal Developer Site.
For anyone else reading this, i found that if i changed the redirectURL from:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=
to:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=
It redirects to the paypal(sandbox) log-in page as intended without error.
Hope this helps

Add multiple items to Paypal in single form using hosted_button_id

I want to setup a single form on a site to purchase multiple products via PayPal. The products are set in the PayPal account and each has a hosted_button_id.
The form would contain a series of descriptions and quantity fields, all initially set to zero. The customer could then add desired quantities against each product and submit the form with a single 'Buy now' button.
Is this possible with PayPal? I don't particularly want a 'cart' experience and I don't want to pass product prices (instead using the data stored at PayPal).
thanks
In the end I concluded you can't do this.
I tried everything, including AJAXing the submission and send the submission via a hidden iFrame to keep the user on my site. Nothing worked. It seems PayPal are very keen to enforce their approved shopping workflow when using their cart.
You can do this, but you'll need to do some server-side programming. You build an "encrypted button" programmatically, and submit that to PayPal.
My store page at https://secure.entrian.com/store/store.html does it - it prompts for some information, sends that to the server to be turned into an encrypted button, and then submits that to PayPal.
The JavaScript looks like this, where $license_name and $quantity are the fields that I'm prompting for, and formgen.py is a server-side Python script that builds and signs the request using OpenSSL according to PayPal's documentation:
$paypal_form.submit(function () {
var response = $.ajax({
type: "GET",
url: 'formgen.py?' + serialize({
licenseName: $license_name.val(),
quantity: $quantity.val()
}),
async: false
}).responseText;
if (response.indexOf('PKCS7') >= 0) {
$encrypted.val(response);
} else {
$payment_errors.text(response).show(easing_duration);
return false;
}
return true;
}
The form looks like this (simplified rather):
<form id="paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="upload" value="1">
<input type="hidden" id="encrypted" name="encrypted" value="">
<button id="buynow" class="submit-button btn" type="submit">Buy Now</button>
</form>
That <input name="encrypted" ...> gets populated with the AJAX response before the form gets submitted to PayPal.

Open external link (HTTPS) with POST values inside Fancybox?

Is there a way to open external https urls, triggered on post submit and with post data inside Fancybox popups or similar?
I am talking about Paypal payments, for example. Clicking the "Buy Now" button, the PayPal website would open inside Fancybox and the data would be parsed using Ajax.
This would improve the user experience, IMHO...
I tried this solution, found in another thread but it does not work...
$("#payment_form").bind("submit", function() {
$.ajax({
type : "POST",
cache : false,
url : "https://www.paypal.com/XXX/XXX",
data : $(this).serializeArray(),
success: function(data) {
$.fancybox(data);
}
});
return false;
});
<form id="payment_form"action="https://www.paypal.com/XXX/XXX" method="post">
<input type="hidden" name="yyy" value="xxxx">
<input type="hidden" name="yyy" value="xxxxxxxx">
<input class="gift-card" type="image" src="button.jpg" name="submit" alt="">
</form>
PayPal is actively enforcing the X-FRAME-OPTIONS:DENY response header, so I doubt this would work.
Note that I haven't tested it yet though, but PayPal actively discourages anyone from 'embedding' their site in any way, shape or form, so even if it works today, you can't guarantee it'll work tomorrow.