Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
xcommerce-gists / common.php
Created May 5, 2012 00:06
PHP OAuth 2 Implementation for PayPal Access
<?php
define('KEY', 'YOUR APPLICATION ID');
define('SECRET', 'YOUR APPLICATION SECRET');
define('CALLBACK_URL', 'YOUR CALLBACK PATH - TO COMPLETE.PHP');
define('AUTHORIZATION_ENDPOINT', 'https://identity.x.com/xidentity/resources/authorize');
define('ACCESS_TOKEN_ENDPOINT', 'https://identity.x.com/xidentity/oauthtokenservice');
define('PROFILE_ENDPOINT', 'https://identity.x.com/xidentity/resources/profile/me');
/***************************************************************************
@xcommerce-gists
xcommerce-gists / sample_config_xml
Created May 25, 2012 14:30
X.commerce sample "stub" module config.xml sample (for onboarding Magento storefronts to your extension)
<default>
<partner_channel>
<capability>
<registration>
<target_capability_name>Capability</target_capability_name>
<store_endpoint_url/>
<request_url><![CDATA[https://devportal.x.com/merchant_onboarding/]]></request_url>
<is_registered>1</is_registered>
<legal_agreement_url><![CDATA[http://www.magentocommerce.com/company/terms/]]></legal_agreement_url>
<store-front-platform><![CDATA[Magento ver. CE 1.5.1.0]]></store-front-platform>
@xcommerce-gists
xcommerce-gists / ppa-openid-connect_access-token-response
Created June 19, 2012 20:39
OpenID Connect integration with PayPal Access
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{ "access_token": "ElAV32hkKGlMT4H86HJK94f54HKDLZdf", "token_type": "Bearer", "refresh_token":
"ExLOxBtZp8JJHDHD9495HDHHDHFHFJHF", "expires_in": 900, "id_token":
"eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9zZXJ2ZXIuZXhhbXBsZS5jb20iLCJ1c2VyX2lkIjoiMjQ4Mjg5NzYxMDAxIiwiYXVkIjoiczZCaGRSa3F0MyIsIm5vbmNlIjoibi0wUzZftKVpFuc1pGaVsyZsOtkT32E4c6MDHeCvIDlR5ESC0ct8BLvGJDB5954MjCR4_X2GAEHonKw4NF8wTmUFvhslYXmjRNFs21Byjn3jNb7lSa3MBfVsw"
}
@xcommerce-gists
xcommerce-gists / Data.php
Created July 19, 2012 01:23
Snip from Data.php that determines whether or not the merchant has onboarded
public function getRegistrationRequest()
{
$request = new Varien_Object();
/** @var $fabricAuth Xcom_Xfabric_Model_Authorization */
$fabricAuth = Mage::helper('xcom_xfabric')->getAuthModel();
$postData = array();
$postData['target_capability_name'] = 'Your Extension Name Here';
$postData['legal_agreement_url'] = self::YOUR_LICENSE_URI;
$postData['store_instance_name'] = (string)Mage::app()->getConfig()->getNode(
@xcommerce-gists
xcommerce-gists / Avro_Coder.php
Created August 10, 2012 20:57
gist for Magento example
<?php
//
// This module is part of the Ponger capability. The module:
// -- handles the Ping message of the PingCapability transaction of the PingPong workflow
// -- sends the Pong message of the PingCapability transaction of the PingPong workflow in response
//
// Copy to your <magento-install-root> directory
include_once 'lib/avro.php';
@xcommerce-gists
xcommerce-gists / DoExpressCheckoutPayment
Created August 28, 2012 18:51
How to Accept a Basic Digital Goods 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=DoExpressCheckoutPayment
&VERSION=89
@xcommerce-gists
xcommerce-gists / DoCapture
Created August 28, 2012 20:44
How to Authorize and Process a Credit Card Payment Using Direct Payment.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=DoCapture
&VERSION=86
@xcommerce-gists
xcommerce-gists / CreateRecurringPaymentsProfile
Created August 28, 2012 20:59
How to Create a Recurring Payments Profile with 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=CreateRecurringPaymentsProfile
&VERSION=86
@xcommerce-gists
xcommerce-gists / ExecutePayment
Created August 28, 2012 21:13
How to Make a Delayed Chained Payment Using Adaptive Payments.curl
HTTP Headers
------------
-H "X-PAYPAL-SECURITY-USERID: insert_developer_user_name"
-H "X-PAYPAL-SECURITY-PASSWORD: insert_developer_password"
-H "X-PAYPAL-SECURITY-SIGNATURE: insert_developer_signature"
-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 / Pay
Created August 28, 2012 21:08
How to Make a Basic Chained 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