2014-04-25 3 views
0

프로그래밍 방식으로 페이팔 주문을 만들려고하지만 리디렉션 키가 필요합니다. 이를 작성하기 위해Drupal commerce 프로그래밍 방식으로 페이팔 wps 주문 생성

그러나
// Return to the payment redirect page for processing successful payments 
'return' => url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE)), 

내가 payment_redirect_key가 생성된다 찾을 수 없다 (즉, 어떤 함수가 생성) 페이팔 WPS 모듈과 같이 $ 순서 -> 데이터 [ 'payment_redirect_key']에서이 데이터를 취득 프로그래밍 방식으로 어떤 도움을 주셔서 감사합니다.

내 목표는 기본 드루팔 상거래 체크 아웃 메커니즘

답변

0

나는 아직 행운과 동일한 작업을 수행하기 위해 노력하고있어에게 우회하지만 payment_redirect_key가 생성 어디서 알아보십시오. 당신은 상업/모듈/commerce_payment의 기능 commerce_payment_redirect_pane_checkout_form에서 그것을 발견 할 수// commerce_payment.checkout_pane.inc 기능 commerce_payment_redirect_pane_checkout_form, 현재 버전 기본적으로 (http://cgit.drupalcode.org/commerce/tree/modules/payment/includes/commerce_payment.checkout_pane.inc#n360)

라인 (360)이있다 포함

$order->data['payment_redirect_key'] = drupal_hash_base64(time()); 
commerce_order_save($order); 

수정

며칠 동안 작업 한 후 몇 줄의 코드로 해결책을 찾았습니다. 나는이 함수를 메뉴 항목의 페이지 콜백 (product/% sku와 같은 것)으로 사용한다. 다음은 코드입니다.

<?php 
function custom_module_create_order($sku) { 
    global $user; 
    $product = commerce_product_load_by_sku($sku); 
    $order = ($user->uid) ? commerce_order_new($user->uid, 'checkout_checkout') : commerce_cart_order_new(); 
    // Save to get the Order ID. 
    commerce_order_save($order); 

    $line_item = commerce_product_line_item_new($product, 1, $order->order_id); 
    commerce_line_item_save($line_item); 
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order); 
    $order_wrapper->commerce_line_items[] = $line_item; 

    // Select here the payment method. Usually something like: 
    // [module_name]|commerce_payment_[module_name] 
    $order->data['payment_method'] = 'commerce_sermepa|commerce_payment_commerce_sermepa'; 
    commerce_order_save($order); 

    // Set status to order checkout to go to the payment platform redirect. 
    commerce_order_status_update($order, 'checkout_payment'); 

    drupal_goto('checkout/' . $order->order_id); 
} 
관련 문제