Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
xcommerce-gists / doEC-one-time-simple-payment.php
Created April 17, 2012 08:05
Single Payment with PayPal Express Checkout API
require_once('services/PayPalApi/PayPalAPIInterfaceServiceService.php');
/* setup payment details */
orderTotal = new BasicAmountType( '-your-currency-code-', '-your-amount-');
$PaymentDetails= new PaymentDetailsType();
$PaymentDetails->OrderTotal = $orderTotal;
/* create DoExpressCheckout request details */
$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = '-payer-id-from-get-EC-call;
@xcommerce-gists
xcommerce-gists / paypal-access-oauth2-python-sample-app.yaml
Created April 17, 2012 18:48
Python OAuth 2 Implementation for PayPal Access
application: oauth2-paypal
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: index.py
@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';
<?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 / 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