Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
xcommerce-gists / Test HTML code.html
Created September 20, 2012 20:10
How to Test PayPal Payments Standard Buttons.html
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Testing a PayPal Payments Standard Button</title>
</head>
<body>
<h2>Buy Strings!</h2>
<?php
// STEP 1: read POST data
// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
@xcommerce-gists
xcommerce-gists / DoCapture
Created October 11, 2012 23:19
How to Authorize and Process a Payment Using Express Checkout.curl
Request
-------
Endpoint URL: https://api-3t.sandbox.paypal.com/nvp
HTTP method: POST
POST data:
USER=merchant_user_name
&PWD=merchant_password
&SIGNATURE=merchant_signature
&METHOD=DoCapture
&VERSION=95
@xcommerce-gists
xcommerce-gists / Pay
Created November 14, 2012 23:23
How to Make a Parallel Payment Using Adaptive Payments.curl
HTTP Headers
------------
-H "X-PAYPAL-SECURITY-USERID: insert_developer_user_name_here"
-H "X-PAYPAL-SECURITY-PASSWORD: insert_developer_password_here"
-H "X-PAYPAL-SECURITY-SIGNATURE: insert_developer_signature_here"
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" #Standard Sandbox App ID
Endpoint
@xcommerce-gists
xcommerce-gists / getAccessToken-request-cURL
Last active August 2, 2019 09:19
PayPalAccessOpenIDConnectOAuth.cURL
curl https://api.paypal.com/v1/identity/openidconnect/tokenservice \
-u "<your_app_id>:<your_app_secret>" \
-d "client_id=&grant_type=authorization_code&code=<code>&redirect_uri=<urlencoded_return_url>"
@xcommerce-gists
xcommerce-gists / Pay
Created August 28, 2012 21:21
How to Set Up a Payment Preapproval Using Adaptive Payments.curl
HTTP Headers
------------
-H "X-PAYPAL-SECURITY-USERID: insert_developer_user_name_here"
-H "X-PAYPAL-SECURITY-PASSWORD: insert_developer_password_here"
-H "X-PAYPAL-SECURITY-SIGNATURE: insert_developer_signature_here"
-H "X-PAYPAL-REQUEST-DATA-FORMAT: NV"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" #Standard Sandbox App ID
Endpoint
@xcommerce-gists
xcommerce-gists / rest_test.php
Created November 20, 2012 02:02
Magento coupon code generator test script
<?php
/********************************************************************
File name: rest_test.php
Description:
A PHP test script that calls the Coupon AutoGen extension
to Magento's REST API.
The Coupon AutoGen API takes:
-- the rule ID of the &quot;Generate Coupons&quot; rule to execute
-- the number of coupon codes to generate
-- the length of each coupon code
@xcommerce-gists
xcommerce-gists / DoEC-parallel.curl
Created September 26, 2012 18:57
How to Make Parallel Payments Using Express Checkout.curl
curl -s --insecure https://api-3t.sandbox.paypal.com/nvp -d
"USER=<Caller_ID>
&PWD=<Caller_Pswd>
&SIGNATURE=<Caller_Sig>
&METHOD=DoExpressCheckoutPayment
&VERSION=93
&TOKEN=<Token> # TOKEN value returned from SetExpressCheckout
&PAYERID=<PayerID> # PAYERID value returned from GetExpressCheckoutDetails
&PAYMENTREQUEST_0_AMT=250 # first payment details
&PAYMENTREQUEST_0_CURRENCYCODE=USD
@xcommerce-gists
xcommerce-gists / CreateBillingAgreement
Created August 28, 2012 21:28
How to Set Up a Reference Transaction Using Express Checkout.curl
Request
-------
Endpoint URL: https://api-3t.sandbox.paypal.com/nvp
HTTP method: POST
POST data:
USER=insert_merchant_user_name_here
&PWD=insert_merchant_password_here
&SIGNATURE=insert_merchant_signature_value_here
&METHOD=CreateBillingAgreement
&VERSION=86
@xcommerce-gists
xcommerce-gists / getAccessToken-request-java
Last active August 12, 2016 08:59
PayPalAccessOpenIDConnectOAuth.java
//download the complete java code sample from https://github.com/paypal/paypal-access
/**
* Gets Access token by going to token service. Code is left blank so that user can fill it up manually.
*
* @return - Access token
*/
private static String getAccessToken(String authorizationCode) {
StringBuilder tokenUrl = new StringBuilder(
"https://api.paypal.com/v1/identity/openidconnect/tokenservice");